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.

概览

AI 生成的概览

本地运行的 MCP 服务器,让助手通过 Pexels API 搜索并获取 Pexels 的图库照片、视频和合集。

可以做什么
搜索照片、浏览精选照片并按 ID 获取单张照片,支持方向、尺寸、颜色和语言筛选,返回多种预设尺寸的图片链接和致谢署名。搜索视频、列出热门视频并按 ID 获取单个视频,可按分辨率或时长筛选,并返回视频文件版本。列出精选合集、API 密钥所属账号的合集,以及合集内的照片或视频。每条结果附带速率限制和分页字段,另提供使用指南资源和查找照片、视频、图集与素材简报的现成提示词。
适用场景
适合让助手为文档、网页、演示或情绪板寻找图库图片和视频素材,或在不离开对话的情况下浏览 Pexels 合集。它只读,适合只需要搜索和获取的场景。
运行要求
通过 npx 以 stdio 在本地运行,需要 Node.js 20 或更高版本。需要免费的 Pexels API 密钥,通过环境变量 PEXELS_API_KEY 提供,缺失时服务器会在启动时退出。需要能访问 Pexels API 的网络。LOG_LEVEL 为可选项。
安装前请注意
PEXELS_API_KEY 密钥写在客户端配置中并发送给 Pexels,日志和错误输出中会做脱敏处理。Pexels 对每个密钥限制每小时 200 次、每月 20,000 次请求。图片替代文本、作者名和合集描述来自贡献者,应视为不可信数据而非指令。Pexels 没有安全搜索过滤,且该项目为非官方项目,需遵守 Pexels 许可协议。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Pexels MCP Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

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

  • 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 src URLs (original/large2x/large/medium/small/portrait/landscape/tiny); each video returns its video_files renditions (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 isError results the model can recover from, plus retries/backoff, timeouts, and rate-limit-aware quota short-circuiting (Pexels omits its rate-limit headers on a 429, 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
json
{  "mcpServers": {    "pexels": {      "command": "npx",      "args": ["-y", "@hanoak/pexels-mcp-server"],      "env": {        "PEXELS_API_KEY": "your_api_key"      }    }  }}

Restart the client. See Configuration for every supported variable.

Other clients (Claude Code, Cursor, VS Code, Windsurf, generic stdio)

Claude Code (CLI):

bash
claude mcp add pexels \  --env PEXELS_API_KEY=your_api_key \  -- npx -y @hanoak/pexels-mcp-server

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):

json
{  "servers": {    "pexels": {      "command": "npx",      "args": ["-y", "@hanoak/pexels-mcp-server"],      "env": {        "PEXELS_API_KEY": "your_api_key"      }    }  }}

Any other MCP client — run the server over stdio with:

bash
PEXELS_API_KEY=your_api_key npx -y @hanoak/pexels-mcp-server

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_photos with query: "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
json
{  "photo": {    "id": 1103970,    "alt": "Photography of Trees at Foggy Forest",    "width": 4000,    "height": 2667,    "avg_color": "#3E361F",    "url": "https://www.pexels.com/photo/photography-of-trees-at-foggy-forest-1103970/",    "src": {      "original": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg",      "large2x": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&h=650&w=940",      "large": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&h=650&w=940",      "medium": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&h=350",      "small": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&h=130",      "portrait": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800",      "landscape": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200",      "tiny": "https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280"    },    "photographer": {      "name": "Jane Doe",      "url": "https://www.pexels.com/@janedoe",      "id": 42    },    "credit": {      "text": "Photo by Jane Doe on Pexels",      "html": "Photo by <a href=\"https://www.pexels.com/@janedoe\">Jane Doe</a> on <a href=\"https://www.pexels.com\">Pexels</a>"    }  },  "rate_limit": { "limit": 200, "remaining": 199, "resetEpoch": 1755000000 }}

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.

Environment variableRequiredDescription
PEXELS_API_KEYyesYour Pexels API key. The server exits at startup with a clear message if it is missing or blank.
LOG_LEVELnodebug | info | warn | error (default info). All logs go to stderr; stdout carries only the MCP protocol.

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.

DomainTools
Photossearch_photos, curated_photos, get_photo
Videossearch_videos, popular_videos, get_video
Collectionslist_featured_collections, list_my_collections, get_collection_media

Tool reference

Photos
ToolParametersDescription
pexels_search_photosquery (required), orientation? (landscape|portrait|square), size? (large|medium|small), color? (named color or hex code), locale?, page?, per_page?Keyword photo search with filters.
pexels_curated_photospage?, per_page?Pexels' hand-curated photo picks, refreshed hourly.
pexels_get_photoid (required)A single photo by its numeric ID, full detail.
Videos
ToolParametersDescription
pexels_search_videosquery (required), orientation?, size? (large=4K|medium=Full HD|small=HD), locale?, page?, per_page?Keyword video search with filters.
pexels_popular_videosmin_width?, min_height?, min_duration?, max_duration?, page?, per_page?Currently popular videos, optionally filtered by size/duration.
pexels_get_videoid (required)A single video by its numeric ID — returns every rendition, not just the top few.
Collections
ToolParametersDescription
pexels_list_featured_collectionspage?, per_page?Pexels' featured collections (metadata only).
pexels_list_my_collectionspage?, per_page?Collections belonging to the account that owns the configured API key (see FAQ).
pexels_get_collection_mediaid (required), type? (photos|videos), sort? (asc|desc), page?, per_page?The photos/videos inside a collection, each tagged with media_type.

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 courtesy credit object.
  • Videos → id, url, image, width/height, duration, user, video_files (trimmed to the top 5 by resolution in list results; complete on pexels_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:

    PromptArgumentsWhat it does
    find_photosubject (required), orientation?Search for one photo and present it with a courtesy credit.
    photo_gallerytheme (required), count?, orientation?, color?Build a themed set of photos (up to 10), each with a courtesy credit.
    find_videosubject (required), orientation?Search for one video and present it with a courtesy credit.
    collection_tourtheme (required), count?Find a matching featured collection and walk through its media.
    media_brieftheme (required), photo_count?, video_count?Gather both photos and videos for a theme, presented together.

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:

BudgetNotes
200 requests/hourHigher limits available on request once you have real usage.
20,000 requests/monthTracked alongside the hourly budget.

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 Authorization header (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 env block.
  • Node too old — this server requires Node 20+. Check node --version.
  • Stale npx version — force the latest with npx -y @hanoak/pexels-mcp-server@latest, or clear the cache via npx 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 the rate_limit.resetEpoch in 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_collections returns 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

ComponentSupported
Node.js20 and 22, tested in CI; >=20 required (enforced by engines and a runtime guard).
OSLinux, macOS, and Windows (all tested in CI).
MCP SDK@modelcontextprotocol/sdk ^1.30; the protocol version is negotiated with your client on connect.
Transportstdio (HTTP/SSE may be added in a future release).

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
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分