格洛斯特郡议会MCP服务器
Azure Functions v4 MCP(模型上下文协议)服务器,用于通过其ModernGov SOAP API访问来自格洛斯特郡所有7个议会的民主数据。
当前状态
| 组件 | 状态 | 注释 |
|---|---|---|
| MCP协议实施 | ✅ 完成 | initialize, tools/list, tools/call |
| 多委员会支持 | ✅ 完成 | 格洛斯特郡所有7个议会 |
| 已定义工具架构 | ✅ 完整的 | 8个工具,具有完整的JSON模式和枚举验证 |
| 刀具布线 | ✅ 完成 | 端到端流程工作 |
| 理事会发现 | ✅ 完成 | list_available_councils 工具 |
| ModernGov SOAP客户端 | ✅ 完整 | 多端点支持,可回退到知识库 |
| 知识库 | ✅ 完成 | 所有议会的117个委员会,295个选区 |
支持的议会(7)
| 理事会 | 委员会 | 病房 | URL |
|---|---|---|---|
| 格洛斯特郡议会 | 32 | 55 | https://glostext.gloucestershire.gov.uk |
| 格洛斯特市议会 | 15 | 39 | https://democracy.gloucester.gov.uk |
| 图克斯伯里自治市议会 | 15 | 38 | https://minutes.tewkesbury.gov.uk |
| 斯特劳德区议会 | 10 | 51 | https://stroud.moderngov.co.uk |
| 切尔滕纳姆自治市议会 | 18 | 40 | https://democracy.cheltenham.gov.uk |
| 科茨沃尔德区议会 | 18 | 34 | https://meetings.cotswold.gov.uk |
| 迪恩区议会森林 | 9 | 38 | https://meetings.fdean.gov.uk |
看 docs/COUNCIL_identifier.md 获取API调用中所需的确切理事会名称字符串。
项目结构
GCC-MCP-Pilot/
├── package.json
├── host.json
├── src/
│ ├── index.js # Azure Functions entry point
│ └── functions/
│ ├── mcp.js # Main MCP HTTP endpoint
│ └── test-soap.js # SOAP exploration endpoint
├── lib/
│ ├── mcp-handler.js # MCP JSON-RPC protocol handler
│ ├── moderngov-client.js # SOAP client with multi-council support
│ ├── council-config.js # Council configuration loader
│ └── tools/
│ ├── list-committees.js
│ ├── get-councillors.js
│ ├── get-councillors-by-ward.js
│ ├── get-meetings.js
│ ├── get-meeting-details.js
│ ├── get-attachment.js
│ └── analyze-meeting-document.js
├── json/
│ └── Gloucestershire/
│ ├── councils.json # Council endpoints
│ └── council_data/
│ ├── Gloucester_City_Council/
│ │ ├── committees.json
│ │ └── wards.json
│ ├── Tewkesbury_Borough_Council/
│ │ ├── committees.json
│ │ └── wards.json
│ └── ... (5 more councils)
└── docs/
├── COUNCIL_IDENTIFIERS.md # Council reference guide
└── DEMOCRATIC_DATA_INTEGRITY.md可用的MCP工具
| 工具 | 参数 | 说明 |
|---|---|---|
list_available_councils | 没有 | 从这里开始! 列出所有7个带有元数据的议会 |
list_committees | council_name (可选) | 列出一个或所有理事会的委员会 |
get_councillors | council_name (必填) | 让所有议员按选区参加议会 |
get_councillors_by_ward | council_name, ward_name | 为特定选区寻找议员 |
get_meetings | council_name, committee_id | 召开委员会会议 |
get_meeting_details | council_name, meeting_id | 获取详细的会议信息 |
get_attachment | council_name, attachment_id | 获取文档元数据和URL |
analyze_meeting_document | url | 从PDF中提取结构化内容 |
必需参数
重要:大多数工具需要 council_name 带a的参数 精确区分大小写的匹配:
✅ 对的: "Gloucester City Council" ❌ 错误: "gloucester city council" (案例不匹配) ❌ 错误: "Gloucester Council" (缺少“城市”) ❌ 错误: "GCC" (缩写)
使用 list_available_councils 第一 获取确切的议会名称!
民主数据完整性
重要: 此MCP服务器返回民主决策的官方法定记录。使用这些数据的AI助手必须遵循特殊的处理规则:
- 逐字引用:必须准确引用委员会的建议、决定、决议和动议
- 始终链接源:包括
source_url或web_page来自响应的链接 - 单独解释:明确区分官方记录和解释
看 docs/DEMOCRATIC_DATA_INTEGRITY.md 完整的指南。
数据分类字段
工具响应包括用于识别官方内容的元数据:
{
"data_classification": "official_record",
"is_official_record": true,
"official_sections": ["recommendations", "decisions", "legal_implications"],
"source": {
"system": "ModernGov",
"council": "Gloucester City Council",
"url": "https://democracy.gloucester.gov.uk/..."
}
}看 文档/注释_BLOB_CLIENT_PERFORMANCE.md blob客户端重用和延迟指南 mcp-notes.
本地开发
先决条件
- Node.js 18+
- Azure功能核心工具v4
设置
cd GCC-MCP-Pilot
npm install启动服务器
func start服务器将在以下时间启动 http://localhost:7071
测试
测试MCP协议
# Test initialize - check server info and available councils
curl -X POST http://localhost:7071/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}'
# Test tools/list - see all available tools
curl -X POST http://localhost:7071/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":2}'
# Test list_available_councils - discover councils
curl -X POST http://localhost:7071/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"list_available_councils","arguments":{}},"id":3}'
# Test list_committees - get committees for a specific council
curl -X POST http://localhost:7071/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"list_committees","arguments":{"council_name":"Gloucester City Council"}},"id":4}'
# Test list_committees - get all councils' committees
curl -X POST http://localhost:7071/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"list_committees","arguments":{}},"id":5}'
# Test get_councillors
curl -X POST http://localhost:7071/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"get_councillors","arguments":{"council_name":"Gloucester City Council"}},"id":6}'探索SOAP响应
使用test-soap端点查看来自ModernGov的实际XML响应:
# List available operations
curl http://localhost:7071/api/test-soap
# Test GetCommittees
curl http://localhost:7071/api/test-soap/GetCommittees
# Test GetCouncillorsByWard
curl http://localhost:7071/api/test-soap/GetCouncillorsByWard
# Test GetMeetings with committee ID
curl "http://localhost:7071/api/test-soap/GetMeetings?committeeId=544"
# Test GetMeeting with meeting ID
curl "http://localhost:7071/api/test-soap/GetMeeting?meetingId=123456"故障排除
“未从ChatGPT/Claude获取任何信息”
如果您看到诸如“未获取任何信息”之类的错误,请检查:
- 议会名称参数:确保精确区分大小写的匹配
# Check available councils first
curl -X POST http://localhost:7071/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"list_available_councils","arguments":{}},"id":1}'- 工具响应格式:工具返回以MCP内容格式包装的JSON:
{
"result": {
"content": [{
"type": "text",
"text": "{ ...actual data... }"
}]
}
}- 错误响应:错误也以内容格式包装
isError: true:
{
"result": {
"content": [{
"type": "text",
"text": "{\"error\": \"council_name is required\"}"
}],
"isError": true
}
}- 检查服务器日志:Azure Functions日志显示所有工具调用和错误:
# In local development
func start
# Watch the console output when making requests- 手动测试:使用上面的curl命令验证工具是否正常工作
常见错误
| 错误 | 原因 | 解决方案 |
|---|---|---|
council_name is required | 缺少参数 | 添加 council_name 参数 |
Unknown council: ... | 无效的议会名称 | 使用 list_available_councils 获取确切的姓名 |
Ward not found | 病房名称无效 | 使用 get_councillors 查看可用病房 |
SOAP request failed: 403 | 网络限制 | 正常-回退到知识库数据 |
调试步骤
- 测试工具/清单 验证MCP服务器是否正在响应
- 测试列表_可用_委员会 验证加载的议会配置
- 测试列表_提交 有专门的委员会来验证数据访问
- 检查Azure功能日志 有关详细的错误消息
- 验证MCP客户端配置 在ChatGPT/Claude设置中
MCP客户端配置
ChatGPT配置
在ChatGPT设置中,配置MCP服务器:
{
"mcpServers": {
"gloucestershire-councils": {
"url": "https://your-function-app.azurewebsites.net/api/mcp",
"apiKey": "your-api-key-if-needed"
}
}
}Claude桌面配置
添加 claude_desktop_config.json:
{
"mcpServers": {
"gloucestershire-councils": {
"command": "node",
"args": ["/path/to/GCC-MCP-Pilot/mcp-stdio-wrapper.js"],
"env": {
"MODERNGOV_ENDPOINT": "https://democracy.gloucester.gov.uk/mgWebService.asmx"
}
}
}
}环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
MODERNGOV_ENDPOINT | ⚠️ 弃用-现在从议会配置中加载 | 不适用 |
现在已在中配置了理事会终结点 json/Gloucestershire/councils.json.
MCP协议参考
此服务器实现了模型上下文协议(MCP)JSON-RPC接口:
方法
initialize-返回服务器功能、委员会列表和指令tools/list-返回8个可用的JSON模式验证工具tools/call-执行工具并返回结果ping-健康检查
响应格式
所有响应均遵循JSON-RPC 2.0格式:
{
"jsonrpc": "2.0",
"result": { ... },
"id": 1
}工具调用结果以MCP内容格式包装:
{
"jsonrpc": "2.0",
"result": {
"content": [
{
"type": "text",
"text": "{ ...JSON result with date context wrapper... }"
}
]
},
"id": 1
}部署
使用以下方式部署到Azure功能:
func azure functionapp publish 文档
许可证
麻省理工学院
