智能查询路由协调器

MCP Orchestrator是一个智能路由协调器,专为Model Context Protocol (MCP)服务器设计,用于在GCP BigQuery(电动汽车数据)和AWS S3 Tables(州税数据)之间智能路由查询。

  • by nirranjanajaiswwal
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 nirranjanajaiswwal/mcp-aws-gcp-orchestrator

使用说明

MCP 服务编排器

专为模型上下文协议(MCP)服务器设计的智能路由编排器,用于在GCP BigQuery(车辆数据)和AWS S3表(按州划分的税收数据)之间路由查询。

特点

  • 🎯(目标、瞄准) 智能查询路由自动将查询路由到相应的数据源
  • 🔗(链接符号,无实际翻译意义,可保持原样或根据上下文替换为具体描述,如“这是一个链接”) 多服务器支持连接到GCP BigQuery和AWS S3表的MCP服务器
  • 📊(表格) 置信度评分为路由决策提供置信度评分
  • 🚀 火箭或快速前进的象征(无实际文字对应,仅表达意象) 易于集成用于处理查询的简单API
  • ⚛️(这个符号在中文中通常没有直接对应的翻译,它是一个化学元素符号“Fe”(铁)的变体或装饰形式,但在中文语境下,我们通常直接使用“铁”或“Fe”来表示这个元素。如果仅从符号本身来看,它可能被理解为一种特殊的标记或符号,没有具体的中文含义。) React 前端用户友好的网页界面,支持自然语言查询

快速入门

开发环境

  1. 安装Python依赖项:

    pip install -e ".[dev]"
    pip install -r backend/requirements.txt
    
  2. 安装React依赖项:

    cd frontend
    npm install
    cd ..
    
  3. 启动开发服务器:

    ./start-dev.sh
    
  4. 访问该应用程序:

    • 前端:http://localhost:3000
    • 后端API:http://localhost:8000

Python API 使用

import asyncio
from mcp_orchestrator import MCPOrchestrator

async def main():
    orchestrator = MCPOrchestrator()
    
    # Configure server commands
    gcp_command = ["python", "-m", "mcp_bigquery_server"]
    aws_command = ["python", "-m", "mcp_s3tables_server"]
    
    # Connect to servers
    await orchestrator.connect(gcp_command, aws_command)
    
    # Process query
    result = await orchestrator.process_query(
        "What is the average range of electric vehicles?"
    )
    print(result)

asyncio.run(main())

建筑

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   React Frontend│    │  FastAPI Backend│    │ MCP Orchestrator│
│                 │    │                 │    │                 │
│ - Query Input   │───▶│ - REST API      │───▶│ - Query Routing │
│ - Results UI    │◀───│ - CORS Support  │◀───│ - Server Mgmt   │
│ - Examples      │    │ - Error Handling│    │ - Confidence    │
└─────────────────┘    └─────────────────┘    └─────────────────┘
                                                        │
                                               ┌────────┴────────┐
                                               ▼                 ▼
                                    ┌─────────────────┐ ┌─────────────────┐
                                    │  GCP BigQuery   │ │  AWS S3 Tables  │
                                    │   (EV Data)     │ │   (Tax Data)    │
                                    └─────────────────┘ └─────────────────┘

配置

为服务器配置设置环境变量:

export GCP_MCP_COMMAND="python -m mcp_bigquery_server"
export AWS_MCP_COMMAND="python -m mcp_s3tables_server"
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"
export GCP_PROJECT_ID="your-project-id"
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_REGION="us-east-1"

路由逻辑

协调器使用基于关键字的分析来路由查询:

  • **电动汽车数据(BigQuery)**包含“ev”、“电动汽车”、“充电”、“电池”、“特斯拉”等关键词的查询
  • **税务数据(S3 表格)**包含“税收”、“州”、“收入”等关键词以及州名的查询

发展

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black src/ tests/

# Lint code
flake8 src/ tests/

# Type check
mypy src/

项目结构

mcp-aws-gcp-orchestrator/
├── src/
│   └── mcp_orchestrator/
│       ├── __init__.py
│       ├── orchestrator.py
│       └── config.py
├── tests/
│   └── test_orchestrator.py
├── examples/
│   └── basic_usage.py
├── docs/
├── pyproject.toml
├── requirements.txt
├── requirements-dev.txt
├── .gitignore
└── README.md

许可证

MIT 许可证 - 详情请参阅 LICENSE 文件

贡献;助力

欢迎贡献!请先阅读 CONTRIBUTING.md 文件。