Skip to main content
Glama
NodeGIS

GeoSpatial MCP Server

by NodeGIS

mcp_geo_convert

Convert coordinates between systems like BD09, GCJ02, WGS84, and Web Mercator using specified methods for accurate geospatial data transformation.

Instructions

在不同坐标系统之间转换坐标。支持BD09(百度)、GCJ02(火星)、WGS84(GPS)和Web Mercator投影坐标系统之间的互相转换。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes纬度
longitudeYes经度
methodYes转换方法

Implementation Reference

  • The handler function for the mcp_geo_convert tool. It receives the conversion method and coordinates, dispatches to the corresponding coordinate transformation method, and returns the result as structured JSON or an error.
    async ({ method, longitude, latitude }) => {
      try {
        let result;
        switch (method) {
          case "BD09toGCJ02":
            result = this.BD09toGCJ02(longitude, latitude);
            break;
          case "GCJ02toBD09":
            result = this.GCJ02toBD09(longitude, latitude);
            break;
          case "WGS84toGCJ02":
            result = this.WGS84toGCJ02(longitude, latitude);
            break;
          case "GCJ02toWGS84":
            result = this.GCJ02toWGS84(longitude, latitude);
            break;
          case "BD09toWGS84":
            result = this.BD09toWGS84(longitude, latitude);
            break;
          case "WGS84toBD09":
            result = this.WGS84toBD09(longitude, latitude);
            break;
          case "WebMercatortoLngLat":
            result = this.webMercatorToLngLat(longitude, latitude);
            break;
          case "LngLattoWebMercator":
            result = this.lngLatToWebMercator(longitude, latitude);
            break;
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              method,
              input: { longitude, latitude },
              output: { longitude: result[0], latitude: result[1] }
            }, null, 2)
          }]
        };
      } catch (err) {
        return {
          content: [{
            type: "text",
            text: `错误: ${err.message}`
          }],
          isError: true
        };
      }
    }
  • Input schema using Zod for validating the tool parameters: conversion method (enum), longitude (number), and latitude (number).
    {
      method: z.enum([
        "BD09toGCJ02",
        "GCJ02toBD09",
        "WGS84toGCJ02",
        "GCJ02toWGS84",
        "BD09toWGS84",
        "WGS84toBD09",
        "WebMercatortoLngLat",
        "LngLattoWebMercator"
      ]).describe("转换方法"),
      longitude: z.number().describe("经度"),
      latitude: z.number().describe("纬度")
    },
  • dist/server.js:163-230 (registration)
    Registration of the mcp_geo_convert tool in the GeoServer's initializeTools method, including name, description, input schema, and handler function.
    this.tool(
      "mcp_geo_convert",
      "在不同坐标系统之间转换坐标。支持BD09(百度)、GCJ02(火星)、WGS84(GPS)和Web Mercator投影坐标系统之间的互相转换。",
      {
        method: z.enum([
          "BD09toGCJ02",
          "GCJ02toBD09",
          "WGS84toGCJ02",
          "GCJ02toWGS84",
          "BD09toWGS84",
          "WGS84toBD09",
          "WebMercatortoLngLat",
          "LngLattoWebMercator"
        ]).describe("转换方法"),
        longitude: z.number().describe("经度"),
        latitude: z.number().describe("纬度")
      },
      async ({ method, longitude, latitude }) => {
        try {
          let result;
          switch (method) {
            case "BD09toGCJ02":
              result = this.BD09toGCJ02(longitude, latitude);
              break;
            case "GCJ02toBD09":
              result = this.GCJ02toBD09(longitude, latitude);
              break;
            case "WGS84toGCJ02":
              result = this.WGS84toGCJ02(longitude, latitude);
              break;
            case "GCJ02toWGS84":
              result = this.GCJ02toWGS84(longitude, latitude);
              break;
            case "BD09toWGS84":
              result = this.BD09toWGS84(longitude, latitude);
              break;
            case "WGS84toBD09":
              result = this.WGS84toBD09(longitude, latitude);
              break;
            case "WebMercatortoLngLat":
              result = this.webMercatorToLngLat(longitude, latitude);
              break;
            case "LngLattoWebMercator":
              result = this.lngLatToWebMercator(longitude, latitude);
              break;
          }
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                method,
                input: { longitude, latitude },
                output: { longitude: result[0], latitude: result[1] }
              }, null, 2)
            }]
          };
        } catch (err) {
          return {
            content: [{
              type: "text",
              text: `错误: ${err.message}`
            }],
            isError: true
          };
        }
      }
    );
  • Example helper function for WGS84 to GCJ02 coordinate transformation, used by the tool handler. Other similar helpers exist for different conversions.
    WGS84toGCJ02(lon, lat) {
      if (this.isOutOfChina(lon, lat)) {
        return [lon, lat];
      }
      return this.delta(lon, lat);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does (conversion) but doesn't describe behavioral traits such as error handling, performance characteristics, or any side effects. For a tool with no annotations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured in a single sentence that front-loads the core purpose and lists supported systems. Every word contributes meaning without redundancy, making it efficient and easy to understand.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (coordinate conversion with 3 parameters) and no annotations or output schema, the description is somewhat complete but has gaps. It covers the purpose and supported systems but lacks details on behavior, output format, or error cases. This makes it adequate but not fully comprehensive for an agent to use confidently.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (latitude, longitude, method with enum values). The description adds minimal value beyond the schema by mentioning the supported coordinate systems, which relates to the method parameter, but doesn't provide additional semantic context like conversion accuracy or limitations. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: converting coordinates between different coordinate systems. It specifies the action ('在不同坐标系统之间转换坐标') and lists the supported systems (BD09, GCJ02, WGS84, Web Mercator), which distinguishes it from sibling tools like mcp_geo_calculate_area and mcp_geo_calculate_distance that perform different geographic calculations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when coordinate conversion is needed, but it doesn't provide explicit guidance on when to use this tool versus alternatives. It mentions the supported systems, which gives context, but lacks specific scenarios, exclusions, or comparisons to sibling tools. This leaves usage somewhat open to interpretation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NodeGIS/geo-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server