REST API to MCP Server — AI Agent Tools avatar

REST API to MCP Server — AI Agent Tools

Pricing

Pay per usage

Go to Apify Store
REST API to MCP Server — AI Agent Tools

REST API to MCP Server — AI Agent Tools

Convert any REST API into a Model Context Protocol (MCP) server configuration. Automatically generates tools and resources from OpenAPI specs or API documentation.

Pricing

Pay per usage

Rating

0.0

(0)

Developer

陈俊杰

陈俊杰

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

a day ago

Last modified

Share

MCP Server Adapter — REST API 转 MCP Server 配置

把任意 REST API 快速转换成 Model Context Protocol (MCP) Server 配置,让开发者无缝对接 MCP 生态。

🚀 功能

  • OpenAPI / Swagger 解析 — 自动抓取并解析 OpenAPI 规范,为每个 API 操作生成 MCP Tool 定义
  • URL 分析 — 分析 API 基 URL 的路径结构,生成通用的 HTTP Tool 配置(GET/POST/PUT/DELETE)
  • 模板生成 — 输出 MCP Server 配置模板,由用户手动补充具体端点信息
  • 标准 MCP 格式 — 输出包含 nameversiontoolsresources 的标准 MCP 配置 JSON

📋 输入参数

参数类型必填描述
api_urlstringOpenAPI 规范 URL、API 文档 URL 或 API 基 URL
api_typeenum解析方式:openapi / url / description
namestring自定义 MCP Server 名称(默认自动生成)

api_type 说明

类型说明
openapi抓取 OpenAPI 3.x 或 Swagger 2.0 规范,自动解析 paths/operations 生成 MCP tools
url分析 URL 路径结构,生成通用 HTTP 工具(GET/POST/PUT/DELETE)
description输出一个 MCP Server 配置模板,用户手动填写具体端点

📤 输出格式

{
"name": "My API MCP Server",
"version": "1.0.0",
"tools": [
{
"name": "getPetById",
"description": "Returns a single pet by ID",
"input_schema": {
"type": "object",
"properties": {
"petId": {
"type": "integer",
"description": "ID of pet to return"
}
},
"required": ["petId"]
},
"url": "https://petstore.swagger.io/v2/pet/{petId}",
"method": "GET"
}
],
"resources": [
{
"uri": "https://petstore.swagger.io/v2/pet/{petId}",
"name": "Returns a single pet by ID"
}
]
}

🧪 使用示例

示例 1: 解析 OpenAPI 规范

输入:
api_url: https://petstore.swagger.io/v2/swagger.json
api_type: openapi
name: Petstore MCP
输出: 完整的 MCP 配置,包含所有 Petstore API 端点的 tool 定义

示例 2: URL 分析

输入:
api_url: https://jsonplaceholder.typicode.com
api_type: url
输出: 包含 GET/POST/PUT/DELETE 通用 HTTP 工具的 MCP 配置

示例 3: 模板生成

输入:
api_url: https://api.example.com/v1
api_type: description
输出: MCP 配置模板,包含示例 tool 和 resource 定义

🔧 本地开发

# 克隆项目
cd apify-actors/mcp-server-adapter
# 安装依赖
pip install -r requirements.txt
# 本地运行(需要 Apify 令牌)
python -m src

📦 技术栈

  • Python 3.11+ — 异步运行时
  • Apify SDK — Actor 框架,提供输入输出、日志、事件系统
  • httpx — 异步 HTTP 客户端,用于抓取 OpenAPI 规范

⚠️ 注意事项

  • 解析 OpenAPI 规范时,依赖目标 API 的规范 URL 可公开访问
  • URL 分析模式仅基于路径结构猜测资源,建议配合 OpenAPI 模式获得更精确结果
  • 生成的 MCP 配置是静态定义,实际调用需要配合 MCP 客户端运行

📄 许可证

MIT