Openapi2mcp
@oil-oil
关于 Openapi2mcp
OpenAPI2MCP (Model Context Protocol) that allows AI clients to call any OpenAPI-compatible REST API through the MCP interface. This tool converts OpenAPI specifications into MCP tools, enabling AI clients to interact with external APIs seamlessly.
基本信息
配置
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"petstore": {
"command": "npx",
"args": [
"-y",
"openapi2mcp"
],
"env": {
"TRANSPORT_TYPE": "stdio",
"API_BASE_URL": "https://petstore3.swagger.io/api/v3",
"OPENAPI_SPEC_URL": "https://petstore3.swagger.io/api/v3/openapi.json",
"HEADERS": "{\"Authorization\":\"Bearer your-token\",\"Content-Type\":\"application/json\"}"
}
}
}
}工具
19Add a new pet to the store.
Update an existing pet. - Update an existing pet by Id.
Finds Pets by status. - Multiple status values can be provided with comma separated strings.
Finds Pets by tags. - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
Find pet by ID. - Returns a single pet.
Updates a pet in the store with form data. - Updates a pet resource based on the form data.
Deletes a pet. - Delete a pet.
Uploads an image. - Upload image of the pet.
Returns pet inventories by status. - Returns a map of status codes to quantities.
Place an order for a pet. - Place a new order in the store.
Find purchase order by ID. - For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
Delete purchase order by identifier. - For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
Create user. - This can only be done by the logged in user.
Creates list of users with given input array.
Logs user into the system. - Log into the system.
Logs out current logged in user session. - Log user out of the system.
Get user by user name. - Get user detail based on username.
Update user resource. - This can only be done by the logged in user.
Delete user resource. - This can only be done by the logged in user.
概览
What is Openapi2mcp?
Openapi2mcp is a tool that converts any OpenAPI 2.0/3.0 compatible REST API into MCP tools, allowing AI clients to call REST APIs seamlessly through the MCP interface. It is designed for developers and AI users who want to enable AI clients (e.g., Claude Desktop, Cursor, Cline) to interact with external APIs.
How to use Openapi2mcp?
Install and build from source using Node.js 18+ and pnpm, then configure an MCP client with STDIO or SSE mode. For STDIO, set environment variables such as TRANSPORT_TYPE, API_BASE_URL, OPENAPI_SPEC_URL, and optional headers/authentication. For SSE, start the SSE server and connect via a URL with parameters. Test by asking the AI client to perform API operations like finding pets by status.
Key features of Openapi2mcp
- Works with any OpenAPI 2.0/3.0 REST API
- Supports STDIO, HTTP, and SSE transport modes
- Flexible authentication via API keys, Bearer tokens, and custom headers
- Smart API merging reduces tool count for clients with limits
- Efficient caching of OpenAPI specs to boost performance
Use cases of Openapi2mcp
- Connect AI assistants to pet store or similar REST APIs for CRUD operations
- Enable Cursor or Claude Desktop to interact with third-party APIs via natural language
- Reduce tool count for MCP clients with tool limits by merging related endpoints
- Deploy a lightweight MCP server that exposes any OpenAPI service to AI clients
FAQ from Openapi2mcp
What are the prerequisites for using Openapi2mcp?
Node.js 18+ and pnpm are required, along with an OpenAPI specification and API credentials if needed. An MCP-compatible client such as Claude Desktop, Cursor, or Cline is also required.
How does API merging work in Openapi2mcp?
The tool groups endpoints by resource path and combines them into unified tools, reducing the total tool count while preserving functionality. For example, separate GET/POST/PUT/DELETE endpoints for /pet become a single pet_operations tool with an object-based parameter structure.
Where does the OpenAPI specification data come from?
The specification can be fetched from a URL (set via OPENAPI_SPEC_URL) or read from a local file path (set via OPENAPI_SPEC_PATH). The base URL is either specified in API_BASE_URL or taken from the spec’s servers field.
What authentication methods are supported?
Authentication is supported via API keys (HEADER.X-API-Key), Bearer tokens (HEADER.Authorization), and custom headers using either the HEADER.* format or a legacy JSON HEADERS variable.
Are there any limits on the number of MCP tools?
Some AI clients have tool count limits; Openapi2mcp provides an optional API merging feature (MERGE_API=true) to combine related endpoints into fewer, unified tools, helping clients with these constraints.
其他 分类下的更多 MCP 服务器
Servers
modelcontextprotocolModel Context Protocol Servers
🪟 Windows-MCP
CursorTouchMCP Server for Computer Use in Windows
MCP Toolbox for Databases
googleapisMCP Toolbox for Databases is an open source MCP server for databases.
XcodeBuildMCP
cameroncookeA Model Context Protocol (MCP) server and CLI that provides tools for agent use when working on iOS and macOS projects.
Inbox Zero AI MCP
elie222The world's best AI personal assistant for email. Open source app to help you reach inbox zero fast.
评论