ivo-toby/mcp-openapi-server
MCP Server (Model Context Protocol) for turning OpenAPI specifications into a MCP Resource
What it solves
Connecting a large language model (LLM) to a REST API usually requires custom glue code. This server removes that work by reading an OpenAPI specification — the standard description of REST endpoints — and exposing each endpoint as a "tool" that the AI can call through the Model Context Protocol (MCP). It also natively supports two other MCP capabilities: prompts (reusable message templates) and resources (read-only content like API docs). The result is that any OpenAPI-defined API becomes directly usable by MCP clients such as Claude Desktop or Cursor, without writing per-endpoint integration code.
How it works
The server takes a single OpenAPI spec (JSON or YAML) from one of four sources: a URL, a local file, standard input (stdin), or inline text passed as an argument. It then parses that spec and registers every API endpoint as an MCP tool the model can invoke. Communication happens over one of two transports: the default stdio transport for direct integration with desktop AI clients, or a Streamable HTTP transport with session management and server-sent events for web-based clients. Configuration is done through environment variables or command-line flags, covering things like base API URL, authentication headers, mutual TLS (mTLS) client certificates, and custom CA certificates. The server also offers flexible tool loading: you can load all endpoints, load only dynamic meta-tools (list endpoints, inspect schemas, invoke any endpoint), or load only explicitly chosen tools. Filters based on OpenAPI tags, resource path prefixes, and HTTP methods let you narrow the surface further. Additionally, you can attach short instructions to the server to tell the model things the OpenAPI spec can't express (for example, call order requirements), and load custom prompts and resources from files, URLs, or inline JSON.
Who it's for
This is for two groups. End users who work with MCP-capable AI assistants (like Claude Desktop or Cursor) can plug in any OpenAPI-defined API by editing their client's MCP configuration. Developers who build custom MCP servers can import the library and use the OpenAPIServer class inside their own Node.js applications, including setting a streamable HTTP transport for web clients. Contributors interested in the codebase can consult the included developer guide.
Highlights
- Supports tools, prompts, and resources — a full MCP server in one package
- Four ways to load an OpenAPI spec: URL, local file, stdin, or inline — both JSON and YAML
- Two transports: stdio for desktop clients, streamable HTTP with sessions and SSE for web clients
- Fine-grained tool filtering: all, dynamic meta-tools, or explicit tool IDs, plus tag/resource/operation filters
- mTLS support for upstream APIs requiring client certificates, including private CAs and encrypted keys
- Server instructions that travel with the initialize handshake to guide the model's behavior
- Health check endpoint at /health when running over HTTP
Related
- Project
- Project
- Project
- Project