MCP代理操作系统
  
一个生产就绪的MCP架构参考实现,演示了如何构建使用和公开模型上下文协议服务器的AI代理。
建筑
该项目展示了 MCP链式模式:一种代理操作系统,它消耗多个外部MCP服务器,并将自己暴露为下游客户端的MCP服务器。
特性
| 特性 | 描述 |
|---|---|
| MCP消费者 | 连接到GitHub、Phoenix Docs和搜索MCP服务器 |
| MCP提供者 | 将代理操作系统作为MCP端点暴露在 http://localhost:7777/mcp |
| 干旱追踪 | 通过OpenTetry集成实现完全可观察性 |
| 多团队支持 | PM、DevRel、销售和工程团队的专业客户 |
| 会话内存 | SQLite支持的对话历史和摘要 |
快速开始
先决条件
- Python 3.12+
- Node.js(用于基于npx的MCP服务器)
- 无烟煤API键
安装
# Clone and setup
git clone https://github.com/Nancy-Chauhan/mcp-agent-os.git
cd mcp-agent-os
python3 -m venv venv && source venv/bin/activate
# Install dependencies
pip install -U agno anthropic fastapi uvicorn sqlalchemy python-dotenv
pip install arize-otel openinference-instrumentation-agno # For tracing
# Configure environment
cp .env.example .env
# Edit .env and add your API keys运行服务器
# Simple server (Phoenix Docs only - no API keys needed)
python3 servers/simple_server.py
# Full server (GitHub + Phoenix Docs + Search)
python3 servers/main_agent_server.py与客户进行测试
python3 clients/test_client.py # Basic connectivity test
python3 clients/pm_team_client.py # Product insights
python3 clients/devrel_team_client.py # Documentation gaps
python3 clients/sales_team_client.py # Sales intelligence
python3 clients/engineers_team_client.py # Bug prioritization配置
环境变量
| 变量 | 必填 | 描述 |
|---|---|---|
ANTHROPIC_API_KEY | 是 | Claude API密钥来自 console.anthropic.com |
GITHUB_PERSONAL_ACCESS_TOKEN | 否 | 用于访问存储库的GitHub令牌 |
ARIZE_API_KEY | 否 | Arize跟踪API密钥 |
ARIZE_SPACE_ID | 否 | 干燥空间标识符 |
MCP服务器
| 服务器 | 需要API密钥 | 说明 |
|---|---|---|
| Phoenix Docs MCP | 否 | AI可观察性文档 |
| GitHub MCP | 是 | 存储库问题、PR和活动 |
| 搜索MCP | 否 | 网络搜索功能 |
运作原理
服务器:消耗MCP服务器
from agno.tools.mcp import MCPTools
# HTTP-based MCP (no API key needed)
phoenix_mcp = MCPTools(
transport="streamable-http",
url="https://arizeai-433a7140.mintlify.app/mcp"
)
# Command-based MCP
github_mcp = MCPTools(
command="npx -y @modelcontextprotocol/server-github",
env={"GITHUB_PERSONAL_ACCESS_TOKEN": token}
)服务器:以MCP身份公开
from agno.os import AgentOS
agent_os = AgentOS(
agents=[community_agent],
enable_mcp_server=True # Exposes /mcp endpoint
)
agent_os.serve() # Runs on port 7777客户端:连接到代理操作系统
from agno.tools.mcp import MCPTools
from agno.agent import Agent
async with MCPTools(
transport="streamable-http",
url="http://localhost:7777/mcp"
) as mcp_tools:
agent = Agent(tools=[mcp_tools])
await agent.aprint_response("Analyze community feedback")可观测性
该项目包括Arize AX跟踪,以实现完全可观察性:
from arize.otel import register
from openinference.instrumentation.agno import AgnoInstrumentor
tracer_provider = register(
space_id="your-space-id",
api_key="your-api-key",
project_name="mcp-meetup-demo",
)
AgnoInstrumentor().instrument(tracer_provider=tracer_provider)查看痕迹 app.arize.com 查看代理执行流、LLM调用、工具调用和错误跟踪。
项目结构
mcp-agent-os/
├── servers/
│ ├── main_agent_server.py # Full Agent OS with all MCPs
│ └── simple_server.py # Minimal setup (no API keys)
├── clients/
│ ├── test_client.py # Basic connectivity test
│ ├── pm_team_client.py # Product management queries
│ ├── devrel_team_client.py # Developer relations queries
│ ├── sales_team_client.py # Sales intelligence queries
│ └── engineers_team_client.py
├── docs/
│ └── architecture.png # Architecture diagram
├── .env.example # Environment template
└── README.md资源
许可证
该项目根据MIT许可证获得许可。
______________________________________________________________________
MCP代理操作系统 --展示具有实际价值的实用MCP架构模式。
