Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak

create-linestring

Generate LineString geometries from coordinate arrays using the PostGIS MCP Server. Input coordinate pairs to create spatial lines for GIS applications.

Instructions

Koordinat dizisinden çizgi geometrisi oluştur

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coordinatesYesKoordinat dizisi [[lon,lat], [lon,lat], ...]
sridNoSRID (varsayılan: 4326)

Implementation Reference

  • The main handler for the 'create-linestring' tool. Parses input using CreateLineStringSchema, constructs a LINESTRING WKT from the provided coordinates, executes a PostGIS query to generate WKT, GeoJSON representations, and computes the length in meters using ST_Length on geography type.
    case "create-linestring": {
      const { coordinates, srid } = CreateLineStringSchema.parse(args);
      const coordString = coordinates
        .map((coord) => `${coord[0]} ${coord[1]}`)
        .join(", ");
    
      const result = await client.query(
        `
        SELECT 
          ST_AsText(ST_GeomFromText('LINESTRING(${coordString})', $1)) as wkt,
          ST_AsGeoJSON(ST_GeomFromText('LINESTRING(${coordString})', $1)) as geojson,
          ST_Length(ST_GeomFromText('LINESTRING(${coordString})', $1)::geography) as length_meters
      `,
        [srid]
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                wkt: result.rows[0].wkt,
                geojson: JSON.parse(result.rows[0].geojson),
                coordinates: coordinates,
                length_meters: parseFloat(result.rows[0].length_meters),
                srid: srid,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Zod schema for validating the input parameters of the create-linestring tool: array of coordinate pairs/triples and optional SRID.
    const CreateLineStringSchema = z.object({
      coordinates: z.array(z.array(z.number().min(2).max(3))),
      srid: z.number().optional().default(4326),
    });
  • server.ts:635-649 (registration)
    Tool registration in the ListToolsRequestHandler response, defining the name, description, and JSON input schema for create-linestring.
      name: "create-linestring",
      description: "Koordinat dizisinden çizgi geometrisi oluştur",
      inputSchema: {
        type: "object",
        properties: {
          coordinates: {
            type: "array",
            description: "Koordinat dizisi [[lon,lat], [lon,lat], ...]",
            items: { type: "array", items: { type: "number" } },
          },
          srid: { type: "number", description: "SRID (varsayılan: 4326)" },
        },
        required: ["coordinates"],
      },
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool creates geometry but doesn't disclose behavioral traits like whether this is a read-only or mutating operation, what happens on invalid inputs, error handling, or performance characteristics. For a creation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is a single, efficient sentence in Turkish that directly states the tool's purpose without any fluff. It is appropriately sized and front-loaded, with every word contributing to understanding the tool's function. No wasted words or unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (creating geometry from coordinates), lack of annotations, and no output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavior, usage context, and output. For a creation tool in a spatial context, more information would be helpful, but it meets the minimum viable threshold.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters (coordinates and srid). The description adds no additional meaning beyond what the schema provides—it mentions 'Koordinat dizisinden' (from coordinate array) which is already covered by the schema's description. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('oluştur' - create) and resource ('çizgi geometrisi' - line geometry) from a coordinate array. It distinguishes from siblings like create-point and create-polygon by specifying line geometry, though it doesn't explicitly contrast with them. The purpose is specific and unambiguous.

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

Usage Guidelines2/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 like create-point or create-polygon. It mentions the input (coordinate array) but gives no context about appropriate use cases, prerequisites, or exclusions. Usage is implied only through the tool name and description.

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