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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"geojson": "<geojson>"
},
"name": "geojson_to_kml"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geojson | Yes | GeoJSON object to convert | |
| documentName | No | Name for the KML document | GeoJSON Conversion |
| documentDescription | No | Description for the KML document | Converted from GeoJSON by GIS Format Conversion MCP |
| nameProperty | No | Property name in GeoJSON to use as KML name | name |
| descriptionProperty | No | Property name in GeoJSON to use as KML description | description |
Implementation Reference
- src/index.ts:609-647 (handler)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); - src/index.ts:224-252 (schema)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'], - src/index.ts:21-21 (helper)Import of the tokml library used by the geojson_to_kml handler for conversion.
import tokml from 'tokml';