mcp-server-pexels is an MCP server that provides image and video search capabilities for the Pexels free stock library, optimized for LLM scenarios. Pexels provides free stock photos and video resources.
Main capabilities
- Photo search: Supports filtering photos by query terms and conditions such as orientation, size, color, and language.
- Video search: Can search videos and automatically selects the HD MP4 closest to 1920x1080.
- Get details: Retrieves full metadata by photo or video ID.
- Smart caching: Search results have a cache TTL of 10 minutes, and queries by ID have a cache TTL of 60 minutes.
- Error handling: Follows MCP best practices, providing graceful failure handling and helpful error messages.
- Attribution: Photographer attribution information is mandatorily included in every result.
How to use
- Get an API Key: Register at pexels.com/api to get a Pexels API key (free, no credit card required).
- Build the server.
- Add to Claude Desktop: Open the configuration file (on Mac, ~/Library/Application Support/Claude/claude_desktop_config.json; on Windows, %APPDATA%\Claude\claude_desktop_config.json) and add the configuration. Windows note: Use the full path to node.exe or add Node to PATH; using forward slashes in paths also works on Windows.
- Restart Claude Desktop. The server will then be available as three tools: pexels_search_photos, pexels_search_videos, and pexels_get_details. It can also be added to your .mcp.json or claude_desktop_config.json, with PEXELS_API_KEY set in the environment; for local development, you can create a .env file.
Documentation for LLM agents is located at docs/agents/AGENTS.md, covering tool semantics, caching behavior, response structure, and attribution requirements.
Code structure
- src/index.ts: entry point, MCP server setup
- src/tools/: tool implementations
- src/shared/: caching, API client, errors, types, video selector
- src/utils/: Zod validation schemas
Engineering decisions Tested with StdioClientTransport on @modelcontextprotocol/sdk v1.29+. The integration test suite starts the built server and validates each tool call against the SDK's CallToolResultSchema and ContentBlockSchema. A structured JSON block containing typed data (id, kind, creatorName, dimensions, URLs) is appended to the last content element of every successful response. Downstream clients and agent frameworks can parse this block directly without parsing markdown text with regular expressions.
Future improvements
- Tool execution telemetry: Add structured logging for cache hits/misses, query execution time, and error rates to support troubleshooting of AI agents in production environments and demonstrate observability best practices.
- Metrics endpoint: Expose counters (requests served, cache hit rate, remaining API quota) for monitoring.
- Custom TTL configuration: Allow users to adjust cache TTL via environment variables.
Community submission This is an unofficial community project and is not affiliated with Pexels. The project is positioned as an MCP server for Pexels stock photos and videos.
Limitations The project's specific build commands, complete configuration examples, pricing and charging information, and platform compatibility details are not yet provided in the materials.