Skip to main content
Glama

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
NameRequiredDescriptionDefault
wktYesWell-Known Text (WKT) string to convert

Implementation Reference

  • 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)}` ); } }
  • 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);
  • 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 }, ], }; }

Other Tools

Related Tools

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