How to Turn Any API Into an MCP Server: 3 Ways
Learn 3 ways to turn any API into an MCP server with FastMCP, Speakeasy, or monday's ATP. Covers specs, read-only access, and MCP Inspector testing.
Your internal system has no MCP server, and you want Claude or your own agent to use it. Building one by hand can mean days of work for an API with 50 endpoints. This guide shows three faster routes, plus the steps to secure the server and test it before you connect it to Claude.
In short: If the API has an OpenAPI file, FastMCP turns it into an MCP server in a few lines. Speakeasy generates a server that is ready to distribute, and monday's ATP fits work with many endpoints through an agent interface. Without OpenAPI, you build a few tools by hand or create a spec from the documentation first. Before you connect to Claude, reduce permissions and test the server with MCP Inspector.
The Steps at a Glance
- Check for OpenAPI: Look for a file in the documentation or the code. If there is none, generate a spec or build the tools by hand.
- Choose a tool: FastMCP for a Python pilot, Speakeasy for a server ready to distribute, or ATP when you build an agent in code with many endpoints.
- Limit it to read-only: Expose only the actions you need, and give the key minimal permissions in the API itself.
- Test and connect: Run MCP Inspector, try the tools by hand, and only then connect to Claude.
Who This Guide Is For
- People who connect Claude, Cursor, Codex, or their own agent to a system that has no official MCP server
- AI transformation teams that need to open internal systems to agents without building a separate integration for each one
- Developers who want to understand when to convert automatically, when to build by hand, and where to host the server
The Problem in Short
MCP (Model Context Protocol) is the standard way to connect a language model to tools and data sources. An MCP server exposes tools with a schema, and the model calls them. The advantage: one connection works with every client. The disadvantage: someone has to write the server.
When you build an MCP server by hand on an existing API, each endpoint requires:
- A tool definition with a name and a description the model can understand
- A JSON schema for each parameter (type, required or not, valid values)
- An HTTP call with authentication (API key, OAuth, Bearer)
- Error handling and pagination
- Testing, and then maintenance: every time the API changes, the server breaks
An API with 50 endpoints is days of work. That is exactly the work you can save.
The Good News: an OpenAPI File
OpenAPI (formerly Swagger) is API documentation in a format that machines can read. It is a JSON or YAML file that describes every path, every parameter, every response schema, and the authentication method. Most modern APIs publish one. Here is where to find it:
- In the product documentation, usually under API Reference, with a Download OpenAPI or Swagger button
- At common addresses: /openapi.json, /swagger.json, /v1/openapi.yaml, /api-docs
- In public GitHub repos of large providers. Stripe, Twilio, GitHub, and Cloudflare publish official specs.
- In internal systems built with FastAPI, NestJS, Spring, or Django REST. The framework (sometimes with a plugin) generates the file automatically.
When you have this file, the next three ways turn it into an MCP server (or an interface for an agent) without writing a single tool by hand.
Way 1: FastMCP (Python, a Few Lines)
FastMCP is the popular Python library for building MCP servers. It has one function that does all the work: FastMCP.from_openapi(). You give it the spec and an authenticated HTTP client, and every endpoint becomes a tool (FastMCP documentation).
Install
pip install fastmcp httpx
The Full Server
# server.py
import httpx
from fastmcp import FastMCP
# HTTP client that talks to your API, including authentication
client = httpx.AsyncClient(
base_url="https://api.example.com",
headers={"Authorization": "Bearer YOUR_TOKEN"},
)
# Load the OpenAPI file (from a URL or a local file)
spec = httpx.get("https://api.example.com/openapi.json").json()
# Every endpoint becomes a tool
mcp = FastMCP.from_openapi(
openapi_spec=spec,
client=client,
name="My API Server",
timeout=30.0,
)
if __name__ == "__main__":
mcp.run() # stdio by default, or mcp.run(transport="http", port=8000)
Filtering: Not Every Endpoint Should Reach the Model
By default, FastMCP turns every path into a tool. That is a lot. With RouteMap, you can exclude admin paths, turn simple GET requests into resources, and keep only what the agent needs:
from fastmcp.server.openapi import RouteMap, MCPType
mcp = FastMCP.from_openapi(
openapi_spec=spec,
client=client,
route_maps=[
RouteMap(pattern=r"^/admin/.*", mcp_type=MCPType.EXCLUDE), # no admin
RouteMap(tags={"internal"}, mcp_type=MCPType.EXCLUDE), # no internal tags
RouteMap(methods=["GET"], pattern=r".*", mcp_type=MCPType.RESOURCE), # read = resource
RouteMap(mcp_type=MCPType.TOOL), # everything else = tool
],
)
You can also rename tools and change their descriptions with mcp_names and mcp_component_fn, so the model understands what each tool does.
The Warning the FastMCP Authors Give
The FastMCP documentation states clearly that a server converted automatically from OpenAPI works less well for the model than a server designed by hand. The library's creator also wrote a full post on this: Stop Converting Your REST APIs to MCP. Why? An API is designed for people and code, not for a model. It has dozens of similar endpoints, technical names, and parameters the model cannot fill in. The recommendation: start with the automatic conversion, see what the agent actually uses, and then narrow it down to 10 to 20 tools with clear names and descriptions. It is great for starting, and less good for finishing.
Connecting to Claude
For a broader explanation of local versus remote connections and key protection, see the guide to building a secure MCP server.
Claude Desktop (file claude_desktop_config.json):
{
"mcpServers": {
"my-api": {
"command": "python",
"args": ["/path/to/server.py"]
}
}
}
claude mcp add my-api -- python /path/to/server.py
Way 2: Speakeasy and Gram (No Code at All)
Speakeasy has generated SDKs from OpenAPI for years. Since July 2025, it also generates a standalone MCP server directly from the spec: a TypeScript server ready to deploy, with Zod schemas and error handling (Speakeasy).
Install and Run
# macOS
brew install speakeasy-api/tap/speakeasy
# macOS / Linux
curl -fsSL https://go.speakeasy.com/cli-install.sh | sh
# Generate an MCP server from the spec
speakeasy quickstart --mcp
The quickstart asks where the file is, what to name the project, and whether to deploy to Cloudflare. At the end, you have a folder with a complete MCP server in TypeScript.
Three Ways to Distribute
- npm package: run it with
npxfrom anywhere - Cloudflare Worker: a ready wrangler setup, with one deploy command (see below)
- MCPB file (formerly DXT): an installation package for Claude Desktop. Double-click and the server installs.
Controlling What the Model Sees
In OpenAPI, you can add an extension called x-speakeasy-mcp to each operation:
paths:
/tasks:
post:
operationId: createTask
x-speakeasy-mcp:
name: create_task
description: "Create a new task for the current user"
scopes: [write]
This gives you readable names, good descriptions, and scopes. For example, read-only access for an agent that should not change anything.
Gram: The Managed Version
If you do not want to host anything, Gram (from the same company) does the same thing in the cloud. You upload the OpenAPI file, choose which operations to expose, set authentication through environment variables, and get the URL of a hosted MCP server (Gram documentation). Prices and limits change, so check the current pricing page before you commit.
Way 3: monday's ATP (The Way That Doesn't Need MCP)
Agent Tool Protocol (ATP) is an open-source project (MIT license) from monday.com (GitHub). The problem it solves: when you connect many MCP servers, the full list of tools loads into the prompt before the agent starts thinking, and the context overflows. With ATP, the agent does not receive a list of tools. It searches for what it needs, writes a short piece of TypeScript code, and the code runs in an isolated sandbox.
The point that matters for this guide: the ATP server loads an OpenAPI file directly, along with your own functions and the MCP servers you already have, into one interface.
Install
npm install @mondaydotcomorg/atp-server @mondaydotcomorg/atp-client
The Server
import { createServer, loadOpenAPI } from '@mondaydotcomorg/atp-server';
const server = createServer({
execution: { timeout: 30000, memory: 128 * 1024 * 1024, provenanceMode: 'track' },
});
// An API that has no MCP server: load the OpenAPI directly
const crmAPI = await loadOpenAPI({
url: 'https://api.example.com/openapi.json',
name: 'crm',
auth: { apiKey: process.env.CRM_KEY },
});
server.addAPIGroup(crmAPI);
// Your own functions, with a schema
server.registerAPI('users', {
getUser: {
description: 'Get a user by ID',
inputSchema: { type: 'object', properties: { userId: { type: 'string' } }, required: ['userId'] },
handler: async ({ userId }) => db.users.find(userId),
},
});
server.listen(3333);
The Agent
import { AgentToolProtocolClient } from '@mondaydotcomorg/atp-client';
const client = new AgentToolProtocolClient({ baseUrl: 'http://localhost:3333' });
await client.init({ name: 'my-agent', version: '1.0.0' });
await client.connect();
// The agent searches only for what is relevant
const found = await client.searchAPI('find customer by email');
// Then it writes code that combines several calls at once
const result = await client.execute(`
const c = await crm.findCustomer({ email: 'dana@example.com' });
const orders = await crm.listOrders({ customerId: c.id, limit: 50 });
return orders.filter(o => o.status === 'open').length;
`);
The project is still in version 0.x, so check the current API in the README before you copy code.
Why It Is Different
- Sandbox: the code runs in an isolated environment with memory and time limits.
Questions people ask
What is the difference between MCP and an API? Can't I just give the model the API?
A model cannot call HTTP on its own. MCP is the layer that turns an intent into a call, with a schema the model can fill in and authentication that does not pass through the prompt.
How many tools is too many?
There is no official number. It does say that with dozens of tools on one server, the context fills up and the model chooses less well. That is why FastMCP warns against converting everything, and why solutions like ATP and Composio move to a search-then-execute model.
Can I build an MCP server without writing code?
Partly. Composio and Gram offer ready-made, hosted servers. For your own internal API, you will usually still need at least an OpenAPI file.
How do I check that the server works before connecting it to Claude?
Run npx @modelcontextprotocol/inspector. It opens an interface that shows the tools and lets you run them by hand before you connect a client.
