geojson_to_wkt
Convert GeoJSON objects into Well-Known Text (WKT) format for streamlined GIS data processing and compatibility with spatial analysis tools.
Instructions
Convert GeoJSON to Well-Known Text (WKT) format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geojson | Yes | GeoJSON object to convert |
Implementation Reference
- src/index.ts:346-372 (handler)The handler function that implements the geojson_to_wkt tool logic, converting GeoJSON to WKT using the wellknown.stringify method.async geoJSONToWKT(args: any): Promise<ToolResponse> { const { geojson } = args; if (!geojson) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameter: geojson' ); } try { console.error(`[Converting] GeoJSON to WKT: ${JSON.stringify(geojson).substring(0, 50)}...`); const wkt = wellknown.stringify(geojson); if (!wkt) { throw new Error('Failed to convert GeoJSON to WKT'); } return this.formatToolResponse(wkt); } catch (error) { console.error('[Error] GeoJSON to WKT conversion failed:', error); throw new McpError( ErrorCode.InternalError, `GeoJSON to WKT conversion failed: ${error instanceof Error ? error.message : String(error)}` ); }
- src/index.ts:106-117 (registration)Tool registration in the ListTools response, defining the name, description, and input schema for geojson_to_wkt.name: 'geojson_to_wkt', description: 'Convert GeoJSON to Well-Known Text (WKT) format', inputSchema: { type: 'object', properties: { geojson: { type: 'object', description: 'GeoJSON object to convert', }, }, required: ['geojson'], },
- src/index.ts:108-117 (schema)The input schema definition for the geojson_to_wkt tool, specifying the expected geojson object parameter.inputSchema: { type: 'object', properties: { geojson: { type: 'object', description: 'GeoJSON object to convert', }, }, required: ['geojson'], },
- src/index.ts:282-283 (handler)Dispatch case in the CallToolRequest handler that routes to the geoJSONToWKT implementation.case 'geojson_to_wkt': return await this.geoJSONToWKT(request.params.arguments);