Skip to main content
Glama

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

Implementation Reference

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

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