MCPify
A dynamic proxy that converts OpenAPI Specification (OAS) endpoints into Message Communication Protocol (MCP) tools, allowing AI agents to use existing REST APIs as if they were native MCP tools without manual implementation.
README
🔄 MCPify
🛠️ A dynamic proxy that converts OpenAPI Specification (OAS) endpoints into Message Communication Protocol (MCP) tools on the fly.
🌟 Overview
MCPify enables seamless integration between REST APIs and AI agents by dynamically translating OpenAPI endpoints into MCP tools. Unlike static code generators, MCPify creates a live proxy server that:
- Parses OpenAPI specs from local files or URLs
- Dynamically maps REST endpoints to MCP tools with appropriate schemas
- Proxies requests between the MCP client and the underlying REST API
- Handles conversions between MCP and REST formats in real-time
This allows AI agents to use existing REST APIs as if they were native MCP tools without any manual implementation required.
✨ Features
| Status | Feature |
|---|---|
| 🟢 | 📄 Parse OpenAPI 3.0+ Specification documents (JSON or YAML) |
| 🟢 | 🔄 Convert REST endpoints to MCP tools with appropriate schemas |
| 🟢 | 📎 Map HTTP methods to appropriate MCP tool annotations |
| 🟢 | 🔌 Proxy requests between MCP clients and REST APIs |
| 🟡 | 🔍 Generate RESTful MCP resources from OpenAPI endpoints |
| 🟡 | 🔐 Support for authentication methods defined in the OAS |
| 🟠 | 📢 Handle binary response types (images, files, etc.) |
| 🟠 | ⏰ Support for webhooks and asynchronous operations |
🚀 Usage
# Start a proxy server using a local OpenAPI specification
npx mcpify --spec api-spec.yaml --base-url https://api.example.com
# Start a proxy server using a remote OpenAPI specification
npx mcpify --spec https://api.example.com/openapi.json
# Specify MCP server port (default: 8080)
npx mcpify --spec api-spec.yaml --port 9000
# Enable debug logging for request/response inspection
npx mcpify --spec api-spec.yaml --log-level debug
[!NOTE]
🚧
npx mcpifywill work once this package is published, which will happen imminently.
Example output:
[INFO] Loading OpenAPI specification from api-spec.yaml
[INFO] Validating OpenAPI document
[INFO] Found 8 endpoints to convert
[INFO] Converting GET /users → query tool "listUsers"
[INFO] Converting GET /users/{id} → query tool "getUserById"
[INFO] Converting POST /users → mutation tool "createUser"
[INFO] Converting PUT /users/{id} → mutation tool "updateUser"
[INFO] Converting DELETE /users/{id} → mutation tool "deleteUser"
[INFO] Converting GET /products → query tool "listProducts"
[INFO] Converting GET /products/{id} → query tool "getProductById"
[INFO] Converting POST /orders → mutation tool "createOrder"
[INFO] MCP proxy server started at http://localhost:8080
[INFO] MCP debugging interface available at http://localhost:8080/debug
🖼 Architecture
MCPify follows a real-time proxy architecture:
- Parser 📄: Loads and validates the OpenAPI specification
- Mapper 🗺️: Converts API endpoints to MCP tools and resources dynamically
- Proxy 🔄: Routes MCP tool calls to the appropriate REST endpoints
- Server 🔌: Exposes the MCP interface to clients
🔄 Conversion Rules
🔄 OpenAPI to MCP Mapping
| Status | OpenAPI Element | MCP Element | Conversion Notes |
|---|---|---|---|
| 🟢 | operationId |
Tool name |
Falls back to path+method if not specified |
| 🟢 | summary+description |
Tool description |
Combined with configurable formatting |
| 🟢 | Parameters + request body | Tool inputSchema |
Converted to JSON Schema |
| 🟢 | deprecated flag |
annotations.deprecated |
Direct mapping |
| 🟢 | HTTP method | Tool annotations | Maps to readOnlyHint, destructiveHint, etc. |
| 🟡 | tags |
annotations.tags |
Used for categorization |
| 🟡 | responses schemas |
Tool result handling | For typed result processing |
| 🟠 | security |
Authentication | Security scheme mapping |
| 🟠 | examples |
Usage examples | Added to tool descriptions |
| 🔴 | Related endpoints | annotations.relatedTools |
For complex workflows |
🔎 HTTP Method Mappings
| HTTP Method | Tool Annotations | Semantic Meaning |
|---|---|---|
| GET | {"readOnlyHint": true} |
Non-destructive query operation |
| POST | {"readOnlyHint": false, "destructiveHint": false} |
Creation operation |
| PUT | {"readOnlyHint": false, "destructiveHint": true, "idempotentHint": true} |
Idempotent update |
| PATCH | {"readOnlyHint": false, "destructiveHint": true} |
Partial update |
| DELETE | {"readOnlyHint": false, "destructiveHint": true} |
Resource deletion |
📂 Resource Generation
Endpoints are automatically converted to MCP resources when:
- The endpoint is a GET operation
- And either:
- Has no parameters, or
- Has only path parameters (for resource templates)
📐 Schema Compatibility
[!IMPORTANT] MCPify handles the differences between OpenAPI schemas and MCP's JSON Schema requirements.
🔧 Schema Differences
| OpenAPI Schema | MCP Schema | Handling Strategy |
|---|---|---|
| Uses JSON Schema subset | Uses standard JSON Schema | Convert and validate |
| Has OpenAPI extensions | No extensions | Remove or map appropriately |
Relies on $ref |
Requires inline schemas | Resolve all references |
Has nullable (OAS 3.0) |
Uses type: ["null", ...] |
Convert format |
[!TIP]
The easiest way to deal with the differences in OpenAPI Schema is to stick to the version of JSON Schema supported by OpenAPI 3.1. That minimizes the need for automatic conversions, which rely on heuristics.
[!IMPORTANT]
If you don't like the automatic conversions, you can use the
x-mcpifyextension to provide your own schema.
🔢 Type Mappings
| OpenAPI Type | Format | MCP JSON Schema Type | Format |
|---|---|---|---|
string |
various | string |
preserved |
integer |
int32/int64 |
integer |
normalized |
number |
float/double |
number |
normalized |
boolean |
n/a | boolean |
preserved |
array |
n/a | array |
preserved |
object |
n/a | object |
preserved |
⚙️ Configuration
📝 Using x-mcpify Extensions and Proxy Configuration
Configure custom behavior using the x-mcpify extension at different levels in your OpenAPI spec:
- Root level - Global configuration
- Path level - Endpoint-specific settings
- Operation level - Fine-grained control
# Root level configuration
x-mcpify:
templates:
default:
description: "{summary} ({description})"
proxy:
timeout: 30 # Request timeout in seconds
retries: 3 # Number of retry attempts
caching:
enabled: true
ttl: 300 # Cache TTL in seconds
# Path level configuration
paths:
/users:
x-mcpify:
include: [tools, resources]
proxy:
timeout: 60 # Override timeout for this path
# Operation level configuration
/users/{id}:
get:
x-mcpify:
operationId: "user_by_id" # Override name
annotations: # Custom annotations
readOnlyHint: false # Override default
proxy:
caching: # Operation-specific cache settings
ttl: 600
Alternatively, you can provide proxy-specific configuration via command-line flags:
# Configure proxy timeout and retries
mcpify --spec api-spec.yaml --timeout 60 --retries 3
# Enable response caching
mcpify --spec api-spec.yaml --cache-ttl 300
# Set custom headers for all proxied requests
mcpify --spec api-spec.yaml --header "User-Agent: MCPify/1.0" --header "X-Custom: Value"
🚫 Opting Out
Disable automatic conversion for specific endpoints:
paths:
/internal/metrics:
get:
x-mcpify: false # Disable completely
/users/{id}:
get:
x-mcpify:
map: ["tool"] # Only create tool, not resource
📚 Examples
📈 Basic Endpoint Conversion
OpenAPI Input:
paths:
/users/{id}:
get:
operationId: getUserById
summary: Get user by ID
description: Retrieves a user by their unique identifier
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
200:
description: User found
content:
application/json:
schema:
$ref: "#/components/schemas/User"
Dynamically Generated MCP Tool:
{
"name": "getUserById",
"description": "Get user by ID - Retrieves a user by their unique identifier",
"inputSchema": {
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "string",
"description": "User's unique identifier"
}
}
},
"annotations": {
"readOnlyHint": true,
"sourceEndpoint": "/users/{id}"
}
}
🔒 Complex Scenario: Authentication
OpenAPI Input with Security:
security:
- apiKey: []
securitySchemes:
apiKey:
type: apiKey
in: header
name: X-API-Key
paths:
/secure/resource:
get:
operationId: getSecureResource
summary: Get a secure resource
Dynamically Generated MCP Tool with Auth:
{
"name": "getSecureResource",
"description": "Get a secure resource - Requires API Key authentication",
"inputSchema": {
"type": "object",
"required": ["apiKey"],
"properties": {
"apiKey": {
"type": "string",
"description": "API Key for authentication"
}
}
},
"annotations": {
"readOnlyHint": true,
"authentication": {
"type": "apiKey",
"location": "header",
"name": "X-API-Key"
}
}
}
🔄 MCP Proxy Features
Dynamic Request Handling
MCPify intelligently converts between MCP tool calls and REST API requests:
-
Request Transformation: Converts MCP tool arguments to appropriate query parameters, path parameters, headers, and request bodies based on the OpenAPI spec
-
Response Transformation: Converts REST API responses back to MCP tool results with proper content formatting
-
Error Handling: Maps HTTP error codes to meaningful MCP error responses with appropriate status codes and error messages
-
Authentication Forwarding: Securely forwards authentication tokens from MCP clients to the underlying REST API
Debugging and Monitoring
MCPify includes a web-based debugging interface at /debug that provides:
- Real-time request/response logging
- Tool mapping visualization
- Performance metrics for proxied requests
- Schema conversion inspection
🧩 Integration with AI Agents
MCPify makes it easy to connect existing REST APIs to AI agents that support the MCP protocol, effectively turning any API into a tool the agent can use:
# Start MCPify proxy to convert Stripe API to MCP
mcpify --spec https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json \
--header "Authorization: Bearer sk_test_123" \
--port 8080
# Connect your AI agent to the MCP proxy
ai-agent --mcp-server http://localhost:8080
Now your AI agent can directly use Stripe API endpoints as MCP tools without any additional implementation.
👥 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📜 License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。