Skip to main content
Glama
ronantakizawa

GIS Data Conversion MCP

geojson_to_topojson

Convert GeoJSON to TopoJSON format to reduce file size by sharing boundaries between adjacent features, making geographic data more compact for web applications.

Instructions

Convert GeoJSON to TopoJSON format (more compact with shared boundaries)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geojsonYesGeoJSON object to convert
objectNameNoName of the TopoJSON object to createdata
quantizationNoQuantization parameter for simplification (0 to disable)

Implementation Reference

  • The main handler function that executes the geojson_to_topojson tool. Converts GeoJSON to TopoJSON using topojsonServer.topology() and optionally applies quantization with topojsonClient.quantize().
    async geojsonToTopoJSON(args: any): Promise<ToolResponse> {
      const { geojson, objectName = 'data', quantization = 1e4 } = args;
      
      if (!geojson) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Missing required parameter: geojson'
        );
      }
      
      try {
        console.error('[Converting] GeoJSON to TopoJSON');
        
        // Create a topology object from the GeoJSON
        const objectsMap: Record<string, any> = {};
        objectsMap[objectName] = geojson;
        
        // Generate the topology
        const topology = topojsonServer.topology(objectsMap);
        
        // Apply quantization if specified
        let result = topology;
        if (quantization > 0) {
          // Use type assertion to work around TypeScript type incompatibility
          result = topojsonClient.quantize(topology as any, quantization);
        }
        
        return this.formatToolResponse(JSON.stringify(result, null, 2));
      } catch (error) {
        console.error('[Error] GeoJSON to TopoJSON conversion failed:', error);
        throw new McpError(
          ErrorCode.InternalError,
          `GeoJSON to TopoJSON conversion failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Input schema definition for the geojson_to_topojson tool, specifying required geojson object and optional objectName and quantization parameters.
    inputSchema: {
      type: 'object',
      properties: {
        geojson: {
          type: 'object',
          description: 'GeoJSON object to convert',
        },
        objectName: {
          type: 'string',
          description: 'Name of the TopoJSON object to create',
          default: 'data',
        },
        quantization: {
          type: 'number',
          description: 'Quantization parameter for simplification (0 to disable)',
          default: 1e4,
        },
      },
      required: ['geojson'],
  • src/index.ts:165-187 (registration)
    Registration of the geojson_to_topojson tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'geojson_to_topojson',
      description: 'Convert GeoJSON to TopoJSON format (more compact with shared boundaries)',
      inputSchema: {
        type: 'object',
        properties: {
          geojson: {
            type: 'object',
            description: 'GeoJSON object to convert',
          },
          objectName: {
            type: 'string',
            description: 'Name of the TopoJSON object to create',
            default: 'data',
          },
          quantization: {
            type: 'number',
            description: 'Quantization parameter for simplification (0 to disable)',
            default: 1e4,
          },
        },
        required: ['geojson'],
      },
Behavior3/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. It mentions the conversion behavior and a key trait (compactness with shared boundaries), which adds useful context. However, it lacks details on potential side effects, error handling, performance considerations, or output format specifics, leaving gaps in behavioral disclosure for a transformation tool.

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 a single, efficient sentence that front-loads the core action and includes a parenthetical benefit. Every word earns its place with no redundancy or unnecessary elaboration, making it highly concise and well-structured.

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 complexity (data format conversion with 3 parameters, no output schema, and no annotations), the description is minimally adequate. It covers the purpose and a key benefit but lacks details on output behavior, error cases, or usage scenarios. With no annotations or output schema, more context would improve completeness for safe agent invocation.

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 fully documents all three parameters. The description does not add any parameter-specific details beyond what the schema provides (e.g., it doesn't explain the implications of 'quantization' or 'objectName' in context). Baseline 3 is appropriate as the schema handles 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 specific action ('Convert GeoJSON to TopoJSON format') and distinguishes it from sibling tools like 'geojson_to_csv' or 'geojson_to_kml' by specifying the target format. It also adds value by mentioning the key benefit ('more compact with shared boundaries'), which helps differentiate it from the inverse tool 'topojson_to_geojson'.

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 context by mentioning the benefit of TopoJSON (compactness with shared boundaries), which suggests when this format might be preferred. However, it does not explicitly state when to use this tool versus alternatives like 'geojson_to_csv' or 'geojson_to_kml', nor does it provide exclusions or prerequisites for use.

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

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/ronantakizawa/gis-dataconvertersion-mcp'

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