Skip to main content
Glama

🏛️ ArchMCP:面向微服务的集中式远程 MCP 服务器

Python 3.10+ Model Context Protocol License: MIT Tests: 18/18 Passing

为你的 AI 编程助手赋予组织级大脑。
ArchMCP 是一个轻量级的远程 Model Context Protocol (MCP) 服务器,可将你的 AI 助手(Google Antigravity、Claude Desktop、Cursor、VS Code)实时连接到你的整个微服务架构。

📚 阅读分步用户手册与设置指南


📖 ArchMCP 背后的故事

日常问题

想象一下,你正在使用 AI 编程助手在 order-service 中编写一个功能。你向 AI 提问:

"实现结账并向客户收费。"

AI 立刻碰壁:

  • 完全不知道 payment-service 需要哪些请求头来实现幂等性。

  • 它不知道 inventory-service 中有哪些数据库列可用于预留库存。

  • 它完全不清楚如果你修改某个端点,哪些上游服务会崩溃。

为了解决这个问题,开发人员通常会尝试两种糟糕的方案:

  1. 将整个仓库塞进提示词:每次提问轻松浪费 100,000+ 个 token,成本高昂,AI 响应缓慢,而且提示词杂乱会导致幻觉。

  2. 在本地克隆 20+ 个仓库:团队中的每个开发人员都必须在笔记本电脑上保持 20 个仓库的更新,仅仅是为了让本地 AI 拥有上下文。


解决方案:一个共享的远程大脑

ArchMCP 通过充当一个集中式、亚毫秒级的架构大脑来解决这个问题。

ArchMCP 并非作为一台笔记本电脑上的私有本地命令运行,而是作为一个共享的远程服务运行。团队中的任何工程师都可以使用认证令牌将其 AI 助手连接到 ArchMCP 服务器 URL。

当你的 AI 助手需要知道:

  • "哪个服务处理退款?" $\rightarrow$ 它调用 search_microservices

  • "payment-service 拥有哪些表?" $\rightarrow$ 它调用 get_database_schema

  • "如果我修改 /api/v1/orders,谁会受影响?" $\rightarrow$ 它调用 analyze_blast_radius

┌────────────────────────────────────────────────────────┐
│                   AI Assistant Client                  │
│       (Google Antigravity, Claude Desktop, Cursor)     │
└──────────────────────────┬─────────────────────────────┘
                           │
                           │  HTTP / Server-Sent Events (SSE)
                           │  Authorization: Bearer <token>
                           │
┌──────────────────────────▼────────────────────────────────────────────────────────┐
│                                   ArchMCP Server                                   │
│                                                                                    │
│   ┌─────────────────────┐  ┌─────────────────────┐  ┌──────────────────────────┐   │
│   │      MCP Tools      │  │    MCP Resources    │  │       MCP Prompts        │   │
│   │ • search_services   │  │ • arch/overview     │  │ • cross_service_planner  │   │
│   │ • blast_radius      │  │ • services/catalog  │  │ • incident_triage        │   │
│   │ • sequence_diagram  │  │ • guidelines/docs   │  │ • contract_refactor      │   │
│   │ • get_db_schema     │  │ • service docs      │  │                          │   │
│   └──────────┬──────────┘  └──────────┬──────────┘  └────────────┬─────────────┘   │
│              │                        │                          │                 │
│   ┌──────────▼────────────────────────▼──────────────────────────▼─────────────┐   │
│   │                       Microservice Intelligence Engine                     │   │
│   │ • Transitive Graph Traversal & Blast Radius Analyzer (BFS)                 │   │
│   │ • In-Memory Index & Token Search (< 2ms response time)                     │   │
│   │ • Dynamic OpenAPI / Swagger 3.0 Importer                                   │   │
│   └───────────────────────────────────┬────────────────────────────────────────┘   │
│                                       │                                            │
│   ┌───────────────────────────────────▼────────────────────────────────────────┐   │
│   │              Embedded Web Visualizer & Live Sandbox (/dashboard)           │   │
│   │ • Interactive Service Topology Explorer & Token Economics Calculator       │   │
│   └────────────────────────────────────────────────────────────────────────────┘   │
└────────────────────────────────────────────────────────────────────────────────────┘

💡 我是如何设计它的以及为什么

在设计 ArchMCP 时,目标是保持快速、简洁、实用,避免不必要的复杂性:

1. 为什么选择远程 HTTP/SSE 而不是本地 CLI 进程?

标准 MCP 服务器以本地 stdio 子进程运行。虽然这对单用户桌面脚本有效,但一家拥有 50 名工程师、跨 30 个微服务协作的公司需要一个集中的事实来源。通过通过 HTTP/SSE 托管 ArchMCP,架构更新和新的 API 模式可以即时提供给所有人,无需本地克隆仓库。

2. 为什么选择内存图索引而不是重型向量数据库?

许多 AI 工具会立即转向重型向量数据库(如 Pinecone 或 Milvus)。对于结构化架构元数据(API 路由、数据库表和服务依赖),图遍历和快速词法 token 匹配具有以下优势:

  • 确定性:对 /api/v1/auth/login 等路由或 users 等表进行精确匹配。

  • 零开销:仅需约 38 MB 内存即可运行,无需任何外部 API 密钥或 GPU 要求。

  • 极速:响应时间低于 2 毫秒。

3. 权衡的取舍

方案

优点

缺点

决策

本地 CLI(stdio

对单个人来说简单。

每个人都必须在本地克隆每个仓库;没有集中更新。

跳过

自定义 REST API

熟悉的 Web 端点。

需要为每个 IDE 编写和维护自定义插件。

跳过(MCP 是开放标准)

重型向量数据库

语义搜索。

冷启动慢、成本高、需要嵌入基础设施。

推迟,改用简单的内存图索引

基于 SSE 的远程 MCP

集中、即时同步、经过认证、适用于所有主流 AI 工具。

需要运行一个轻量级服务器。

采用


📊 性能基准与 token 经济学

我们测量了通过转储仓库上下文让 AI 助手分析微服务任务与查询 ArchMCP 之间的差异:

基准指标

完整代码库提示

ArchMCP 查询(实时)

效率提升

Token 消耗

约 140,000 到 180,000 个 token

约 120 到 380 个 token

减少 > 99.6%

执行延迟

不适用(完整文件扫描 / 手动)

约 1.8 毫秒到 16 毫秒

亚秒级实时

内存占用

约 500 MB(本地克隆 + 索引器)

约 38 MB

减少 > 90% 内存

测试套件

不适用

18/18 通过,耗时 < 1.5 秒

即时验证

💡 实时验证:你可以随时使用内置的 交互式仪表盘沙盒 实时测试和观察这些性能指标,该沙盒会计算每次请求的查询延迟和 token 节省量。


🔍 构建过程中的意外发现

在 Python 中构建远程 MCP 服务器揭示了一些有趣的技术细节:

  1. 类型提示成为 AI 模式:官方 Python MCP SDK 会自动读取 Python 类型注解和文档字符串,以生成 LLM 用于选择工具的 JSON-Schema 定义。好的文档字符串确实能让 AI 更聪明。

  2. DNS 重新绑定防护:MCP 2.0 协议会自动验证传入的 Host 头,以保护内部开发网络免受基于浏览器的 DNS 攻击。

  3. 两阶段 SSE 握手:当 AI 客户端连接到 GET /sse 时,服务器会打开事件流并返回一个唯一的会话回传 URL(/messages/?session_id=...)。所有后续的 JSON-RPC 工具调用都会发送到此会话。


🖥️ 实时浏览器可视化器与沙盒

ArchMCP 包含一个嵌入式、响应式 Web 仪表盘,位于 http://localhost:8000/dashboard(或 /):

ArchMCP 交互式仪表盘与实时沙盒

  • 交互式拓扑:点击任何服务卡片(auth-serviceorder-servicepayment-service)以检查其 API、拥有的数据库表和依赖映射。

  • 实时工具沙盒:实时测试任何 MCP 工具,并查看 JSON-RPC 请求/响应以及实时的 token 节省量和延迟指标。


⌨️ 开发者 CLI

ArchMCP 附带一个便捷的命令行工具:

# 1. Start the Remote Server
archmcp run

# 2. Explore the Catalog in your Terminal
archmcp explore

# 3. Calculate Change Blast Radius
archmcp blast-radius auth-service

# 4. Import a live OpenAPI / Swagger Specification
archmcp import-openapi https://petstore.swagger.io/v2/swagger.json --owner "Commerce Team"

🔌 连接你的 AI 助手

一旦 ArchMCP 运行(例如在 http://127.0.0.1:8000/sse),你可以在几秒钟内配置你的 AI 工具:

Google Antigravity IDE

添加到 .agents/mcp_config.json

{
  "mcpServers": {
    "archmcp": {
      "url": "http://127.0.0.1:8000/sse",
      "headers": {
        "Authorization": "Bearer dev-token-secret-123"
      }
    }
  }
}

Claude Desktop(claude_desktop_config.json

{
  "mcpServers": {
    "archmcp": {
      "url": "http://127.0.0.1:8000/sse",
      "headers": {
        "Authorization": "Bearer dev-token-secret-123"
      }
    }
  }
}

Cursor(.cursor/mcp.json

{
  "mcpServers": {
    "archmcp": {
      "url": "http://127.0.0.1:8000/sse?token=dev-token-secret-123"
    }
  }
}

🚀 三步快速入门

# 1. Clone & Install
git clone https://github.com/ShubhamScript/archmcp.git
cd archmcp
pip install -e .[dev]

# 2. Run Tests
pytest -v

# 3. Start Server
archmcp run

在浏览器中打开 http://localhost:8000/dashboard,以交互方式探索你的架构。


🔮 路线图上的下一步

如果要将 ArchMCP 扩展到大型企业中的 500+ 个微服务:

  1. 语义概念搜索:添加 pgvectorsqlite-vec 以及本地嵌入,以便开发人员可以提出概念性问题("循环计费在哪里?")。

  2. Backstage 集成:自动同步 Spotify Backstage 的 catalog-info.yaml

  3. Redis 事件总线:在水平扩展的容器副本之间同步活动 SSE 会话。

  4. Git Webhooks:每当 PR 合并时自动更新模式。


📂 项目结构

archmcp/
├── README.md                      # Project guide & architecture story
├── pyproject.toml                 # Dependencies, CLI scripts, and build config
├── Dockerfile                     # Container build instructions
├── docker-compose.yml             # Container orchestration
├── data/
│   └── repositories.yaml          # Sample microservices catalog
├── src/
│   └── archmcp/
│       ├── main.py                # Server bootstrap
│       ├── cli.py                 # Developer CLI (run, explore, blast-radius, import-openapi)
│       ├── config/settings.py     # Environment settings
│       ├── auth/                  # Bearer token verification & ASGI middleware
│       ├── mcp/                   # Tools, Resources, Prompts, and SSE route handlers
│       ├── services/              # Blast radius, graph traversal, and search logic
│       ├── ingestion/             # OpenAPI importer, markdown parser, dependency scanner
│       ├── storage/               # In-memory database & token search index
│       ├── web/                   # Embedded visualizer and live testing playground
│       └── models/                # Pydantic schemas (Architecture, BlastRadius, Services)
└── tests/                         # 18 unit & integration tests

📄 许可证

MIT 许可证。可免费用于开源和商业用途。

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).

  • MCP server for AI access to Swagger by SmartBear.

  • MCP server for AI access to SmartBear tools, including BugSnag, Reflect, Swagger, PactFlow, QTM4J.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ShubhamScript/archmcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server