wkt_to_geojson
Convert Well-Known Text (WKT) to GeoJSON format for geographic data interoperability using the GIS Data Conversion MCP.
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 core handler function that validates input, parses WKT to GeoJSON using the 'wellknown' library, formats the response, and handles errors.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:94-103 (schema)Input schema definition specifying the required 'wkt' string parameter for the tool.inputSchema: { type: 'object', properties: { wkt: { type: 'string', description: 'Well-Known Text (WKT) string to convert', }, }, required: ['wkt'], },
- src/index.ts:91-104 (registration)Tool registration in the ListTools response, defining name, description, and input schema.{ 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)Dispatcher case in CallToolRequest handler that routes requests for 'wkt_to_geojson' to the handler method.case 'wkt_to_geojson': return await this.wktToGeoJSON(request.params.arguments);
- src/index.ts:63-72 (helper)Helper method used by all tools, including wkt_to_geojson, to format the output as the expected ToolResponse structure.private formatToolResponse(text: string): ToolResponse { return { content: [ { type: 'text', text }, ], }; }