Skip to main content
Glama

create-spatial-index

Generate spatial indexes for PostGIS database tables to optimize spatial queries. Specify the table name and geometry column to enhance spatial data performance.

Instructions

Mekansal indeks oluştur

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometry_columnNoGeometri kolonu (varsayılan: geom)
table_nameYesTablo adı

Implementation Reference

  • Handler function for 'create-spatial-index' tool: parses input using SpatialIndexSchema, sanitizes table and column names, creates a GIST spatial index if not exists using SQL CREATE INDEX, queries for index info, returns success or error details.
    case "create-spatial-index": { const { table_name, geometry_column } = SpatialIndexSchema.parse(args); const sanitizedTableName = table_name.replace(/[^a-zA-Z0-9_]/g, ""); const sanitizedGeomColumn = geometry_column || "geom"; const indexName = `idx_${sanitizedTableName}_${sanitizedGeomColumn}_gist`; try { await client.query(` CREATE INDEX IF NOT EXISTS ${indexName} ON ${sanitizedTableName} USING GIST (${sanitizedGeomColumn}); `); const indexInfo = await client.query( ` SELECT indexname, indexdef, tablename FROM pg_indexes WHERE indexname = $1; `, [indexName] ); return { content: [ { type: "text", text: JSON.stringify( { table_name: sanitizedTableName, geometry_column: sanitizedGeomColumn, index_name: indexName, index_created: true, index_info: indexInfo.rows[0] || null, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { table_name: sanitizedTableName, geometry_column: sanitizedGeomColumn, index_name: indexName, index_created: false, error: error instanceof Error ? error.message : "Unknown error", }, null, 2 ), }, ], }; } }
  • Zod input schema validation for create-spatial-index tool parameters: table_name (required string), geometry_column (optional string, default 'geom').
    const SpatialIndexSchema = z.object({ table_name: z.string(), geometry_column: z.string().optional().default("geom"), });
  • server.ts:904-918 (registration)
    Tool registration in ListToolsRequestHandler: defines name 'create-spatial-index', description, and inputSchema matching SpatialIndexSchema.
    name: "create-spatial-index", description: "Mekansal indeks oluştur", inputSchema: { type: "object", properties: { table_name: { type: "string", description: "Tablo adı" }, geometry_column: { type: "string", description: "Geometri kolonu (varsayılan: geom)", }, }, required: ["table_name"], }, },

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/receptopalak/postgis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server