geojson_to_kml
Convert GeoJSON files to KML format for geographic data visualization and integration, enabling precise format transformation with customizable document name, description, and property mapping.
Instructions
Convert GeoJSON to KML format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| descriptionProperty | No | Property name in GeoJSON to use as KML description | description |
| documentDescription | No | Description for the KML document | Converted from GeoJSON by GIS Format Conversion MCP |
| documentName | No | Name for the KML document | GeoJSON Conversion |
| geojson | Yes | GeoJSON object to convert | |
| nameProperty | No | Property name in GeoJSON to use as KML name | name |
Implementation Reference
- src/index.ts:609-647 (handler)The handler function for geojson_to_kml tool. Validates input geojson, prepares options, calls tokml(geojson, options) to convert to KML, and returns ToolResponse.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:224-253 (schema)Input schema for the geojson_to_kml tool defining required geojson object and optional string parameters for KML document customization.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:221-254 (registration)Registration of geojson_to_kml tool in the tools list returned by ListToolsRequestSchema handler.{ 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)Switch case in CallToolRequestSchema handler that dispatches geojson_to_kml calls to the geojsonToKML method.case 'geojson_to_kml': return await this.geojsonToKML(request.params.arguments);