Featured

Deploy OpenClaw in 60 seconds β€” 20% off logoDeploy OpenClaw in 60 seconds β€” 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger β†’
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger β†’
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free β†’
Your own AI agent, running 24/7 with QwikClaw logoYour own AI agent, running 24/7 with QwikClaw

QwikClaw sets up and runs an always-on OpenClaw agent for you. One click, no config files, no server setup.

Deploy now β†’
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data β€” no proxies, no parsers, no maintenance.

Start building free β†’
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it β€” secured from day one.

Get it set up for you β†’
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free β†’
Reach 47,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here β†’

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

mcp-server-pexels MCP server](https://glama.ai/mcp/servers/afshinator/mcp-server-pexels/badges/score.svg)](https://glama.ai/mcp/servers/afshinator/mcp-server-pexels) πŸ“‡ ☁️ - An MCP server to search for (free) stock images and videos from pexels.com.

README.md

mcp-server-pexels

An MCP server for Pexels stock photo and video search. Optimized for LLMs.

![Lint](https://github.com/afshinator/mcp-server-pexels/actions/workflows/lint.yml) ![MCP]() ![License](LICENSE) ![smithery badge](https://smithery.ai/servers/afshinator/mcp-server-pexels) ![mcp-server-pexels MCP server](https://glama.ai/mcp/servers/afshinator/mcp-server-pexels)

!project image

Pexels provides free stock photos and videos.

Features

  • Photo Search β€” Search photos with filters (query, orientation, size, color, locale)
  • Video Search β€” Search videos, auto-selects HD .mp4 closest to 1920x1080
  • Get Details β€” Retrieve full metadata for a photo/video by ID
  • Intelligent Caching β€” 10 min TTL for searches, 60 min for ID lookups
  • Error Handling β€” Graceful failures with helpful messages (per MCP best practices)
  • Attribution β€” Mandatory photographer credits in every result

For LLM agents: See docs/agents/AGENTS.md for agent-optimized documentation β€” tool semantics, caching behaviour, response structure, and attribution requirements.

Prerequisites

Quick Start (2 minutes)

1. Get an API Key

Sign up at pexels.com/api β€” free, no credit card.

2. Build the Server

npm install && npm run build

3. Add to Claude Desktop

Open ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows), add:

{
  "mcpServers": {
    "pexels": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-server-pexels/build/index.js"],
      "env": {
        "PEXELS_API_KEY": "YOUR_PEXELS_API_KEY"
      }
    }
  }
}

Windows note: Use node.exe full path or add Node to PATH. Forward slashes in paths work on Windows.

4. Restart Claude Desktop

The server is now available as pexels_search_photos, pexels_search_videos, and pexels_get_details.

Configuration

Add to your .mcp.json or claude_desktop_config.json:

{
  "mcpServers": {
    "pexels": {
      "command": "node",
      "args": ["/absolute/path/to/build/index.js"],
      "env": {
        "PEXELS_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}

Environment

Set PEXELS_API_KEY in your environment. For local dev, create a .env file: `` PEXELS_API_KEY=your_pexels_api_key ``

Development

npm run dev       # watch mode
npm run inspector # MCP Inspector
npm test          # build + run all tests (125+)
npm run lint      # check code style with Biome
npm run format    # auto-format with Biome

LLM-optimized docs for agent consumers are at docs/agents/AGENTS.md.

Tools

| Tool | Description | |------|-------------| | pexels_search_photos | Search for photos by query | | pexels_search_videos | Search for videos | | pexels_get_details | Get details by ID and type |

Architecture

  • src/index.ts β€” Entry point, MCP server setup
  • src/tools/ β€” Tool implementations
  • src/shared/ β€” Cache, API client, errors, types, video selector
  • src/utils/ β€” Zod validation schemas

Engineering Decisions

| Decision | Rationale | |----------|----------| | Cache-first architecture | Pexels API allows 200 requests/hour. Caching (10m TTL for searches, 60m for ID lookups) preserves quota, reduces latency to <5ms on cache hit, and demonstrates awareness of API costs β€” critical for production AI systems where agents frequently re-request the same context. | | Fail-fast at call time | MCP servers are spawned as child processes β€” starting is not the time to fail. Server warns on startup but fails gracefully on first tool call with structured isError: true. | | Zod validation schemas | MCP v2 SDK requires z.object() wrappers. Catches invalid input before it reaches the API. | | resource_link for media | Remote images and videos are provided as MCP resource_link content blocks with proper mimeType. The markdown image link in the text block remains as a fallback for clients that do not render resource_link. | | Pure video selection | Video selection logic isolated in video-selector.ts β€” testable independently from tool handler. | | Hardcoded attribution | Required by Pexels Terms of Service. Embedded in every text response. |

Compatibility

Tested with @modelcontextprotocol/sdk v1.29+ via StdioClientTransport. The integration test suite spawns the built server and validates every tool call against the SDK's CallToolResultSchema and ContentBlockSchema.

A structured JSON block is appended as the last content element in every successful response, containing typed data (id, kind, creatorName, dimensions, URLs). Downstream clients and agent frameworks can parse this block directly instead of regex-parsing the markdown text.

Future Improvements

  • Tool execution telemetry β€” Add structured logging for cache hits/misses, query execution time, and error rates. This supports troubleshooting AI agents in production and demonstrates observability best practices.
  • Metrics endpoint β€” Expose counters (requests served, cache hit ratio, API quota remaining) for monitoring.
  • Custom TTL configuration β€” Allow users to tune cache TTL via environment variables.

Community Submissions

  • are welcome! 🌟

License

Unofficial community project. Not affiliated with Pexels.

See related servers & alternatives β†’

Related MCP servers

Browse all β†’

Related guides

Hand-picked reading to help you choose and use Search servers.