MCP Server
AI agents such as Claude and Cursor call APIs through tools served over the Model Context Protocol (MCP). RapiDoc turns your OpenAPI spec into an MCP server, and curates it on the way, because exposing every endpoint one-to-one works poorly for agents: internal endpoints leak, transport headers become tool arguments the model has to guess, and every extra tool costs context on every turn.
RapiDoc reads your plain OpenAPI spec, leaves out internal and deprecated operations, and strips transport and credential headers from tool arguments. The result is an MCP manifest: plain JSON with one tool per operation, real JSON Schema arguments and MCP safety annotations. It ships in a small TypeScript project you can run as-is.
You can create it three ways:
- In the browser: the Export MCP Server button of
<rapi-doc>(or its JavaScript methods), described with RapiDoc. Nothing is sent to a server. - On the command line:
rapidoc mcp exportandrapidoc mcp serve(@rapidoc/cli). - In Node:
@rapidoc/mcp, for build scripts and your own servers.
The MCP Server example shows the manifest, server and runtime for a real OpenAPI spec.
The export runs in the browser and sends nothing anywhere. You unzip and install the project on your machine, and your AI app starts it as a child process that talks over stdin and stdout, on no port.
How operations become tools
Section titled “How operations become tools”No extra annotations are needed. Every tool comes from standard OpenAPI fields:
- Tool names: The tool name is the snake_case form of the
operationId(placeOrderbecomesplace_order). Operations without anoperationId, or with one that has no Latin letter or digit, get a name derived from the HTTP method and path (GET /orders/{id}becomesget_orders_by_id). Names are at most 64 characters, the limit of MCP hosts: a longer one is cut and ends in a short hash of the whole name. When two operations would get the same name, each ends in a short hash of its own method and path (same_1a2b3c4d), so a tool keeps its name when the spec is reordered or another operation is added. - Tool descriptions: The operation
summaryis used, else itsdescription, elseMETHOD /path. HTML and Markdown are stripped and the text is truncated to 300 characters. - Left out: Operations marked
x-internal: trueorx-hidden: true, operations markeddeprecated: true, and webhooks are left out. - Headers: Headers like
Authorization,Cookie,X-Api-Key,Accept,User-Agentand other transport metadata are stripped from LLM tool arguments, as is any parameter that carries an API key named in the spec’ssecuritySchemes. A secret passed in a parameter the spec does not declare as a security scheme stays an argument, so declare it. The runtime applies the right scheme itself, from environment variables. - Base URL: The base URL is
servers[0](Swagger 2.0:schemes,hostandbasePath). The exported server runs outside the documentation page, so it needs a full URL. A relative one such as/api/v1, or a spec withoutservers, is resolved against the address the spec was loaded from (rapidoc mcp export https://example.com/openapi.yaml; in the browser, the page’s address). A spec read from a file has no such address: the manifest then has no base URL, the export says so, and you setMCP_BASE_URL, which also overrides a full URL. A tool call without a base URL answers with an error that names the variable; it is never sent tolocalhost. - Resources: Every operation is a tool,
GETincluded, with all its parameters. To also offer aGETwith no required parameters as an MCP resource, setx-mcp-resource: trueon it. It stays a tool as well, because many hosts leave resources for the user to attach and do not let the agent read them. Its URI isreference://and the tool name withoutget_, with dashes (getCurrenciesbecomesreference://currencies). - Safety annotations: Every tool carries MCP annotations:
readOnlyHintforGETonly,idempotentHintforGET,PUTandDELETE, anddestructiveHint:trueforPUT,PATCHandDELETE,falseforGET, and left out forPOST, which may add (POST /orders) or undo (POST /orders/{id}/cancel). Without the hint, hosts assume a tool may be destructive. Hosts use the annotations to ask the user before running a consequential tool; they are hints, not enforcement. - Token budget: RapiDoc estimates how many tokens the tool list adds to every turn, and warns above 30 tools or 5,000 tokens.
Example
Section titled “Example”Here is a plain OpenAPI 3.x snippet and how each operation is treated:
openapi: 3.0.3info: title: Commerce Fulfillment API version: 2.4.0servers: - url: https://api.example.com/v2 # Base URL in the manifestsecurity: - api_key: [] # Applied by the runtime from MCP_AUTH_API_KEY
paths: # 1. Tool "place_order" (POST: readOnlyHint false, no destructiveHint) /orders: post: summary: Place a new order operationId: placeOrder parameters: - name: Authorization # Stripped: never a tool argument in: header schema: { type: string } requestBody: required: true content: application/json: schema: type: object required: [customerId, items] properties: customerId: { type: string } items: { type: array, items: { type: string } } shippingMethod: { type: string, enum: [standard, express, overnight] }
# 2. Read-only tool "get_order" /orders/{orderId}: get: summary: Get an order operationId: getOrder parameters: - name: orderId in: path required: true schema: { type: string }
# 3. Read-only tool "get_currencies", and MCP resource "reference://currencies" (opt-in) /currencies: get: summary: List supported currencies operationId: getCurrencies x-mcp-resource: true
# 4. Excluded: internal endpoint /admin/database/vacuum: post: summary: Trigger internal database maintenance x-internal: true
# 5. Excluded: deprecated endpoint /orders/legacy: get: summary: Legacy order list deprecated: true
components: securitySchemes: api_key: type: apiKey in: header name: X-API-KeyThe Manifest
Section titled “The Manifest”The export is data, not generated code. manifest.json describes the whole server. Swagger 2.0 specs work too: type: basic in securityDefinitions is HTTP Basic, and formData parameters become the fields of a form body.
server:name(snake_case of themcp-server-nameattribute or the API title),versionanddescriptionfrominfo.sources: the API, namedapi, with thebaseUrlfromservers[0](server variables filled with their defaults; left out when the spec names no full URL) and the OpenAPI spec’ssecuritySchemescopied as they are. An Arazzo spec can add more sources.manifestVersion:1. The runtime refuses a manifest of a version it does not know, with a message that says so.tools: one per operation that survives the exclusions above.resources: the operations markedx-mcp-resource: true, with areference://URI.workflows: one entry per Arazzo workflow when an Arazzo spec is given (see Workflows as tools); otherwise empty.
Each tool has a name, a description, an inputSchema, MCP annotations and an operation block that tells the runtime how to make the HTTP call. The inputSchema is real JSON Schema: path, query, header and cookie parameters become properties by name, and the request body becomes a body property holding the full body schema, with nested objects, arrays, enums and required intact. $refs are inlined, cycles are cut, and read-only properties are dropped because they never go in a request.
The place_order tool from the example above:
{ "name": "place_order", "description": "Place a new order", "inputSchema": { "type": "object", "properties": { "body": { "type": "object", "required": ["customerId", "items"], "properties": { "customerId": { "type": "string" }, "items": { "type": "array", "items": { "type": "string" } }, "shippingMethod": { "type": "string", "enum": ["standard", "express", "overnight"] } } } }, "required": ["body"] }, "annotations": { "readOnlyHint": false, "idempotentHint": false }, "operation": { "source": "api", "method": "POST", "path": "/orders", "params": [{ "name": "body", "in": "body", "contentType": "application/json" }], "security": [{ "api_key": [] }] }}operation.params records where each argument goes (path, query, header, cookie or body), and operation.security is the operation’s security requirement, else the OpenAPI spec’s. Only a TypeScript server is exported today. Because the manifest holds everything a server needs, a server in another language would only have to read the same manifest.json; nothing would need to be regenerated.
Export and run the server: the runtime, the exported project, creating it from <rapi-doc>, the command line or Node, and connecting an AI app.