Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak

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"],
      },
    },
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the action ('create spatial index') without any information about side effects (e.g., whether it modifies database schema, requires write permissions, or affects performance), error conditions, or what happens on success/failure. For a tool that likely performs a database mutation, this lack of transparency is critical and inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single phrase that is under-specified rather than concise. While it's brief, it fails to convey essential information that would help an agent use the tool effectively. Conciseness should not come at the cost of clarity, and this description lacks the necessary detail to be considered well-structured or helpful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of creating a spatial index (likely a database mutation), the absence of annotations, and no output schema, the description is severely incomplete. It doesn't explain what a spatial index is, why one would create it, what the tool returns, or any behavioral traits. For a tool with 2 parameters and no structured safety hints, this minimal description leaves too many gaps for reliable agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter semantics beyond what the input schema provides. However, schema description coverage is 100%, with clear descriptions for both parameters ('geometry_column' and 'table_name'), including a default value for 'geometry_column'. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't need to compensate but also doesn't add value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Mekansal indeks oluştur' (Turkish for 'Create spatial index') is a tautology that essentially restates the tool name without adding meaningful context. It doesn't specify what resource it acts upon (e.g., database table), what a spatial index is, or how it differs from sibling tools like 'analyze-database' or 'get-table-info'. The purpose is minimally stated but lacks differentiation and specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., existing tables with geometry columns), use cases (e.g., performance optimization for spatial queries), or exclusions. Given sibling tools like 'analyze-database' and 'get-table-info', there's no indication of how this tool fits into the workflow, leaving the agent to guess based on the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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