OpenAPI to MCP Server
这是一个基于FastMCP的OpenAPI转换服务器,提供了以下功能:
- OpenAPI规范解析
- 自动生成MCP工具
- API调用封装
MCP 配置
本项目支持通过多种客户端配置 MCP 服务器,以便与各种 IDE 或工具集成。以下是一些常见客户端的配置示例:
Windsurf / Cursor / Claude
对于基于 Windsurf 框架的客户端(如 Cursor 和 Claude),您可以在 ~/.codeium/windsurf/mcp_config.json 文件中配置 MCP 服务器。以下是一个示例配置:
{
"mcpServers": {
"openapi2mcpserver": {
"disabled": false,
"command": "uvx",
"args": [
"openapi2mcpserver"
],
"env": {
"BASE_URL": "your_openapi3.0_host",
"OPEN_API_DOC_JSON_URL": "your_openapi3.0_host doc json url"
}
}
}
}
请将 BASE_URL, OPEN_API_DOC_JSON_URL 替换为您的实际 OpenAPI 服务器地址和文档 JSON URL。
Cline
对于 Cline 客户端,您可以在其配置文件中添加类似的 MCP 服务器配置。具体的配置方式请参考 Cline 的官方文档。通常,您需要指定服务器的名称、命令、参数和环境变量。
// Cline 配置文件示例 (具体格式请参考 Cline 文档)
{
"mcpServers": {
"openapi2mcpserver": {
"command": "uvx",
"args": [
"openapi2mcpserver"
],
"env": {
"BASE_URL": "your_openapi3.0_host",
"OPEN_API_DOC_JSON_URL": "your_openapi3.0_host doc json url"
}
}
}
}
请将示例中的占位符替换为您的实际 OpenAPI 服务器地址和文档 JSON URL,并根据 Cline 的具体配置格式进行调整。
安装
- 克隆仓库
- 安装依赖:
pip install -r requirements.txt - 配置环境变量(参见下文)
配置
在项目根目录创建.env文件,包含以下环境变量:
BASE_URL=https://api.xxx.com
OPEN_API_DOC_JSON_URL=https://api.xxx.com/api/v3/api-docs/default
运行
使用uvx安装并运行(推荐)
uvx --from openapi2mcpserver
功能
测试
测试
Metadata
Release files for openapi2mcpserver 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openapi2mcpserver-0.1.3.tar.gz | 3.6 kB | Without provenance | Details for openapi2mcpserver-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openapi2mcpserver-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for openapi2mcpserver-0.1.3-py3-none-any.whl |
Total release size: 7.8 kB
Release files / openapi2mcpserver-0.1.3.tar.gz
| Download URL | openapi2mcpserver-0.1.3.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
353d7022672d8ac20133a4fafa911421e2eb81fd80d542f07e837313d82e7a93
|
|
BLAKE2b-256 checksum How to use checksums |
f261badf5d8a6e2c14270967a1636b6afe7c6d863550b510e3ddec0ff41528b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|
Release files / openapi2mcpserver-0.1.3-py3-none-any.whl
| Download URL | openapi2mcpserver-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0f0a54795cd1b8a3b8004347ca054ea331387e99ecffd8a2566ebf7c7cebe76
|
|
BLAKE2b-256 checksum How to use checksums |
8e18e7ac233abdd26e35b3b88002e25b2f7a20a807ede97398a7f3b9ef379621
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|
Security for openapi2mcpserver 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.