MongoDB管道生成与执行服务器

WeTrack MCP Server是一个基于MongoDB的管道生成与执行工具,通过自然语言查询生成和执行MongoDB聚合管道,适用于金融事件数据分析。

  • by williamayal
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 williamayal/wetrack-mcp-server

使用说明

WeTrack MCP服务器

用于MongoDB管道生成和执行的MCP(模型上下文协议)服务器。该服务器为人工智能模型提供了与存储在MongoDB中的金融事件数据交互的工具。

特性

  • 管道生成:使用GPT-5.1从自然语言查询生成MongoDB聚合管道
  • 管道执行:执行MongoDB聚合管道并返回结果
  • 远程访问:用于远程MCP访问的HTTP/SSE服务器(Claude AI等)
  • 认证:OAuth2和Bearer令牌身份验证支持
  • 日期处理:自动将日期字符串转换为MongoDB查询的日期时间对象

工具

  1. generate_mongodb管道:从自然语言查询生成MongoDB聚合管道
  2. execute_mongodb-pipeline:执行MongoDB聚合管道并返回结果

设置

  1. 安装依赖项:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. 在中配置环境变量 .env:
MONGODB_URI=your_mongodb_uri
MONGODB_DATABASE=your_database
MONGODB_VIEW=your_view_or_collection
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL_PIPELINE=gpt-5.1
SERVER_PORT=8002

# Authentication (optional)
OAUTH_ENABLED=false
OAUTH_CLIENT_ID=your_client_id
OAUTH_CLIENT_SECRET=your_client_secret
BEARER_TOKEN_ENABLED=false
BEARER_TOKEN=your_bearer_token
MCP_TOKEN=your_mcp_token
MCP_CLIENT_ID=your_client_id
  1. 运行服务器:
python -m src.server_http

远程访问(Claude AI)

  1. 使用ngrok公开服务器:
ngrok http 8002
  1. 使用ngrok URL和身份验证凭据配置Claude AI。

项目结构

wetrack-mcp-server/
├── src/
│   ├── config/          # Configuration settings
│   ├── services/         # LLM and MongoDB services
│   ├── tools/           # MCP tools (generate, execute)
│   ├── utils/           # Date and JSON utilities
│   ├── auth.py          # Authentication utilities
│   ├── oauth.py         # OAuth2 implementation
│   └── server_http.py   # HTTP/SSE server
├── test_pipeline.py     # Pipeline testing script
└── requirements.txt     # Python dependencies

许可证

麻省理工学院