Skip to main content
Glama

geojson_to_kml

Convert GeoJSON data to KML format for use in mapping applications. Specify document properties and field mappings during conversion.

Instructions

Convert GeoJSON to KML format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geojsonYesGeoJSON object to convert
documentNameNoName for the KML documentGeoJSON Conversion
documentDescriptionNoDescription for the KML documentConverted from GeoJSON by GIS Format Conversion MCP
namePropertyNoProperty name in GeoJSON to use as KML namename
descriptionPropertyNoProperty name in GeoJSON to use as KML descriptiondescription

Implementation Reference

  • The handler function that executes the geojson_to_kml tool, parsing arguments, calling tokml library to convert GeoJSON to KML, and formatting the response.
    async geojsonToKML(args: any): Promise<ToolResponse> { const { geojson, documentName = 'GeoJSON Conversion', documentDescription = 'Converted from GeoJSON by GIS Format Conversion MCP', nameProperty = 'name', descriptionProperty = 'description' } = args; if (!geojson) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameter: geojson' ); } try { console.error('[Converting] GeoJSON to KML'); // Set up options for tokml const options = { documentName: documentName, documentDescription: documentDescription, name: nameProperty, description: descriptionProperty }; // Convert GeoJSON to KML using tokml const kml = tokml(geojson, options); return this.formatToolResponse(kml); } catch (error) { console.error('[Error] GeoJSON to KML conversion failed:', error); throw new McpError( ErrorCode.InternalError, `GeoJSON to KML conversion failed: ${error instanceof Error ? error.message : String(error)}` ); } }
  • src/index.ts:221-253 (registration)
    Tool registration in the ListTools handler, defining name, description, and input schema for geojson_to_kml.
    { name: 'geojson_to_kml', description: 'Convert GeoJSON to KML format', inputSchema: { type: 'object', properties: { geojson: { type: 'object', description: 'GeoJSON object to convert', }, documentName: { type: 'string', description: 'Name for the KML document', default: 'GeoJSON Conversion', }, documentDescription: { type: 'string', description: 'Description for the KML document', default: 'Converted from GeoJSON by GIS Format Conversion MCP', }, nameProperty: { type: 'string', description: 'Property name in GeoJSON to use as KML name', default: 'name', }, descriptionProperty: { type: 'string', description: 'Property name in GeoJSON to use as KML description', default: 'description', } }, required: ['geojson'], },
  • src/index.ts:294-295 (registration)
    Dispatch case in CallToolRequestSchema handler that routes calls to the geojsonToKML method.
    case 'geojson_to_kml': return await this.geojsonToKML(request.params.arguments);
  • Input schema definition for the geojson_to_kml tool, specifying parameters and validation.
    inputSchema: { type: 'object', properties: { geojson: { type: 'object', description: 'GeoJSON object to convert', }, documentName: { type: 'string', description: 'Name for the KML document', default: 'GeoJSON Conversion', }, documentDescription: { type: 'string', description: 'Description for the KML document', default: 'Converted from GeoJSON by GIS Format Conversion MCP', }, nameProperty: { type: 'string', description: 'Property name in GeoJSON to use as KML name', default: 'name', }, descriptionProperty: { type: 'string', description: 'Property name in GeoJSON to use as KML description', default: 'description', } }, required: ['geojson'],
  • Import of the tokml library used by the geojson_to_kml handler for conversion.
    import tokml from 'tokml';

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