What is MCP? How AI agents use APIs
Concepts: Model Context Protocol, how agents call APIs, MCP vs REST, OpenAPI vs MCP, and exposing your API to AI.
What is MCP? (Model Context Protocol)
MCP (Model Context Protocol) is an open protocol that lets AI agents discover and call tools—including APIs. Instead of an agent calling your REST API directly, it talks to an MCP server that exposes your API as structured “tools” the agent can invoke. That’s how ChatGPT, Claude, Cursor, and other agents use external APIs: they connect to MCP servers (or similar tool backends) that describe available operations and handle the actual HTTP calls.
You can read the full spec and docs at the official MCP documentation.
How do AI agents call APIs?
AI agents don’t call REST endpoints raw. They use a tool layer: the agent gets a list of tools (name, description, parameters), chooses when to call one, and sends a structured request. The MCP server (or equivalent) then performs the real API call and returns the result. So “how do AI agents use external APIs?” — they use them through tools exposed by an MCP server (or similar) that wraps your API.
How does MCP work?
An MCP server advertises tools (operations) to the client (e.g. an IDE or agent runtime). Each tool has a name, description, and input schema. When the agent decides to use a tool, it sends the parameters; the server executes the operation (e.g. calls your REST API) and returns the response. So MCP is the protocol between the agent and the thing that actually talks to your API.
MCP vs REST API
REST is how your API is implemented (HTTP, JSON, endpoints). MCP is how an agent discovers and invokes capabilities. The bridge is an MCP server that maps MCP tool calls to your REST API. So: REST = your API’s interface; MCP = the protocol agents use to call tools that wrap your API.
What are MCP tools?
MCP tools are the operations an MCP server exposes—one tool per logical action (e.g. “get user”, “create order”). Each has a name, description, and JSON schema for parameters. Agents see this list and call tools by name with arguments; the server translates those into calls to your API.
OpenAPI vs MCP
OpenAPI describes your REST API (paths, methods, request/response schemas). MCP describes tools for agents (name, description, input schema). They’re complementary: you can generate MCP tools from an OpenAPI spec by mapping endpoints to tools. That’s exactly what Api2Agent does—turns your OpenAPI spec into an MCP server scaffold that exposes your API as MCP tools.
How to expose your API to AI (ChatGPT, Claude, Cursor)
To get your API used by AI agents, you need an MCP server (or equivalent) that exposes your API as tools. With an OpenAPI spec, you can generate that server: upload or paste your spec, get a TypeScript MCP server scaffold, then run or deploy it. Agents like Cursor or Claude connect to that server and can then call your API through the generated tools.
Use Api2Agent to generate an MCP server from your OpenAPI spec — no hand-writing required.