Curvature MCP服务器
暴露的MCP服务器 曲率 道路分析作为LLM的工具
MCP(模型上下文协议)服务器,使曲率道路分析项目可作为Claude等LLM的工具。使用自然语言为摩托车手和驾驶爱好者搜索最弯曲、最曲折的道路。
 
🏍️ 这是什么?
此MCP服务器允许Claude和其他LLM分析OpenStreetMap中的道路曲率数据。问以下问题:
- *“找出佛蒙特州长度至少为15公里的十大最弯曲的道路”*
- *“搜索曲率在500到1000之间的铺砌山路”*
- *“获取佛蒙特州100号公路的详细信息”*
Claude将使用MCP工具加载数据、搜索道路并提供详细分析。
🎯 特性
- 加载曲率数据 从已处理的msgpack文件
- 搜索道路 按曲率分数、长度、曲面类型和名称
- 获取详细的道路信息 包括分段、坐标和度量
- 列出加载的数据集 跟踪可用的数据
- 完全异步支持 通过适当的错误处理
- 易于集成 使用Claude Code和Claude API
🚀 快速开始
先决条件
- Python 3.8+
- 曲率 OSM数据处理库
- Claude Code CLI或Claude API访问
安装
- 克隆此存储库:
cd ~/Documents/Programming
git clone https://github.com/GeorgeSmith-Sweeper/curvature-mcp.git
cd curvature-mcp- 设置虚拟环境并安装依赖项:
python3 -m venv mcp_server/venv
mcp_server/venv/bin/pip install -r mcp_server/requirements.txt
mcp_server/venv/bin/pip install osmium # For processing OSM data- 安装曲率库(用于数据处理):
cd ~/Documents/Programming
git clone https://github.com/adamfranco/curvature.git
cd curvature
pip install -e .准备数据
下载并处理您所在地区的OpenStreetMap数据:
# Download OSM data (example: Vermont)
curl -L -o /tmp/vermont-latest.osm.pbf \
https://download.geofabrik.de/north-america/us/vermont-latest.osm.pbf
# Process through curvature pipeline (requires curvature library)
cd ~/Documents/Programming/curvature
python bin/curvature-collect /tmp/vermont-latest.osm.pbf | \
python bin/curvature-pp add_segments | \
python bin/curvature-pp add_segment_length_and_radius | \
python bin/curvature-pp add_segment_curvature | \
python bin/curvature-pp roll_up_curvature | \
python bin/curvature-pp roll_up_length > /tmp/vermont-latest.msgpack其他数据来源:
- 美国各州: https://download.geofabrik.de/north-america/us.html
- 全球: https://download.geofabrik.de/
使用Claude代码
服务器已在中预先配置 .claude/mcp.json.简单地说:
- 在Claude Code中打开此项目
- MCP服务器将自动加载
- 让克劳德使用曲率工具!
示例提示:
Load the Vermont curvature data from /tmp/vermont-latest.msgpack
Find the top 10 curviest roads in Vermont
Search for roads with curvature over 500 and at least 20km long
Get details about Vermont Route 100与Claude API一起使用
在您的Claude API代码中配置MCP服务器:
import anthropic
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-opus-4-5",
max_tokens=2000,
messages=[{
"role": "user",
"content": "Find the curviest roads in Vermont over 15km long"
}],
mcp_servers=[{
"type": "stdio",
"command": "mcp_server/venv/bin/python",
"args": ["-m", "mcp_server.server"],
"env": {"PYTHONPATH": "."}
}],
tools=[{
"type": "mcp_toolset",
"mcp_server_name": "curvature"
}],
betas=["mcp-client-2025-11-20"]
)🛠️ 可用工具
load_curvature_data
从msgpack文件加载已处理的曲率数据。
参数:
file_path(必需):.msgpack文件的绝对路径data_id(可选):此数据集的标识符(默认值:“default”)
search_roads
搜索符合特定条件的道路。
参数:
data_id(可选):要搜索的数据集(默认值:“默认”)min_curvature(可选):最小曲率分数max_curvature(可选):最大曲率分数min_length_km(可选):最小道路长度(km)surface(可选):按表面类型过滤(例如“铺砌”、“沥青”)name_contains(可选):按名称筛选(不区分大小写)limit(可选):要返回的最大结果(默认值:20)
get_road_details
获取特定道路的详细信息。
参数:
data_id(可选):要搜索的数据集road_id(可选):道路收集IDname(可选):道路名称(可替代Road_id)
list_loaded_datasets
列出当前加载的所有曲率数据集及其统计信息。
📊 输出示例
正在加载数据:
{
"status": "success",
"data_id": "vermont",
"collections_loaded": 134850,
"statistics": {
"total_collections": 134850,
"average_curvature": 198.8,
"max_curvature": 107938.1
}
}寻找弯曲的道路:
{
"status": "success",
"total_matches": 1021,
"results": [
{
"name": "Vermont Route 100",
"curvature": 8944.52,
"length_km": 25.02,
"length_mi": 15.55,
"surface": "asphalt",
"ways_count": 42
}
]
}🧪 测试
在没有MCP的情况下在本地测试工具:
# Test with data
PYTHONPATH=. mcp_server/venv/bin/python mcp_server/test_tools.py /tmp/vermont-latest.msgpack
# Test without data (basic functionality)
PYTHONPATH=. mcp_server/venv/bin/python mcp_server/test_tools.py📁 项目结构
curvature-mcp/
├── .claude/
│ └── mcp.json # Claude Code configuration
├── mcp_server/
│ ├── __init__.py # Package init
│ ├── server.py # Main MCP server (stdio transport)
│ ├── tools.py # Tool definitions and implementations
│ ├── test_tools.py # Local testing script
│ ├── requirements.txt # Python dependencies
│ ├── venv/ # Virtual environment (gitignored)
│ └── README.md # Detailed MCP server docs
├── README.md # This file
├── .gitignore # Git ignore rules
└── LICENSE # License file🔧 发展
添加新工具
- 在中创建新的工具类
mcp_server/tools.py:
class MyNewTool(CurvatureTool):
def __init__(self):
super().__init__(
name="my_tool",
description="What this tool does",
input_schema={
"type": "object",
"properties": {
"param1": {"type": "string", "description": "..."}
},
"required": ["param1"]
}
)
def _execute_sync(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
# Your implementation
return {"status": "success", "result": "..."}- 添加
ALL_TOOLS列表 - 测试用
test_tools.py
业绩说明
- 正在加载数据:快速(佛蒙特州317MB加载在几秒钟内)
- 搜索:非常快(在内存中过滤134K+个集合)
- 记忆:随数据集大小缩放(佛蒙特州约500MB RAM)
🤝 贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支
- 进行更改
- 彻底测试
- 提交拉取请求
📝 许可证
此项目遵循与 曲率 项目。
🙏 积分
🔗 链接
- Curvature项目: https://github.com/adamfranco/curvature
- MCP文件: https://modelcontextprotocol.io/
- OpenStreetMap数据: https://download.geofabrik.de/
- 克劳德代码: https://claude.com/claude-code
📧 支持
对于问题和疑问:
______________________________________________________________________
制作❤️ 适合摩托车手和驾驶爱好者
🤖 *生成于 克劳德代码*
