A Model Context Protocol (MCP) server for coordinate system transformations and map projections.
- Multiple coordinate system format support:
- EPSG codes
- WKT (Well-Known Text)
- Proj string format
- Batch coordinate transformation
- Simple and intuitive API
- Dual-mode operation: server or library
pip install mcp-server-projmcp-server-projfrom mcp_server_proj import CoordinateTransformer
# Create transformer instance
transformer = CoordinateTransformer()
# Set source and target coordinate systems
transformer.set_source_crs("EPSG:4326") # WGS84
transformer.set_target_crs("EPSG:3857") # Web Mercator
# Initialize transformer
transformer.initialize_transformer()
# Transform coordinates
x, y = transformer.transform_point(116.3, 39.9)
print(f"Transformed coordinates: ({x}, {y})")The main coordinate transformation class provides the following methods:
set_source_crs(crs: str): Set source coordinate systemset_target_crs(crs: str): Set target coordinate systeminitialize_transformer(): Initialize the transformertransform_point(x: float, y: float) -> tuple[float, float]: Transform a single point
The MCP protocol server provides two tools:
-
transform-coordinates: Transform coordinates between different systems{ "source_crs": "EPSG:4326", "target_crs": "EPSG:3857", "coordinates": [ {"x": 116.3, "y": 39.9} ] } -
list-supported-crs: List all supported coordinate systems
Standard identifiers for coordinate reference systems:
- EPSG:4326 - WGS84 Geographic
- EPSG:3857 - Web Mercator
- And many more...
Example of a geographic coordinate system:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]]
Example of WGS84:
+proj=longlat +datum=WGS84 +no_defs +type=crs
For the best debugging experience, use the MCP Inspector:
npx @modelcontextprotocol/inspector mcp-server-proj- Python >= 3.12
- mcp >= 1.3.0
- pyproj >= 3.0.0
MIT
radial-hks (radialjiajie@gmail.com)
Issues and Pull Requests are welcome!