mcp-server-pexels

mcp-server-pexels

Search and find free images and videos from Pexels.com. (free api key required)

Category
Visit Server

README

mcp-server-pexels

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

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

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          # run tests

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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured