Skip to main content

通过 WGS84 经纬度查询 OpenStreetMap 区/县级行政区名称的 MCP Server,调用 Overpass API 实现反向地理编码。

Project description

dhcckb-reverse-geocode-district

通过 WGS84 经纬度查询 OpenStreetMap 区/县级行政区名称的 MCP Server。

调用 Overpass API 实现反向地理编码,支持多级回退查询。

安装

pip install dhcckb-reverse-geocode-district

或使用 uvx 直接运行:

uvx dhcckb-reverse-geocode-district

功能

工具 说明
reverse_geocode_district 输入 WGS84 经纬度,返回对应区/县级行政区名称、所属城市、省份、行政区级别及 OSM ID

查询策略

  • 中国坐标(约 73°E–135°E, 18°N–54°N):主查 admin_level=6(区/县),回退 5→4;中文名优先 name:zh
  • 国际坐标:主查 admin_level=8(街道/城镇),回退 6→5→4;始终返回 name
  • 大洋/荒漠:返回 found: false 及清晰的说明信息。

用法示例

MCP Client 配置

{
  "mcpServers": {
    "reverse-geocode-district": {
      "command": "uvx",
      "args": ["dhcckb-reverse-geocode-district"]
    }
  }
}

调用示例

// 请求
{
  "name": "reverse_geocode_district",
  "arguments": {
    "latitude": 39.9087,
    "longitude": 116.3975
  }
}

// 响应
{
  "found": true,
  "district_name": "东城区",
  "city": "北京市",
  "province": "北京市",
  "admin_level": 6,
  "admin_level_desc": "admin_level=6 (区/县 (district/county))",
  "osm_id": 554089,
  "osm_type": "relation",
  "in_china": true
}

环境变量

变量名 默认值 说明
OVERPASS_BASE_URL https://overpass-api.de/api/interpreter Overpass API 端点
OVERPASS_RATE_LIMIT 1.0 请求间隔(秒)

依赖

  • Python >= 3.10
  • mcp >= 1.0.0
  • httpx >= 0.28.0

许可

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dhcckb_reverse_geocode_district-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file dhcckb_reverse_geocode_district-0.1.0.tar.gz.

File metadata

File hashes

Hashes for dhcckb_reverse_geocode_district-0.1.0.tar.gz
Algorithm Hash digest
SHA256 28fcbdec8dee689d02a67003027761c5ec65a0501633a031f8c13d55aff33b45
MD5 7c2491532d23f9d3ebf710b120b69980
BLAKE2b-256 04d539f7e9171c23be6fb12be69c461619c8548cd5c070fdc39a2d1c98a81da6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page