api2mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@api2mcplist pets from the petstore"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@swayam5342/api2mcp
Serve any OpenAPI 3.x / Swagger 2.x API as a local MCP (Model Context Protocol) server over stdio. Every operation in the spec becomes an MCP tool; when a tool is called, the request is proxied to the real upstream HTTP API with your configured auth.
It does exactly two things:
Serve — given a spec (file path or URL), run an MCP server on stdio so Claude Desktop, Claude Code, and other MCP clients can launch it as a subprocess. One spec → one server.
Proxy — forward tool calls to the upstream API using the method/path/params from the spec, injecting your configured headers and fixed params, and return the response.
No telemetry, no database, no eval. The only network egress is the upstream calls you configure (plus fetching the spec itself if you pass a URL).
Quick start
npx @swayam5342/api2mcp --url https://petstore3.swagger.io/api/v3/openapi.jsonThat's a running MCP server on stdio — every Petstore endpoint is now a tool. Point an MCP client at it (see below) and ask it to list pets.
Related MCP server: OpenAPI to MCP Server
Install
# no install needed
npx @swayam5342/api2mcp --url ./openapi.json
# or globally
npm install -g @swayam5342/api2mcp
api2mcp --url ./openapi.jsonRequires Node.js >= 18.
Use with Claude Desktop
Add to your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"petstore": {
"command": "npx",
"args": [
"-y",
"@swayam5342/api2mcp",
"--url",
"https://petstore3.swagger.io/api/v3/openapi.json"
]
}
}
}Restart Claude Desktop; the spec's operations appear as tools named after their operationId (e.g. addPet, getPetById).
CLI reference
api2mcp --url <spec> [options]Flag | Short | Description |
|
| OpenAPI/Swagger spec — file path or URL |
|
| Upstream base URL (overrides the spec's |
| — | Upstream headers as a JSON object string |
|
| Prefix for generated tool names ( |
|
| Upstream request timeout in ms (default 30000) |
|
| Params injected into every upstream request, hidden from the LLM ( |
|
| Verbose logging to stderr (secrets redacted) |
--headers intentionally has no short flag: -h shows help.
Configuration
Every flag can also come from environment variables or a config file. Precedence: CLI flags > environment variables > config file.
Environment variables
Variable | Meaning |
| Spec file path or URL |
| Upstream base URL |
| Timeout in ms |
| Headers as a JSON object string |
| Fixed params ( |
| Debug logging ( |
Config file
The first of api2mcp.json, api2mcp.config.json, .api2mcp.json found in the working directory is used:
{
"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"
}Passing secrets safely
Don't put API keys in --headers or --fixed-params on the command line — process arguments are visible to other users on the machine (ps). Use your MCP client's env field instead:
{
"mcpServers": {
"my-api": {
"command": "npx",
"args": ["-y", "@swayam5342/api2mcp", "--url", "https://api.example.com/openapi.json"],
"env": {
"API_HEADERS": "{\"Authorization\":\"Bearer YOUR_TOKEN\"}",
"API_FIXED_PARAMS": "apiKey=YOUR_KEY"
}
}
}
}All header and fixed-param values are redacted (***) from every log line and error message, including upstream error bodies that echo them back.
Fixed params: auth the LLM never sees
Fixed params are injected into every upstream request but are stripped from the tool schemas, so the model never sees the key and cannot leak or misuse it:
API_FIXED_PARAMS="apiKey=YOUR_KEY" npx @swayam5342/api2mcp --url ./openapi.jsonIf the spec declares a matching parameter (query, or a body property), the value is injected in that declared location.
Unknown keys are sent as query parameters.
Accepts
key=value, comma-separateda=1,b=2, or a JSON object string.
How operations become tools
Spec | Tool |
| tool |
no operationId, | tool |
| tool description (fallback: |
path/query/header params | top-level input fields, required per the spec |
JSON request body (object) | properties flattened into top-level input fields |
JSON request body (non-object) | single |
v1 limitations: JSON request bodies only (no multipart/form-urlencoded), cookie params ignored, and every operation is registered directly (no on-demand mode for very large specs).
Worked example: Petstore
npx @swayam5342/api2mcp --url https://petstore3.swagger.io/api/v3/openapi.json --prefix pets --debugstderr shows the redacted config and registered N tools ..., then the server waits on stdio. In Claude Desktop:
{
"mcpServers": {
"petstore": {
"command": "npx",
"args": [
"-y",
"@swayam5342/api2mcp",
"--url", "https://petstore3.swagger.io/api/v3/openapi.json",
"--prefix", "pets"
]
}
}
}Then ask Claude: "Find available pets in the store" — it calls pets_findPetsByStatus with status: "available", the call is proxied to https://petstore3.swagger.io/api/v3/pet/findByStatus?status=available, and the JSON response comes back as the tool result.
Library API
import { createServer, resolveConfig } from "@swayam5342/api2mcp";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const config = await resolveConfig({ url: "./openapi.json" }); // merges env + config file
const server = await createServer(config); // an SDK McpServer, tools registered
await server.connect(new StdioServerTransport()); // or any other transportExports: createServer(config, options?), resolveConfig(cliFlags, options?), and the types Api2McpConfig, CreateServerOptions. options.fetchImpl lets you swap the HTTP layer (e.g. for tests).
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
Alicense-qualityCmaintenanceEnables conversion of OpenAPI specifications into MCP servers and remixing multiple MCP servers into one. Works with stdio and sse transports and integrates with major chat clients.Last updated304MIT- Alicense-qualityDmaintenanceConverts any OpenAPI/Swagger spec into an MCP server, exposing REST API endpoints as tools for Claude.Last updatedMIT
- Alicense-qualityDmaintenanceRuntime MCP server that dynamically bridges any OpenAPI 3.x spec to MCP tools.Last updated2MIT
- Alicense-qualityBmaintenanceTurns any OpenAPI/Swagger spec into an MCP server, generating one tool per endpoint with zero code.Last updated10MIT
Related MCP Connectors
The official MCP Server from Mia-Platform to interact with Mia-Platform Console
MCP Spec Compliance MCP — audits any MCP server.json against the official Model Context Protocol
A basic MCP server to operate on the Postman API.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/swayam5342/api2mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server