一个集成Google Forms API和CamelAIOrg代理的模型上下文协议(MCP)服务器,用于通过自然语言指令创建、修改和检索表单。
该项目允许通过自然语言请求创建和管理Google表单。它由两个主要组件组成:
系统具有深色主题用户界面,并带有动画化的请求流程可视化,展示前端、代理、MCP服务器和Google API之间的交互。
┌─────────────┐ ┌─────────────┐ ┌────────────┐ ┌────────────┐
│ │ │ │ │ │ │ │
│ 前端 │◄──►│ CamelAIOrg │◄──►│ MCP 服务器 │◄──►│ Google │
│ (UI) │ │ 代理 │ │ │ │ Forms API │
│ │ │ │ │ │ │ │
└─────────────┘ └─────────────┘ └────────────┘ └────────────┘
此图表说明了用户请求如何流经系统:
graph TD
subgraph "用户界面"
A[前端UI]
end
subgraph "处理逻辑"
B((CamelAIOrg代理))
C((MCP服务器))
end
subgraph "外部服务"
D{{Google Forms API}}
end
A -->|"1. 用户输入:创建反馈表单"| B
B -->|"2. 解释请求,发送工具调用"| C
C -->|"3. 转换为API请求"| D
D -->|"4. 返回表单ID和URL"| C
C -->|"5. 处理API响应"| B
B -->|"6. 格式化最终结果到UI"| A
style B fill:#f9d423,stroke:#333,stroke-width:2px,color:#333
style C fill:#8ecae6,stroke:#333,stroke-width:2px,color:#333
create_form)转换为具体的Google表单API请求。模型上下文协议(MCP)服务器作为关键中间层的原因如下:
create_form、add_question)。git clone https://github.com/yourusername/google-form-mcp-server.git
cd google-form-mcp-server
http://localhost:5000/oauth2callback在根目录下创建.env文件:
# Google API凭证
GOOGLE_CLIENT_ID=your_client_id_here
GOOGLE_CLIENT_SECRET=your_client_secret_here
GOOGLE_REFRESH_TOKEN=your_refresh_token_here
# 服务器配置
FLASK_ENV=development
PORT=5000
DEBUG=True
# CamelAIOrg代理配置
AGENT_ENDPOINT=http://agents:5001/process
AGENT_API_KEY=your_agent_api_key_here
要获得刷新令牌:
.env文件中docker-compose up --build
这将启动MCP服务器(端口5000)和CamelAIOrg代理服务(端口5001)。
访问Web界面:http://localhost:5000
该界面允许您:
GET /api/health - 健康检查GET /api/schema - 获取MCP工具模式POST /api/process - 处理MCP请求GET /health - 健康检查GET /schema - 获取代理能力POST /process - 处理自然语言请求这里有一些您可以尝试的自然语言请求示例:
MCP服务器接受以下格式的请求:
{
"transaction_id": "unique_transaction_id",
"tool_name": "create_form",
"parameters": {
"title": "表单标题",
"description": "表单描述"
}
}
并响应:
{
"transaction_id": "unique_transaction_id",
"status": "success",
"result": {
"form_id": "表单ID",
"response_url": "https://docs.google.com/forms/d/form_id/viewform",
"edit_url": "https://docs.google.com/forms/d/form_id/edit",
"title": "表单标题"
}
}
google-form-mcp-server/
├── server/ # MCP服务器
│ ├── app.py # 主Flask应用
│ ├── config.py # 配置
│ ├── forms_api.py # Google表单API集成
│ ├── mcp_handler.py # MCP协议处理器
│ ├── requirements.txt # Python依赖
│ ├── static/ # 静态资产
│ ├── templates/ # HTML模板
│ └── utils/ # 工具函数
├── agents/ # CamelAIOrg代理
│ ├── agent_integration.py # 代理实现
│ ├── agent_server.py # 代理API服务器
│ └── requirements.txt # Python依赖
├── Dockerfile # MCP服务器Dockerfile
├── docker-compose.yml # Docker Compose配置
├── .env.example # 示例环境变量
└── README.md # 项目文档
要不使用Docker运行MCP服务器:
cd server
pip install -r requirements.txt
python app.py
要不使用Docker运行代理服务:
cd agents
pip install -r requirements.txt
python agent_server.py
MIT