
tyktechnologies/api-to-mcp 是从 https://github.com/tyktechnologies/api-to-mcp. 导入的 MCP 服务器候选
概览
tyktechnologies/api-to-mcp 是从 https://github.com/tyktechnologies/api-to-mcp. 导入的 MCP 服务器候选
概述(AI 翻译)
一个基于OpenAPI/Swagger规范创建MCP(模型上下文协议)服务器的工具,使AI助手能够与你的API交互。为特定API或服务创建你自己的品牌定制MCP。
概述
该项目创建了一个动态MCP服务器,将OpenAPI规范转化为MCP工具。它通过模型上下文协议实现REST API与AI助手的无缝集成,使任何API都成为AI可访问的工具。
特色
- 从文件或HTTP/HTTPS地址动态加载OpenAPI规范
- 支持从文件或 HTTP/HTTPS URL 加载的 OpenAPI 覆盖层
- 可自定义的 OpenAPI 操作映射到 MCP 工具
- 使用球状模式对操作Id和URL路径进行高级过滤
- 全面的参数处理,包含格式保留和位置元数据
- API 认证处理
- 用于配置MCP服务器的OpenAPI元数据(标题、版本、描述)
- 分层描述的备援(操作描述→操作摘要→路径摘要)
- 通过环境变量和CLI支持自定义HTTP头部
- 用于 API 请求跟踪和识别的 X-MCP 头
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
OpenAPI to MCP Server
A tool that creates MCP (Model Context Protocol) servers from OpenAPI/Swagger specifications, enabling AI assistants to interact with your APIs. Create your own branded and customized MCPs for specific APIs or services.
Overview
This project creates a dynamic MCP server that transforms OpenAPI specifications into MCP tools. It enables seamless integration of REST APIs with AI assistants via the Model Context Protocol, turning any API into an AI-accessible tool.
Features
- Dynamic loading of OpenAPI specs from file or HTTP/HTTPS URLs
- Support for OpenAPI Overlays loaded from files or HTTP/HTTPS URLs
- Customizable mapping of OpenAPI operations to MCP tools
- Advanced filtering of operations using glob patterns for both operationId and URL paths
- Comprehensive parameter handling with format preservation and location metadata
- API authentication handling
- OpenAPI metadata (title, version, description) used to configure the MCP server
- Hierarchical description fallbacks (operation description → operation summary → path summary)
- Custom HTTP headers support via environment variables and CLI
- X-MCP header for API request tracking and identification
- Support for custom
x-mcpextensions at the path level to override tool names and descriptions
Using with AI Assistants
This tool creates an MCP server that allows AI assistants to interact with APIs defined by OpenAPI specifications. The primary way to use it is by configuring your AI assistant to run it directly as an MCP tool.
Setting Up in Claude Desktop
-
Ensure you have Node.js installed on your computer
-
Open Claude Desktop and navigate to Settings > Developer
-
Edit the configuration file (or it will be created if it doesn’t exist):
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add this configuration (customize as needed):
{
"mcpServers": {
"api-tools": {
"command": "npx",
"args": [
"-y",
"@tyk-technologies/api-to-mcp@latest",
"--spec",
"https://petstore3.swagger.io/api/v3/openapi.json"
],
"enabled": true
}
}
}
- Restart Claude Desktop
- You should now see a hammer icon in the chat input box. Click it to access your API tools.
Customizing the Configuration
You can adjust the args array to customize your MCP server with various options:
{
"mcpServers": {
"my-api": {
"command": "npx",
"args": [
"-y",
"@tyk-technologies/api-to-mcp@latest",
"--spec",
"./path/to/your/openapi.json",
"--overlays",
"./path/to/overlay.json,https://example.com/api/overlay.json",
"--whitelist",
"getPet*,POST:/users/*",
"--targetUrl",
"https://api.example.com"
],
安装
npx -y @tyk-technologies/api-to-mcp@latest --spec https://petstore3.swagger.io/api/v3/openapi.json配置
{
"mcpServers": {
"api-tools": {
"command": "npx",
"args": [
"-y",
"@tyk-technologies/api-to-mcp@latest",
"--spec",
"https://petstore3.swagger.io/api/v3/openapi.json"
],
"enabled": true
}
}
}