规划MCP服务器v2.0
澳大利亚规划物业报告的模型上下文协议(MCP)服务器-Cloudflare Workers Edition。
特性
- 🌍 全球边缘部署 -在Cloudflare的300多个边缘位置运行
- ⚡ 高性能 -并行API请求和智能缓存
- 📊 综合数据 -物业详细信息、区域、覆盖层、选区、公用事业和土地信息
- 🔒 生产就绪 -速率限制、身份验证、结构化日志记录
- 📈 实时进度 -长时间运行操作期间的进度更新
- 🚀 基于HTTP的MCP -与Claude、ChatGPT和其他人工智能助手配合使用
快速开始
先决条件
- Node.js 18+
- Cloudflare Workers帐户
- 牧马人CLI(
npm install -g wrangler)
安装
# Clone the project
cd planning-mcp
# Install dependencies
npm install
# Login to Cloudflare
wrangler login
# Create KV namespace for caching
wrangler kv:namespace create "CACHE"
# Copy the ID and add to wrangler.toml
# Start development server
npm run dev配置
- 更新
wrangler.toml使用您的KV命名空间ID - (可选)设置用于身份验证的API密钥:
wrangler secret put API_KEY部署
# Build the project
npm run build
# Deploy to Cloudflare Workers
npm run deploy用法
MCP工具: vic_planning_property_report
检索全面的维多利亚州规划物业报告。(其他国家工具即将推出。)
输入:
{
"address": "1 Spring Street, Melbourne VIC 3000",
"includePdfBase64": false,
"includeZoneHtml": false,
"includeOverlayHtml": false
}输出:
{
"success": true,
"address": "1 SPRING STREET MELBOURNE VIC 3000",
"propertyPfi": "12345",
"propertyDetails": {
"address": "1 SPRING STREET MELBOURNE VIC 3000",
"councilName": "Melbourne City Council",
"landSize": 842,
"landSizeHectares": 0.0842,
"standardParcelIdentifier": "1\\PS123456",
"registeredAboriginalParty": "Bunurong Land Council",
...
},
"electorates": {
"federal": "Melbourne",
"legislativeAssembly": "Melbourne District",
"legislativeCouncil": "Southern Metropolitan Region"
},
"utilities": {
"powerDistributor": "AusNet Services",
"gas": "AusNet Services",
"melbourneWater": "Melbourne Water",
"melbourneWaterRetailer": "South East Water"
},
"zones": [...],
"overlays": [...]
}HTTP API
健康检查:
GET /healthMCP端点:
POST /mcp
Content-Type: application/json
{
"jsonrpc": "2.0",
"id": "1",
"method": "tools/call",
"params": {
"name": "vic_planning_property_report",
"arguments": {
"address": "1 Spring Street, Melbourne VIC 3000"
}
}
}建筑
┌─────────────────────────────────────────┐
│ Cloudflare Edge Network │
│ ┌───────────────────────────────────┐ │
│ │ Worker (HTTP MCP Endpoint) │ │
│ │ - Hono.js Framework │ │
│ │ - Rate Limiting │ │
│ │ - Authentication │ │
│ │ - CORS │ │
│ └───────────────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────────────┐ │
│ │ Services Layer │ │
│ │ - Address Resolution │ │
│ │ - Property Data Fetching │ │
│ │ - Progress Reporting │ │
│ └───────────────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────────────┐ │
│ │ Workers KV (Caching) │ │
│ │ - 60%+ Cache Hit Rate │ │
│ │ - 24hr TTL for addresses │ │
│ └───────────────────────────────────┘ │
└─────────────────────────────────────────┘发展
项目结构
planning-mcp/
├── src/
│ ├── index.ts # Main entry point
│ ├── types/ # TypeScript types
│ ├── services/ # Business logic
│ ├── middleware/ # HTTP middleware
│ ├── handlers/ # MCP handlers
│ ├── lib/ # Utilities
│ └── schemas/ # Validation schemas
├── test/ # Tests
├── wrangler.toml # Cloudflare config
├── tsconfig.json # TypeScript config
└── package.json # Dependencies测试
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Type check
npm run type-check环境变量
在中配置 wrangler.toml:
| 变量 | 描述 | 默认值 |
|---|---|---|
RATE_LIMIT_PER_MINUTE | 每个IP的速率限制 | 100 |
CACHE_TTL_HOURS | 缓存TTL(小时) | 24 |
ENABLE_ANALYTICS | 启用分析 | true |
ALLOWED_ORIGINS | CORS起源 | \* |
秘密(使用 wrangler secret put):
| 机密 | 描述 | 必填 |
|---|---|---|
API_KEY | 身份验证的承载令牌 | 否 |
演出
- 延迟时间: P50小于5秒,P95小于8秒
- 缓存命中率: >预热后60%
- 吞吐量: 1000+要求/秒,自动缩放
- 冷启动: \<100ms
- 内存: 每个请求\<128MB
安全
- ✅ 使用Zod进行输入验证
- ✅ 速率限制(每IP 100个要求/分钟)
- ✅ 可选的API密钥身份验证
- ✅ CORS配置
- ✅ 日志中没有秘密
监控
结构化日志记录
所有请求都以JSON格式记录,并带有相关ID:
{
"timestamp": "2024-01-30T10:00:00.000Z",
"level": "info",
"message": "Tool call started",
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"tool": "vic_planning_property_report",
"metadata": {
"address": "1 Spring St"
}
}分析
启用Cloudflare分析引擎:
- 请求计数和延迟
- 缓存命中率/未命中率
- 错误追踪
- API性能指标
部署选项
选项1:Cloudflare Workers(推荐)
- 300+个边缘位置
- $5/月基数+使用量
- 全球最低延迟
选项2:Vercel边缘功能
看 Vercel部署指南 获取迁移说明。
选项3:Oracle服务器
传统的Node.js部署-请参阅 v1.0分支.
故障排除
常见问题
找不到KV命名空间:
# Create namespace and update wrangler.toml
wrangler kv:namespace create "CACHE"速率限制错误:
# Increase limit in wrangler.toml
RATE_LIMIT_PER_MINUTE = "200"身份验证失败:
# Check API key is set
wrangler secret list
wrangler secret put API_KEY贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 添加测试
- 提交拉取请求
许可证
麻省理工学院
支持
- 文档: 产品需求文档
- 问题:
- 讨论:
更新日志
v2.0.0(2024-01-30)
- ✨ 为Cloudflare员工重写
- ✨ 基于HTTP的MCP协议
- ✨ 利用土地面积增强物业数据
- ✨ 实时进度更新
- ✨ 并行API请求
- ✨ Workers KV智能缓存
- ✨ 完整的现场覆盖(15+个现场)
- 🔒 生产就绪安全
- 📊 结构化日志记录和指标
v1.0.0
- Node.js stdio的初始实现
______________________________________________________________________
建于❤️ 澳大利亚规划研究
