wkt_to_geojson
Convert Well-Known Text (WKT) to GeoJSON format for geographic data processing and visualization.
Instructions
Convert Well-Known Text (WKT) to GeoJSON format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wkt | Yes | Well-Known Text (WKT) string to convert |
Implementation Reference
- src/index.ts:317-344 (handler)The main handler function for the 'wkt_to_geojson' tool. Parses WKT string using the 'wellknown' library and returns the resulting GeoJSON as a formatted JSON string.async wktToGeoJSON(args: any): Promise<ToolResponse> { const { wkt } = args; if (!wkt) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameter: wkt' ); } try { console.error(`[Converting] WKT to GeoJSON: "${wkt.substring(0, 50)}${wkt.length > 50 ? '...' : ''}"`); const geojson = wellknown.parse(wkt); if (!geojson) { throw new Error('Failed to parse WKT string'); } return this.formatToolResponse(JSON.stringify(geojson, null, 2)); } catch (error) { console.error('[Error] WKT to GeoJSON conversion failed:', error); throw new McpError( ErrorCode.InternalError, `WKT to GeoJSON conversion failed: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:92-104 (schema)Defines the input schema and metadata for the 'wkt_to_geojson' tool in the ListTools response.name: 'wkt_to_geojson', description: 'Convert Well-Known Text (WKT) to GeoJSON format', inputSchema: { type: 'object', properties: { wkt: { type: 'string', description: 'Well-Known Text (WKT) string to convert', }, }, required: ['wkt'], }, },
- src/index.ts:280-281 (registration)Registers the tool dispatch in the CallToolRequestSchema handler by routing calls to the wktToGeoJSON method.case 'wkt_to_geojson': return await this.wktToGeoJSON(request.params.arguments);
- src/index.ts:63-72 (helper)Helper method used by the handler to format the GeoJSON response according to MCP ToolResponse type.private formatToolResponse(text: string): ToolResponse { return { content: [ { type: 'text', text }, ], }; }