A small Python example of wrapping a REST API as MCP tools that Claude, Cursor and other MCP clients can call with validated input.
Any HTTP API: SaaS, internal backend, or third-party service
Pydantic validation, error handling, dual-format responses
Claude, Cursor, or any MCP-compatible client
Four tools over JSONPlaceholder: list, get, create and update.
List with filtering + pagination
Fetch with optional related data
Create with validated input
Partial update, marked destructive
Clone, install from the lock file, run the offline tests.
git clone https://github.com/BryceEWatson/mcp-api-bridge.gitcd mcp-api-bridgeuv sync --extra devuv run pytest -m "not live" # HTTP mocked, no networkuv run api-bridge # MCP server over stdio
The point of this project is the pattern. JSONPlaceholder is a stand-in: swap the API client and the tool functions, and the FastMCP wiring, validation and error handling carry over.
api_client.py: base URL, auth headers@mcp.tool pattern, with Annotated[type, Field(...)] parameters for your domainThe README has the full steps with code.
Security notes
The base URL is fixed in code, so tool input can't redirect requests. Input is checked against the schema before any HTTP call, and API failures come back as MCP errors. Prompt injection through tool output and response size limits are out of scope. The README lists both sides.