@kaisers-io/openapi-mcp
v0.12.2
Published
Turn any OpenAPI spec into a strict, locally running MCP server
Maintainers
Readme
openapi-mcp
openapi-mcp gives an AI agent safe access to an HTTP API. You point it at the API's OpenAPI
3.0, 3.1 or 3.2 description, from a URL or a file, and it runs on your machine as an
MCP server: each operation you allow becomes a tool that
agents in Claude Code, Codex and other MCP hosts can call. There is no code to generate and
nothing to deploy.
Without any configuration, the agent can only read (GET, HEAD and QUERY operations),
credentials come only from environment variables, every call is checked against the
operation's schema, and a changed API description waits for your approval before the server
uses it.
The agent also spends few tokens on the API. With many operations, --tool-mode discover lists
a few fixed tools instead of one per operation, and execute_code combines many calls in one
program that returns only the result. For six tasks on GitHub's API, one agent spent 2.7 cents
per task this way and 23.5 cents with one tool per operation
(measurements).
Only use a description you trust. Its operation names and texts reach the model, and a hostile description can try to steer the agent.
Requirements: Node.js 22.19 or later, or 24.11 or later (Node 23 is not supported), on
macOS, Linux or Windows. Use the latest patch release of your Node line, because older patches miss
its security fixes. On Windows the cache directories are private through your user profile's access
control list (owner, SYSTEM, Administrators), not through 0700/0600 modes. Other platforms, such
as FreeBSD, are refused because they are untested, not because they are known to be unsafe.
Set it up with your agent
Two agent skills ask what the agent should do with the API, show which operations it may use, store the credentials safely, write the host config after you confirm, and check that the server works:
npx skills add kaisers-io/openapi-mcpThe command finds both skills, configuring-openapi-mcp and debugging-openapi-mcp, and asks
which ones to install and for which agents.
Set it up by hand
Preview the tools, without starting a server:
npx -y @kaisers-io/[email protected] tools --spec https://api.example.com/openapi.jsonClaude Code (.mcp.json, which expands ${VAR}):
{
"mcpServers": {
"shop": {
"command": "npx",
"args": [
"-y",
"@kaisers-io/[email protected]",
"serve",
"--spec",
"https://api.example.com/openapi.json",
"--base-url",
"https://api.example.com",
"--header-env",
"Authorization=SHOP_TOKEN"
],
"env": { "SHOP_TOKEN": "${SHOP_TOKEN}" }
}
}
}Codex (~/.codex/config.toml). Codex does not expand ${VAR}; it forwards the variables named
in env_vars from the environment you start it in:
[mcp_servers.shop]
command = "npx"
args = [
"-y", "@kaisers-io/[email protected]", "serve",
"--spec", "https://api.example.com/openapi.json", "--base-url", "https://api.example.com",
"--header-env", "Authorization=SHOP_TOKEN",
]
env_vars = ["SHOP_TOKEN"]--header-env sends the variable's value unchanged, so for a bearer token the variable holds
Bearer followed by the token. With a spec from a URL, --base-url is required next to
--header-env, so the spec cannot choose where the token goes. Run the same arguments with
check instead of serve to see whether the server would start.
On Windows, a host that starts commands without a shell cannot run npx, which is a .cmd
script. Use "command": "cmd" with "args": ["/d", "/c", "npx", "-y", ...] there, keep
& | < > ^ % out of the arguments, and double the backslashes in JSON paths
("C:\\specs\\shop.json").
Pin an exact version, as above, and never latest: the server runs with your API credentials
every time the host starts it. Without --trust-spec-updates, a description fetched with
--spec-header-env also needs --cache-key.
Choose what the agent may do
--allow and --deny take selectors, matched regardless of case: method:delete,
path:/users/**, route:GET /users/**, operationId:list*, name:get_users_by_id and
tag:<glob>. --deny always wins, and any --allow replaces the read-only default. A tool's
name is the operationId reduced to [A-Za-z0-9_-] (at most 64 characters), or method and path
when there is no usable operationId (get_users_by_id).
Learn more
- Connecting a host: every host, Windows, HTTP clients.
- Credentials and the security model.
- Filtering.
- Large APIs and tool modes:
--tool-mode discoverlists a few tools instead of one per operation, among themexecute_code, which runs a short program over several read-only calls. - Spec updates and the cache:
openapi-mcp cache promoteaccepts a changed description. - Serving over HTTP.
- Configuration reference:
every flag and default, also in
openapi-mcp <command> --help.
License
MIT
