geojson_to_wkt
Convert GeoJSON objects to Well-Known Text (WKT) format for geographic data interoperability and analysis in GIS applications.
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-373 (handler)The main handler function for the 'geojson_to_wkt' tool. It validates input, uses the 'wellknown' library to convert GeoJSON to WKT, handles errors, and returns a formatted tool response.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:105-118 (registration)The tool registration entry 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 for the 'geojson_to_wkt' tool, specifying that a 'geojson' object is required.inputSchema: { type: 'object', properties: { geojson: { type: 'object', description: 'GeoJSON object to convert', }, }, required: ['geojson'], },
- src/index.ts:282-283 (handler)The switch case in the CallToolRequest handler that routes calls to the geoJSONToWKT method.case 'geojson_to_wkt': return await this.geoJSONToWKT(request.params.arguments);