Fixed params
Injected into every request, hidden from every schema
If the spec declares a matching parameter, the value goes in that place. Unknown keys go in the query string. Write them as key=value, a=1,b=2 or a JSON object.
TypeScript · Node 18+ · MIT · on npm
api2mcp serves any OpenAPI 3.x or Swagger 2.x spec as a local MCP server over stdio. Every operation becomes a tool. When the model calls one, the request goes to the real API with your auth injected, and the response comes back as the tool result.
Every Petstore endpoint, now a tool
npx @swayam5342/api2mcp --url https://petstore3.swagger.io/api/v3/openapi.json
findPetsByStatusGET /pet/findByStatus?status=availableNo telemetry. No database. No eval. The only network traffic is the upstream calls you configure, plus fetching the spec if you pass a URL.
Pick a Petstore operation to see the tool api2mcp registers for it. Path, query and header params become top-level fields; a JSON object body is flattened into them. A fixed param disappears from the schema and is injected into the request instead.
In the spec
Headers and fixed params are added by api2mcp, not by the model. The key is never in a tool schema, so the model can't leak it or put it somewhere it shouldn't.
Fixed params
If the spec declares a matching parameter, the value goes in that place. Unknown keys go in the query string. Write them as key=value, a=1,b=2 or a JSON object.
Redaction
Every header and fixed-param value is redacted from logs and error messages, even when the upstream echoes it back in an error body.
Arguments
Other users can see process arguments with ps. Pass secrets through your MCP client's env field instead.
Fill in your API and copy the config. The token goes in env, never in args. Restart Claude Desktop and the operations show up as tools named after their operationId.
Every setting can come from a flag, an environment variable or a config file in the working directory, in that order of precedence: flags win, then the environment, then the file.
| Flag | Env | What it does |
|---|---|---|
-u, --url | OPENAPI_URL | Spec file path or URL |
-b, --base-url | API_BASE_URL | Upstream base URL; overrides the spec's servers |
--headers | API_HEADERS | Upstream headers as a JSON object |
-f, --fixed-params | API_FIXED_PARAMS | Params injected into every request, hidden from the model |
-p, --prefix | Prefix for tool names: myapi_listPets | |
-t, --timeout | API_TIMEOUT | Upstream timeout in ms (default 30000) |
-d, --debug | DEBUG | Verbose logs to stderr, secrets redacted |
api2mcp.json (or api2mcp.config.json, .api2mcp.json)
{
"url": "https://api.example.com/openapi.json",
"baseUrl": "https://api.example.com",
"timeout": 30000,
"headers": { "Authorization": "Bearer your-token" },
"fixedParams": { "apiKey": "your-key" },
"toolPrefix": "myapi"
}
Or use it as a library
import { createServer, resolveConfig } from "@swayam5342/api2mcp";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const config = await resolveConfig({ url: "./openapi.json" });
const server = await createServer(config);
await server.connect(new StdioServerTransport());
Limits in v1: JSON request bodies only (no multipart or form-urlencoded), cookie params are ignored, and every operation is registered up front, with no on-demand mode for very large specs. For a curated server built from the same idea, see plugit.