Skip to main content
Glama

topojson_to_geojson

Convert TopoJSON to GeoJSON format for geographic data processing and visualization.

Instructions

Convert TopoJSON to GeoJSON format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topojsonYesTopoJSON object to convert
objectNameNoName of the TopoJSON object to convert (if not provided, first object is used)

Implementation Reference

  • The main execution logic for the 'topojson_to_geojson' tool. It validates input, determines the TopoJSON object to convert, and uses topojsonClient.feature to produce GeoJSON output.
    async topojsonToGeoJSON(args: any): Promise<ToolResponse> { const { topojson, objectName } = args; if (!topojson) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameter: topojson' ); } try { console.error('[Converting] TopoJSON to GeoJSON'); // Determine which object to convert let objName = objectName; // If no object name provided, use the first object in the topology if (!objName && topojson.objects) { objName = Object.keys(topojson.objects)[0]; } if (!objName || !topojson.objects || !topojson.objects[objName]) { throw new Error('No valid object found in TopoJSON'); } // Convert TopoJSON to GeoJSON const geojson = topojsonClient.feature(topojson, topojson.objects[objName]); return this.formatToolResponse(JSON.stringify(geojson, null, 2)); } catch (error) { console.error('[Error] TopoJSON to GeoJSON conversion failed:', error); throw new McpError( ErrorCode.InternalError, `TopoJSON to GeoJSON conversion failed: ${error instanceof Error ? error.message : String(error)}` ); } }
  • src/index.ts:189-206 (registration)
    Registration of the 'topojson_to_geojson' tool in the ListTools response, including name, description, and input schema definition.
    { name: 'topojson_to_geojson', description: 'Convert TopoJSON to GeoJSON format', inputSchema: { type: 'object', properties: { topojson: { type: 'object', description: 'TopoJSON object to convert', }, objectName: { type: 'string', description: 'Name of the TopoJSON object to convert (if not provided, first object is used)', }, }, required: ['topojson'], }, },
  • Input schema definition for the 'topojson_to_geojson' tool specifying required 'topojson' object and optional 'objectName'.
    inputSchema: { type: 'object', properties: { topojson: { type: 'object', description: 'TopoJSON object to convert', }, objectName: { type: 'string', description: 'Name of the TopoJSON object to convert (if not provided, first object is used)', }, }, required: ['topojson'],
  • src/index.ts:290-291 (registration)
    Dispatch case in the CallToolRequest handler that routes to the topojsonToGeoJSON method.
    case 'topojson_to_geojson': return await this.topojsonToGeoJSON(request.params.arguments);

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