Skip to main content
Glama
ronantakizawa

GIS Data Conversion MCP

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
NameRequiredDescriptionDefault
geojsonYesGeoJSON object to convert

Implementation Reference

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

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