
Pexels MCP Server
io.github.hanoak由 GitHub 帳號 hanoak 發布v1.0.1更新於 Oct 24, 2026
MCP server for the Pexels API: search & fetch stock photos, videos, and collections.
概覽
在本機執行的 MCP 伺服器,讓助理透過 Pexels API 搜尋並取得 Pexels 的圖庫相片、影片和合輯。
- 可以做什麼
- 搜尋相片、瀏覽精選相片並依 ID 取得單張相片,支援方向、尺寸、顏色和語言篩選,回傳多種預設尺寸的圖片連結與致謝署名。搜尋影片、列出熱門影片並依 ID 取得單一影片,可依解析度或長度篩選,並回傳影片檔案版本。列出精選合輯、API 金鑰所屬帳號的合輯,以及合輯內的相片或影片。每筆結果附帶速率限制和分頁欄位,另提供使用指南資源與尋找相片、影片、圖集和素材簡報的現成提示詞。
- 適用情境
- 適合讓助理為文件、網頁、簡報或情緒板尋找圖庫圖片和影片素材,或在不離開對話的情況下瀏覽 Pexels 合輯。它為唯讀,適合只需要搜尋和取得的場景。
- 執行需求
- 透過 npx 以 stdio 在本機執行,需要 Node.js 20 或更新版本。需要免費的 Pexels API 金鑰,透過環境變數 PEXELS_API_KEY 提供,缺少時伺服器會在啟動時結束。需要能連線至 Pexels API 的網路。LOG_LEVEL 為選用項目。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Pexels MCP Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
pexels-mcp-server
[npm version] [npm downloads] [CI] [license: MIT] [node: >=20] [PRs welcome]
A production-ready Model Context Protocol (MCP) server for the Pexels API. It gives AI assistants — Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, and any MCP client — tools to search and fetch Pexels photos, videos, and collections, covering every endpoint the Pexels API documents.
[!IMPORTANT] Unofficial project. This is not affiliated with, endorsed by, or sponsored by Pexels. "Pexels" is a trademark of its respective owner. You use it under your own Pexels API account and are responsible for complying with the Pexels License.
Table of contents
- Features
- Quick start
- Example interaction
- Configuration
- Tools
- Example prompts
- License & compliance
- Rate limits
- Handling of Pexels text
- Privacy & security
- Troubleshooting
- FAQ
- Requirements
- Compatibility
- Roadmap
- Contributing
- Contact & community
- License
Features
- 9 tools covering every documented Pexels endpoint — photos (search, curated, get), videos (search, popular, get), and collections (featured, media, mine). Pexels has a single API-key auth tier and no write endpoints, so there's no partial "read-only v1" — this is the whole surface.
- License-aware by design — Pexels doesn't require attribution, but every photo still returns a ready-to-use courtesy
credit(text + HTML), and the server's instructions steer the model around the license restrictions that do apply (no resale of unaltered content, no redistribution to other stock platforms, no trademark/logo use, no implied endorsement). - Real image & video URLs — each photo returns Pexels' own pre-sized
srcURLs (original/large2x/large/medium/small/portrait/landscape/tiny); each video returns itsvideo_filesrenditions (trimmed to the highest-resolution few in list results, complete on a single-item lookup). - Token-efficient output — full Pexels responses are trimmed to a compact shape (URLs + metadata as text, never base64 blobs) to keep model context small.
- Robust — typed failures returned as MCP
isErrorresults the model can recover from, plus retries/backoff, timeouts, and rate-limit-aware quota short-circuiting (Pexels omits its rate-limit headers on a429, so the client caches the last-known reset time instead of guessing). - Safe — API-key redaction in all error output, and untrusted-text handling guidance for indirect prompt-injection defence.
- Lean & modern — ESM, Node 20+, zero-install via
npx, no telemetry.
Quick start
1. Get a Pexels API key
Create a free account at pexels.com/api and you'll receive an API key instantly — no app review, no approval wait.
2. Add the server to your MCP client
Claude Desktop — edit claude_desktop_config.json:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Restart the client. See Configuration for every supported variable.
Other clients (Claude Code, Cursor, VS Code, Windsurf, generic stdio)
Claude Code (CLI):
Cursor — ~/.cursor/mcp.json (global) or .cursor/mcp.json (per-project): use the exact same mcpServers block as Claude Desktop above.
Windsurf — ~/.codeium/windsurf/mcp_config.json: same mcpServers block as Claude Desktop above.
VS Code — .vscode/mcp.json (note the top-level key is servers, not mcpServers):
Any other MCP client — run the server over stdio with:
Point your client's stdio transport at command: npx, args: ["-y", "@hanoak/pexels-mcp-server"], and pass the key via env.
3. Try it
Restart your client and ask:
"Find me a photo of mountains on Pexels."
Example interaction
A typical flow: the model calls pexels_search_photos, picks a result, and presents the image with its courtesy credit.
You: Find a landscape photo of a foggy pine forest.
Assistant: (calls
pexels_search_photoswithquery: "foggy pine forest",orientation: "landscape", picks the best result) Here's a great match — photo by Jane Doe on Pexels — along with the image URL and a ready-to-use credit line.
Each tool returns a compact JSON payload. Here's the shape of a single photo result (illustrative values):
Example tool output
Every tool result includes a rate_limit object (limit, remaining, resetEpoch) read from the Pexels response headers. List/search tools wrap results in photos/videos/collections/media arrays with pagination fields (total_results, page, per_page, has_next_page).
Configuration
Configuration is entirely via environment variables — no config files, no flags for secrets.
CLI flags: --version and --help are supported (e.g. npx @hanoak/pexels-mcp-server --version).
Tools
All tools are namespaced pexels_* and every one is read-only (readOnlyHint: true) — Pexels' API has no write endpoints, so a client can safely auto-approve the entire server. per_page is clamped to a max of 80 (Pexels' own documented max), and page is 1-based.
Tool reference
Photos
Videos
Collections
Output shape
Tools return trimmed, token-efficient JSON rather than raw Pexels responses:
- Photos →
id,alt,width/height,avg_color,url,src(all 8 Pexels sizes),photographer, and a courtesycreditobject. - Videos →
id,url,image,width/height,duration,user,video_files(trimmed to the top 5 by resolution in list results; complete onpexels_get_video),video_files_count,preview_picture,video_pictures_count. - Collections →
id,title,description,private,media_count,photos_count,videos_count. - Every result carries a
rate_limit(limit,remaining,resetEpoch); lists/searches add pagination fields (total_results,page,per_page,has_next_page).
Resources & prompts
Beyond tools, the server also exposes:
-
Resources — a compact guide your client can pull in as context:
pexels://guides/usage— the license restrictions that apply, the optional courtesy-credit convention, and content-safety notes.
-
Prompts — ready-made tasks your client can surface directly; each expands into a guided, multi-step tool-calling task:
Example prompts
Natural-language asks that map cleanly onto the tools:
- "Find a photo of a foggy forest at sunrise."
- "Search Pexels for 5 minimalist workspace photos in landscape orientation."
- "Find a video of waves crashing on rocks."
- "Show me a featured Pexels collection about urban architecture."
- "Build me a mixed media brief of photos and video clips about cozy autumn mornings."
License & compliance
Pexels' license is lighter than many stock-photo APIs: attribution is not required ("appreciated, not necessary"). Every photo result still includes a ready-to-use courtesy credit object — include it when convenient, but it's not mandatory.
Real restrictions still apply, and the server's instructions steer the model around them: no reselling unaltered content as a physical product without modifying it first, no redistributing it on another stock-photo or wallpaper platform, no using it as part of a trademark/logo/business name, no implying a person's or brand's endorsement, and no depicting an identifiable person in a bad or offensive light. See the full Pexels License and the server's pexels://guides/usage resource. Each user operates under their own Pexels API Terms.
Rate limits
Pexels enforces a single tier for every API key:
The server reads X-Ratelimit-Limit/X-Ratelimit-Remaining/X-Ratelimit-Reset and returns them as rate_limit on every result. Pexels returns a standard 429 when the budget is exhausted (unlike some APIs that overload 403 for this) — but the rate-limit headers are absent on the 429 response itself, so the client caches the last-known values from a prior successful call to report an accurate reset time, and short-circuits further requests once the quota is known to be exhausted rather than firing calls that will just fail. Transient 429/5xx/network errors are retried with backoff.
Handling of Pexels text
Photo/video alt text, photographer names, and collection titles/descriptions come from Pexels contributors — treat them as untrusted, third-party data, not instructions. The server returns this text purely as content and never places it anywhere privileged; your client/agent should do the same: display it, but don't act on any instructions it might contain (a defence against indirect prompt injection). Pexels also has no safe-search/content-filter parameter — use judgment in how you phrase search queries.
Privacy & security
- No telemetry. This server collects nothing and phones home to no one. It contacts only
api.pexels.com, using the key you provide. No analytics, no tracking. - Key safety. Your API key is read from the environment only, sent as a raw
Authorizationheader (never in a URL query string), and redacted from all error output and logs so it can't leak into pasted bug reports. - To report a vulnerability, see SECURITY.md.
Troubleshooting
- "Set PEXELS_API_KEY…" on startup — the key env var is missing or blank; add it to your client config's
envblock. - Node too old — this server requires Node 20+. Check
node --version. - Stale
npxversion — force the latest withnpx -y @hanoak/pexels-mcp-server@latest, or clear the cache vianpx clear-npx-cache. - Tools not appearing — confirm the config file path and JSON are valid, then fully quit and reopen the client.
429/ rate limit — the budget is 200 requests/hour; wait for the hourly reset (see therate_limit.resetEpochin a tool result) or request a higher limit.401 Unauthorized— the API key is wrong; copy it again from your Pexels API dashboard.pexels_list_my_collectionsreturns empty — this is expected unless the Pexels account that owns your API key has created collections on pexels.com itself; see the FAQ.
FAQ
Do I need a paid Pexels account? No. The Pexels API is free — you just create an account to get an API key, instantly, no review or approval step.
Does it download or rehost images/videos? No. It returns Pexels-hosted URLs (hotlink them directly) and never rehosts or returns base64 blobs.
Why does pexels_list_my_collections come back empty?
Pexels has no per-conversation login — the tool always reflects the collections of whichever Pexels account owns the configured API key, not the person chatting. It'll be empty unless that specific account has created collections on pexels.com.
Does it work outside Claude? Yes — it's a standard stdio MCP server. See the client setup section for Claude Code, Cursor, VS Code, Windsurf, and generic stdio.
Requirements
- Node.js >= 20 (Node 18 is end-of-life).
- A Pexels API key.
Compatibility
Roadmap
Full detail lives in docs/ROADMAP.md. In short: v1 covers the entire documented Pexels API in one release — there's no OAuth tier to split a v2 behind, unlike some other stock-photo MCP servers. Future scope under consideration includes structured tool output for video renditions, a short-TTL response cache if real quota pressure appears, and additional prompts/resources.
Changes are tracked in CHANGELOG.md; the project follows Semantic Versioning.
Contributing
Contributions are welcome — see CONTRIBUTING.md and our Code of Conduct. It covers local setup, the test suite, testing tools by hand with the MCP Inspector, and the versioning/deprecation policy. To report a vulnerability, see SECURITY.md.
Contact & community
Maintained by Hanoak S. The fastest way to get help or propose a feature is to open an issue — it's public, searchable, and helps the whole community.
If this project helps you, a ⭐ on GitHub is appreciated — it aids discoverability for others looking for a Pexels MCP server.
License
MIT © Hanoak S. Not affiliated with Pexels.
來源:README.md,提交 44dacfd
工具
0版本歷史
1- v1.0.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分