Name | geocode-mcp-hubei JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | MCP geocode tool wrapping 湖北POI 要素定位器 (findAddressCandidates) |
upload_time | 2025-08-26 05:19:39 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
geocoding
mcp
gis
poi
arcgis
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Geocode MCP Service
一个基于 Python + uv 的 Model Context Protocol (MCP) 服务,封装湖北 POI 要素定位器地理编码接口。
远程底层服务:
GET https://geosc41.aakle.cn/server/rest/services/湖北POI_要素定位器/GeocodeServer/findAddressCandidates
## 功能
- 暴露一个 MCP 工具:`geocode_poi`(可自定义)
- 输入:`address` (字符串)
- 内部映射为远程接口 `SingleLine`
- 固定参数:`maxLocations=8`, `f=pjson`, `outSR=4326`, `outFields=*`
- 输出:简化的候选列表(名称、坐标、得分、原始 JSON)
## 快速开始
```powershell
# 创建并激活虚拟环境 (可选)
python -m venv .venv
.\.venv\Scripts\activate
# 安装依赖 (使用 uv 或 pip)
pip install -r requirements.txt
# 或者
uv pip install -r requirements.txt
# 运行本地测试脚本
python src/test_geocode.py "中国地质大学"
```
## 作为 MCP 服务器运行
```powershell
python -m geocode_mcp.server
```
服务器会通过标准输入输出与支持 MCP 的客户端通信。
安装为可执行脚本后也可直接运行(两种等价):
```powershell
geocode-mcp
# 或使用别名脚本
geocode-poi-server
```
### 百炼 / uvx 托管配置示例
`mcpServers` JSON:
```json
{
"mcpServers": {
"geocode_poi": {
"type": "stdio",
"command": "uvx",
"args": ["geocode-mcp-hubei>=0.1.0,<0.2", "geocode-mcp"]
}
}
}
```
或使用新增的别名脚本(省去显式写第二个参数):
```json
{
"mcpServers": {
"geocode_poi": {
"type": "stdio",
"command": "uvx",
"args": ["geocode-mcp-hubei>=0.1.0,<0.2", "geocode-poi-server"]
}
}
}
```
## 工具调用示例(伪 JSON-RPC)
```json
{
"method": "tools/call",
"params": {
"name": "geocode_poi",
"arguments": {"address": "中国地质大学"}
}
}
```
## 部署到阿里云
1. 选择部署方式:
- 函数计算(推荐无服务器)
- ECS 容器/实例
2. 函数计算示例:
- Runtime: Python 3.11
- 入口:`fc_handler.handler`
3. 打包:
```powershell
Compress-Archive -Path src,requirements.txt -DestinationPath package.zip
```
4. 上传并在启动代码里调用 `from geocode_mcp.server import run_server`,需要改造成 HTTP 触发器包装。
> MCP 典型运行基于长连接/标准 IO,若在函数计算上使用,需要将协议桥接为 HTTP:可创建一个简单的 HTTP 转 MCP 工具适配层(后续 TODO)。
## TODO
- [ ] 阿里云 HTTP 适配层 (把 HTTP 请求映射为 geocode 工具调用)
- [ ] 增加缓存与错误重试
- [ ] 添加单元测试
```
Raw data
{
"_id": null,
"home_page": null,
"name": "geocode-mcp-hubei",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "geocoding, MCP, GIS, POI, arcgis",
"author": null,
"author_email": "Your Name <you@example.com>",
"download_url": "https://files.pythonhosted.org/packages/ae/e0/34885a3cec98cd1b1320a77da9ec3d078ee6470695660f0e23583b1dd3a9/geocode_mcp_hubei-0.1.1.tar.gz",
"platform": null,
"description": "# Geocode MCP Service\r\n\r\n\u4e00\u4e2a\u57fa\u4e8e Python + uv \u7684 Model Context Protocol (MCP) \u670d\u52a1\uff0c\u5c01\u88c5\u6e56\u5317 POI \u8981\u7d20\u5b9a\u4f4d\u5668\u5730\u7406\u7f16\u7801\u63a5\u53e3\u3002\r\n\r\n\u8fdc\u7a0b\u5e95\u5c42\u670d\u52a1\uff1a\r\nGET https://geosc41.aakle.cn/server/rest/services/\u6e56\u5317POI_\u8981\u7d20\u5b9a\u4f4d\u5668/GeocodeServer/findAddressCandidates\r\n\r\n## \u529f\u80fd\r\n- \u66b4\u9732\u4e00\u4e2a MCP \u5de5\u5177\uff1a`geocode_poi`\uff08\u53ef\u81ea\u5b9a\u4e49\uff09\r\n- \u8f93\u5165\uff1a`address` (\u5b57\u7b26\u4e32)\r\n- \u5185\u90e8\u6620\u5c04\u4e3a\u8fdc\u7a0b\u63a5\u53e3 `SingleLine`\r\n- \u56fa\u5b9a\u53c2\u6570\uff1a`maxLocations=8`, `f=pjson`, `outSR=4326`, `outFields=*`\r\n- \u8f93\u51fa\uff1a\u7b80\u5316\u7684\u5019\u9009\u5217\u8868\uff08\u540d\u79f0\u3001\u5750\u6807\u3001\u5f97\u5206\u3001\u539f\u59cb JSON\uff09\r\n\r\n## \u5feb\u901f\u5f00\u59cb\r\n```powershell\r\n# \u521b\u5efa\u5e76\u6fc0\u6d3b\u865a\u62df\u73af\u5883 (\u53ef\u9009)\r\npython -m venv .venv\r\n.\\.venv\\Scripts\\activate\r\n\r\n# \u5b89\u88c5\u4f9d\u8d56 (\u4f7f\u7528 uv \u6216 pip)\r\npip install -r requirements.txt\r\n# \u6216\u8005\r\nuv pip install -r requirements.txt\r\n\r\n# \u8fd0\u884c\u672c\u5730\u6d4b\u8bd5\u811a\u672c\r\npython src/test_geocode.py \"\u4e2d\u56fd\u5730\u8d28\u5927\u5b66\"\r\n```\r\n\r\n## \u4f5c\u4e3a MCP \u670d\u52a1\u5668\u8fd0\u884c\r\n```powershell\r\npython -m geocode_mcp.server\r\n```\r\n\u670d\u52a1\u5668\u4f1a\u901a\u8fc7\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u4e0e\u652f\u6301 MCP \u7684\u5ba2\u6237\u7aef\u901a\u4fe1\u3002\r\n\r\n\u5b89\u88c5\u4e3a\u53ef\u6267\u884c\u811a\u672c\u540e\u4e5f\u53ef\u76f4\u63a5\u8fd0\u884c\uff08\u4e24\u79cd\u7b49\u4ef7\uff09\uff1a\r\n```powershell\r\ngeocode-mcp\r\n# \u6216\u4f7f\u7528\u522b\u540d\u811a\u672c\r\ngeocode-poi-server\r\n```\r\n\r\n### \u767e\u70bc / uvx \u6258\u7ba1\u914d\u7f6e\u793a\u4f8b\r\n`mcpServers` JSON\uff1a\r\n```json\r\n{\r\n \"mcpServers\": {\r\n \"geocode_poi\": {\r\n \"type\": \"stdio\",\r\n \"command\": \"uvx\",\r\n \"args\": [\"geocode-mcp-hubei>=0.1.0,<0.2\", \"geocode-mcp\"]\r\n }\r\n }\r\n}\r\n```\r\n\u6216\u4f7f\u7528\u65b0\u589e\u7684\u522b\u540d\u811a\u672c\uff08\u7701\u53bb\u663e\u5f0f\u5199\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff09\uff1a\r\n```json\r\n{\r\n \"mcpServers\": {\r\n \"geocode_poi\": {\r\n \"type\": \"stdio\",\r\n \"command\": \"uvx\",\r\n \"args\": [\"geocode-mcp-hubei>=0.1.0,<0.2\", \"geocode-poi-server\"]\r\n }\r\n }\r\n}\r\n```\r\n\r\n## \u5de5\u5177\u8c03\u7528\u793a\u4f8b\uff08\u4f2a JSON-RPC\uff09\r\n```json\r\n{\r\n \"method\": \"tools/call\",\r\n \"params\": {\r\n \"name\": \"geocode_poi\",\r\n \"arguments\": {\"address\": \"\u4e2d\u56fd\u5730\u8d28\u5927\u5b66\"}\r\n }\r\n}\r\n```\r\n\r\n## \u90e8\u7f72\u5230\u963f\u91cc\u4e91\r\n1. \u9009\u62e9\u90e8\u7f72\u65b9\u5f0f\uff1a\r\n - \u51fd\u6570\u8ba1\u7b97\uff08\u63a8\u8350\u65e0\u670d\u52a1\u5668\uff09\r\n - ECS \u5bb9\u5668/\u5b9e\u4f8b\r\n2. \u51fd\u6570\u8ba1\u7b97\u793a\u4f8b\uff1a\r\n - Runtime: Python 3.11\r\n - \u5165\u53e3\uff1a`fc_handler.handler`\r\n3. \u6253\u5305\uff1a\r\n```powershell\r\nCompress-Archive -Path src,requirements.txt -DestinationPath package.zip\r\n```\r\n4. \u4e0a\u4f20\u5e76\u5728\u542f\u52a8\u4ee3\u7801\u91cc\u8c03\u7528 `from geocode_mcp.server import run_server`\uff0c\u9700\u8981\u6539\u9020\u6210 HTTP \u89e6\u53d1\u5668\u5305\u88c5\u3002\r\n\r\n> MCP \u5178\u578b\u8fd0\u884c\u57fa\u4e8e\u957f\u8fde\u63a5/\u6807\u51c6 IO\uff0c\u82e5\u5728\u51fd\u6570\u8ba1\u7b97\u4e0a\u4f7f\u7528\uff0c\u9700\u8981\u5c06\u534f\u8bae\u6865\u63a5\u4e3a HTTP\uff1a\u53ef\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 HTTP \u8f6c MCP \u5de5\u5177\u9002\u914d\u5c42\uff08\u540e\u7eed TODO\uff09\u3002\r\n\r\n## TODO\r\n- [ ] \u963f\u91cc\u4e91 HTTP \u9002\u914d\u5c42 (\u628a HTTP \u8bf7\u6c42\u6620\u5c04\u4e3a geocode \u5de5\u5177\u8c03\u7528)\r\n- [ ] \u589e\u52a0\u7f13\u5b58\u4e0e\u9519\u8bef\u91cd\u8bd5\r\n- [ ] \u6dfb\u52a0\u5355\u5143\u6d4b\u8bd5\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "MCP geocode tool wrapping \u6e56\u5317POI \u8981\u7d20\u5b9a\u4f4d\u5668 (findAddressCandidates)",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://example.com/geocode-mcp",
"Issues": "https://example.com/geocode-mcp/issues",
"Repository": "https://example.com/geocode-mcp/repo"
},
"split_keywords": [
"geocoding",
" mcp",
" gis",
" poi",
" arcgis"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5418021b9fc644bc3925e85b64fdbbbf86772a20fcdcbff5041f22eedaffb904",
"md5": "e3a58a63aa3bbe8d7046cb24ea167f67",
"sha256": "f76705dcbdc11445a7b0543a8e8c9bd85c5faea887d03720074a251672f3524c"
},
"downloads": -1,
"filename": "geocode_mcp_hubei-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e3a58a63aa3bbe8d7046cb24ea167f67",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7175,
"upload_time": "2025-08-26T05:19:38",
"upload_time_iso_8601": "2025-08-26T05:19:38.201536Z",
"url": "https://files.pythonhosted.org/packages/54/18/021b9fc644bc3925e85b64fdbbbf86772a20fcdcbff5041f22eedaffb904/geocode_mcp_hubei-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "aee034885a3cec98cd1b1320a77da9ec3d078ee6470695660f0e23583b1dd3a9",
"md5": "3546da9253697a998aae18b0ebfccc5a",
"sha256": "79a3a48d12f440f0e0932fc9caa36e0fc08ddfd837b1656043d136d24e324fa8"
},
"downloads": -1,
"filename": "geocode_mcp_hubei-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "3546da9253697a998aae18b0ebfccc5a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 6437,
"upload_time": "2025-08-26T05:19:39",
"upload_time_iso_8601": "2025-08-26T05:19:39.225225Z",
"url": "https://files.pythonhosted.org/packages/ae/e0/34885a3cec98cd1b1320a77da9ec3d078ee6470695660f0e23583b1dd3a9/geocode_mcp_hubei-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-26 05:19:39",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "geocode-mcp-hubei"
}