Skip to content

MCP vs OpenAPI: A Protocol vs an API Description, for AI Tools

By Shoaib HossainAugust 1, 202612 min readUpdated October 17, 2026

"MCP or OpenAPI?" is a common question when connecting AI agents to tools, and it is slightly the wrong question. The Model Context Protocol is a protocol: a client and a server exchange JSON-RPC 2.0 messages at runtime to discover and call tools, read resources, and fetch prompt templates. The OpenAPI Specification is a description format: a YAML or JSON document that describes an HTTP API's paths, operations, parameters, and responses, so that tools (and models) can understand and call it without reading its source. One is a conversation, the other is a contract.

Both can end in the same place, a model calling a function, and both are used that way: MCP servers by hosts such as Claude Code, Gemini CLI, and ChatGPT, and OpenAPI documents by tools that turn an API description into function definitions, such as ChatGPT's Custom GPT Actions. This guide compares how each works, where each fits, and how they are often combined. It follows the MCP specification (2025-06-18) and the OpenAPI 3.1 specification. For a hands-on MCP setup, see MCP with ChatGPT and the OpenAI API.

MCP is a protocol a client and server speak at runtime; OpenAPI is a document that describes an HTTP API
MCP is a protocol a client and server speak at runtime; OpenAPI is a document that describes an HTTP API

What each one actually is

MCP defines messages and their meaning. A server declares capabilities (tools, resources, prompts) during initialisation; the client asks tools/list to discover tools, each with a name, a description, an inputSchema (JSON Schema), and optionally an outputSchema and annotations; and it calls tools/call to run one. Messages travel over one of two standard transports: stdio, where the client launches the server as a subprocess, or Streamable HTTP, a single HTTPS endpoint that accepts POST and GET and may stream with server-sent events.

OpenAPI describes an HTTP API you already have. A document lists paths and operations, each with an operationId, parameters (path, query, header, cookie), a requestBody, responses, and references to securitySchemes for authentication. It says nothing about how a model should use the API; it is a machine-readable contract used for documentation, client and server code generation, testing, and gateways.

So the categories differ. MCP is closer to "HTTP plus a fixed set of methods for AI tools"; OpenAPI is closer to "a typed interface definition for one service".

Quick reference

  • Both use JSON Schema for inputs, so a tool's inputSchema and an operation's parameter schema can often be translated mechanically.
  • MCP also standardises things OpenAPI has no notion of: server-to-client notifications such as tools/list_changed, resources, and prompt templates.
  • OpenAPI covers things MCP leaves to the server: HTTP status codes, content negotiation, and a full description of response bodies.

Remember this

MCP is a runtime protocol for AI tool access; OpenAPI is a static description of an HTTP API. Compare them as such.

The same capability, both ways

Here is one capability, "get an order by ID", in each form. As an MCP tool, returned from tools/list:

1{2  "name": "get_order",3  "title": "Order lookup",4  "description": "Fetch one order by its ID. Use only for order questions.",5  "inputSchema": {6    "type": "object",7    "properties": { "order_id": { "type": "string" } },8    "required": ["order_id"]9  }10}

As an OpenAPI 3.1 operation:

1openapi: 3.1.02info: { title: Orders API, version: 1.0.0 }3paths:4  /orders/{id}:5    get:6      operationId: getOrder7      summary: Fetch one order by its ID8      parameters:9        - name: id10          in: path11          required: true12          schema: { type: string }13      responses:14        "200": { description: The order }15        "404": { description: No such order }

The difference is who executes. With MCP, the host sends tools/call to the server and the server runs whatever code implements the tool, returning content (and optionally structuredContent) or a result with isError: true. With an OpenAPI-based integration, the host reads the document, turns operations into function definitions for the model, and then builds and sends the HTTP request itself.

How a model reaches a tool in each approach: the host asks an MCP server for tools, or turns an OpenAPI document into function definitions
How a model reaches a tool in each approach: the host asks an MCP server for tools, or turns an OpenAPI document into function definitions

Quick reference

  • Because the MCP server executes, it can combine calls, enforce business rules, and shape output for a model; an OpenAPI integration exposes the API as it is.
  • An OpenAPI operation's operationId and summary become the model's function name and description, so they need to be written for a model, not only for developers.
  • MCP distinguishes protocol errors (JSON-RPC errors such as an unknown tool) from tool execution errors (isError: true), which the model can read and react to.

Remember this

An MCP server runs the tool and returns content; an OpenAPI integration has the host call your HTTP API directly.

Where each fits, and where each breaks

MCP fits when the consumer is an AI host and you want one server to work across several hosts, when tools are local (a CLI that reads files, a database on your laptop) and should run as a subprocess, or when the set of tools changes at runtime. It also suits curated tools: an MCP server can expose three narrow, well-described tools over an API that has three hundred endpoints.

An OpenAPI-described API fits when the API already exists and serves non-AI clients too, when you rely on gateways, SDK generation, and contract testing, and when stateless HTTP calls are all the model needs.

Each has a characteristic failure. MCP's is trust: a server is code or a remote service whose tool descriptions and outputs enter the model's context, so a malicious or careless server can inject instructions or receive data it should not; the spec says clients must treat tool annotations as untrusted unless the server is trusted, and should keep a human in the loop for sensitive operations. OpenAPI's is shape: exposing a large, fine-grained REST API to a model directly means many tools, ambiguous names, and multi-call workflows the model must assemble correctly.

MCP and OpenAPI-described APIs compared for AI tool access
AspectMCPOpenAPI-described HTTP API
What it isRuntime protocol (JSON-RPC 2.0)Interface description document
Discoverytools/list at runtime; list_changed notificationsRead the document ahead of time
Who executesThe MCP serverThe host sends HTTP requests
Local toolsstdio subprocess, no network endpointNeeds an HTTP endpoint
Beyond toolsResources, prompt templatesFull HTTP semantics: status codes, content types
EcosystemAI hosts: Claude Code, Gemini CLI, ChatGPT, SDKsGateways, SDK generators, docs, testing tools
Breaks whenThird-party servers are trusted blindlyThe API is too broad or too chatty for a model

Quick reference

  • Neither approach handles authorisation for you; both need per-user credentials and least-privilege scopes for anything that touches user data.
  • Tool count matters to a model: dozens of similar operations make selection worse, whichever format describes them.
  • Hosts increasingly defer loading full tool schemas until needed, which reduces the context cost of large tool sets in either approach.

Remember this

Use MCP for agent-first, multi-host, or local tools; use an OpenAPI-described API when the API is the product and many clients share it.

Combining them: an MCP server over an OpenAPI API

In practice the two meet often. A team with an OpenAPI-described API builds an MCP server in front of it: each tool calls one or more API operations, and the server adds what a model needs: fewer, clearer tools, input validation, combined calls, trimmed output, and errors phrased so the model can recover.

A sketch of one such tool using the official TypeScript MCP SDK's high-level API:

1import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";2import { z } from "zod";3 4const server = new McpServer({ name: "orders", version: "1.0.0" });5 6server.registerTool(7  "get_order",8  {9    title: "Order lookup",10    description: "Fetch one order by ID. Use only for questions about a specific order.",11    inputSchema: { order_id: z.string().regex(/^ORD-\d+$/) },12  },13  async ({ order_id }) => {14    const res = await fetch(`${process.env.ORDERS_API}/orders/${order_id}`, {15      headers: { Authorization: `Bearer ${process.env.ORDERS_TOKEN}` },16    });17    if (res.status === 404) {18      return { content: [{ type: "text", text: `No order ${order_id}.` }], isError: true };19    }20    const order = await res.json();21    return { content: [{ type: "text", text: `Status: ${order.status}, total: ${order.total}` }] };22  }23);

The OpenAPI document stays the contract for the API; the MCP server is an AI-facing adapter with its own, smaller surface. Generating MCP tools directly from every OpenAPI operation is possible, but it tends to reproduce the "too many, too fine-grained" problem; curating is usually worth the effort.

When to choose MCP, when to choose an OpenAPI-described API, and when to combine them
When to choose MCP, when to choose an OpenAPI-described API, and when to combine them

Quick reference

  • Validate inputs in the server (the regex above), not only in the description; models do not reliably follow descriptions.
  • Return short, relevant text: every token of tool output enters the model's context.
  • Check the SDK's current API before copying; MCP SDK method names have changed across versions.

Remember this

Keep OpenAPI as the API's contract and put a small, curated MCP server in front of it for AI hosts.

Security in both approaches

The MCP specification's security requirements are a good checklist for either approach. Servers must validate all tool inputs, implement access controls, rate-limit invocations, and sanitise outputs. Clients should prompt for confirmation on sensitive operations, show tool inputs to the user before calling the server to avoid data exfiltration, validate results before passing them to the model, set timeouts, and log tool use for audit.

For Streamable HTTP servers the spec adds transport rules: validate the Origin header to prevent DNS-rebinding attacks, bind local servers to 127.0.0.1 rather than all interfaces, and authenticate all connections.

For OpenAPI-based integrations, the same principles apply through the API: scoped credentials per user, read-only operations exposed by default, and no operation that changes state without a confirmation step in the host. The model should never hold a credential broader than the user it acts for.

Quick reference

  • Treat tool descriptions and outputs from third-party servers as untrusted input; they can carry instructions aimed at the model.
  • Prefer servers published by the service provider over third-party aggregators that sit between you and the API.
  • Audit logs should record the tool, arguments, caller identity, and result status for every call.

Remember this

Validate inputs, scope credentials, confirm state changes, and log every call, whichever format describes the tool.

Hands-on: describe one capability both ways

  1. Pick one read-only operation from an API you own and write its OpenAPI 3.1 description with an operationId, parameters, and 200 and 404 responses.
  2. Write an MCP server with a single tool that calls that operation, validates input, and returns a short text result or isError: true.
  3. Connect the MCP server to one host (for example Claude Code with claude mcp add, or Gemini CLI with gemini mcp add) and ask a question that needs the tool.
  4. Ask a question that should not use the tool, and one with an invalid ID.
  5. Compare: how many tokens of tool definition and output did each design put in context, and which errors could the model recover from?

Pass criterion: the same capability works through both, the MCP tool refuses invalid input itself, and you can state which design you would ship for AI hosts and why.

Quick reference

  • Keep the OpenAPI document in the API's repository and the MCP server as a separate adapter.
  • If the host picks the wrong tool, rewrite the description to say when not to use it.
  • Add the operation's error codes to the MCP tool's handling so the model gets an explanation, not a stack trace.

Remember this

Writing one capability both ways shows the difference faster than any comparison table.

Key takeaway

MCP and OpenAPI sit at different layers. MCP is a runtime protocol, JSON-RPC 2.0 over stdio or Streamable HTTP, in which AI hosts discover tools with tools/list and run them with tools/call, while the server owns execution and can also offer resources and prompts. OpenAPI is a document that describes an HTTP API's operations, parameters, responses, and security schemes, used by gateways, SDK generators, and tools that turn it into function definitions for a model.

Choose MCP for agent-first, multi-host, or local tools; choose an OpenAPI-described API when the API is the product; and often combine them, with a small, curated MCP server in front of an API whose contract stays in OpenAPI. Either way, validate inputs, scope credentials, confirm state changes, and treat third-party tool descriptions as untrusted. See also Claude Code MCP and Plugins and Gemini CLI Setup.

Practice (60 min): complete the five steps above for one real operation.

Share:

References

  1. MCP specification (2025-06-18): Tools — checked Oct 17, 2026
  2. MCP specification (2025-06-18): Transports — checked Oct 17, 2026
  3. OpenAPI Specification v3.1.0 — checked Oct 17, 2026
  4. OpenAI docs: GPT Actions introduction — checked Oct 17, 2026

Shoaib Hossain

Author, Core Concept Learning

Related Articles

AI agents rarely work alone. They read files, query databases, call business APIs, and sometimes delegate work to other …

Read

The Model Context Protocol (MCP) is an open protocol for exposing tools, resources, and prompts to AI applications over …

Read

Jul 1, 2026 · 6 min read

Artificial intelligence is not here to replace .NET developers. It is here to extend what they can build. The fundamenta…

Read

Keep learning

Follow a structured path or browse all courses to go deeper.