Metadata-Version: 2.4
Name: apifox-mcp-community
Version: 3.0.0
Summary: Apifox MCP Server v3 — 基于 MCP 协议的 Apifox API 管理工具，支持动态工具注册
Author: ChenShi
License: MIT
Keywords: api,apifox,mcp,model-context-protocol
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: mcp>=1.0.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# Apifox MCP v3

- 基于 MCP 协议的 Apifox API 管理工具 v3。
- 支持**多维工具激活**（按域 / 按权限 / 按工具名），80+ 个 MCP 工具覆盖 13 个功能域。
- 项目处于测试阶段，请不要在重要生产环境使用，或确保项目以安全模式启动。


# 配置文件
```json
{
  "mcpServers": {
    "apifox": {
      "command": "{下载位置}/ApiFox_MCP/.venv/Scripts/python.exe",
      "args": ["-m", "apifox_mcp.main"],
      "cwd": "{下载位置}/ApiFox_MCP/apifox-mcp-3.0",
      "env": {
        "APIFOX_TOKEN": "你的token",
        "APIFOX_PROJECT_ID": "你的项目id",
        "APIFOX_API_VERSION": "2025-09-01",
        "APIFOX_MCP_MODE": "full",
        "APIFOX_MCP_CLUSTER": "design", //该字段仅在MODE为cluster时有效
        "APIFOX_MCP_CUSTOM_TOOLS": "list_http_apis,get_http_api_detail",
        "APIFOX_PUBLIC_API_BASE": "https://api.apifox.com",
        "APIFOX_MCP_TOOL_TIMEOUT": "3.0",
        "APIFOX_HTTP_TIMEOUT": "30.0",
        "APIFOX_MAX_RETRIES": "2",
        "APIFOX_BRANCH_ID":"",
        "APIFOX_AI_BRANCH":"test_branch"
      }
    }
  }
}
```


# 启动模式
项目的启动模式分为以下几种：

## full（默认）
**全量模式**：全量加载项目 80+ 工具。
**注意**：全量加载后预计本 mcp 上下文长度会达到 20k token，使用之前需考虑 token 消耗。

## dynamic
**动态模式**：启动时仅加载 9 个 Layer 1 核心工具，AI 按需调用 `activate_domain` 激活 Layer 2 功能域。
支持 `readonly` 参数：`activate_domain("http_api", readonly=True)` 仅激活查询工具。

**注意**：因 MCP 工具通常组装在请求上下文前端，工具列表改变后会导致下次请求**大范围缓存失效**，建议 AI 在会话开始时一次性加载完成所有所需工具。

## cluster
**集群模式**：通过 `APIFOX_MCP_CLUSTER` 参数，让 MCP 以预设工作流环境启动。
启动后工具集在整个 session 生命周期内不变，支持零缓存失效。

### 预设环境

| 集群 | 包含域 | 用途 |
|------|--------|------|
| **design** | http_api(读写), schema(读写), response(读写), doc(读写), environment(只读) | 搭建完整 API 文档体系 |
| **testing** | test_case(读写), test_scenario(读写), test_report(读写), http_api(只读), schema(只读), environment(只读), response(只读) | 编写测试用例并审查结果，可查询 API 定义但不能修改 |
| **review** | 全部 13 个域（只读） | 审查项目当前信息，零写入风险 |
| **platform** | custom_endpoint(读写), websocket(读写), environment(读写), global_param(读写) | 管理项目环境与平台参数 |



