API文档爬取服务

一个用于爬取API文档网站并通过模型上下文协议(MCP)暴露其内容的服务器,使AI模型能够搜索、浏览和引用API规范。

  • by ShotaNagafuchi
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 ShotaNagafuchi/api-docs-mcp

使用说明

API文档MCP服务器

MCP服务器,用于抓取API文档网站并通过模型上下文协议公开其内容。这允许人工智能模型搜索、浏览和参考API规范。

特性

  • 对API文档网站进行爬网以提取结构化信息
  • 通过MCP将API文档作为资源公开
  • 提供用于查找特定API终结点的搜索工具
  • 包括常见API文档任务的提示模板
  • 存储已爬网数据以供脱机访问

安装

# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install the package
pip install -e .

用法

启动服务器

python -m src.main --url https://example-api-docs.com

连接到服务器

此MCP服务器可以连接到任何MCP客户端,例如Claude for Desktop。配置您的客户端以使用此服务器:

{
  "api-docs": {
    "command": "python",
    "args": ["-m", "src.main", "--url", "https://example-api-docs.com"]
  }
}

MCP能力

资源

  • API端点规范
  • 数据模型和模式
  • API示例和代码片段

工具

  • search_api:按名称、路径或描述搜索API终结点
  • get_endpoint_details:获取特定端点的详细信息
  • list_endpoints:列出所有可用的API终结点
  • find_examples:查找特定API终结点的示例

鼓励

  • explain_endpoint:生成API终结点的自然语言解释
  • compare_endpoints:比较两个API终结点
  • generate_code:生成用于使用API终结点的示例代码

许可证

麻省理工学院