Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak

simplify-geometry

Simplify complex geometries using the Douglas-Peucker algorithm, reducing vertices while preserving shape. Specify WKT geometry and tolerance for spatial data optimization.

Instructions

Geometriyi basitleştir (Douglas-Peucker algoritması)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometry_wktYesWKT formatında geometri
preserve_collapsedNoÇöken geometrileri koru
toleranceYesBasitleştirme toleransı

Implementation Reference

  • Handler for the 'simplify-geometry' tool. Parses input using SimplifyGeometrySchema, determines simplify function (ST_Simplify or ST_SimplifyPreserveTopology), executes PostGIS query to simplify geometry, computes metrics like point count and area before/after, and returns detailed JSON response including reduction ratio.
    case "simplify-geometry": {
      const { geometry_wkt, tolerance, preserve_collapsed } =
        SimplifyGeometrySchema.parse(args);
    
      const simplifyFunc = preserve_collapsed
        ? "ST_SimplifyPreserveTopology"
        : "ST_Simplify";
    
      const result = await client.query(
        `
        SELECT 
          ST_AsText(${simplifyFunc}(ST_GeomFromText($1), $2)) as simplified_wkt,
          ST_AsGeoJSON(${simplifyFunc}(ST_GeomFromText($1), $2)) as simplified_geojson,
          ST_NumPoints(ST_GeomFromText($1)) as original_points,
          ST_NumPoints(${simplifyFunc}(ST_GeomFromText($1), $2)) as simplified_points,
          ST_Area(ST_GeomFromText($1)::geography) as original_area,
          ST_Area(${simplifyFunc}(ST_GeomFromText($1), $2)::geography) as simplified_area
      `,
        [geometry_wkt, tolerance]
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                input_geometry: geometry_wkt,
                tolerance: tolerance,
                preserve_collapsed: preserve_collapsed,
                simplified_wkt: result.rows[0].simplified_wkt,
                simplified_geojson: JSON.parse(
                  result.rows[0].simplified_geojson
                ),
                original_points: result.rows[0].original_points,
                simplified_points: result.rows[0].simplified_points,
                original_area_sqmeters:
                  parseFloat(result.rows[0].original_area) || 0,
                simplified_area_sqmeters:
                  parseFloat(result.rows[0].simplified_area) || 0,
                reduction_ratio:
                  result.rows[0].original_points > 0
                    ? 1 -
                      result.rows[0].simplified_points /
                        result.rows[0].original_points
                    : 0,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Zod input schema for 'simplify-geometry' tool validating geometry_wkt (string), tolerance (number), and optional preserve_collapsed (boolean). Used for parsing arguments in the handler.
    const SimplifyGeometrySchema = z.object({
      geometry_wkt: z.string(),
      tolerance: z.number(),
      preserve_collapsed: z.boolean().optional().default(false),
    });
  • server.ts:752-772 (registration)
    Tool registration in ListToolsRequestHandler, defining name, description, and JSON inputSchema matching the Zod schema for client tool listing.
      name: "simplify-geometry",
      description: "Geometriyi basitleştir (Douglas-Peucker algoritması)",
      inputSchema: {
        type: "object",
        properties: {
          geometry_wkt: {
            type: "string",
            description: "WKT formatında geometri",
          },
          tolerance: {
            type: "number",
            description: "Basitleştirme toleransı",
          },
          preserve_collapsed: {
            type: "boolean",
            description: "Çöken geometrileri koru",
          },
        },
        required: ["geometry_wkt", "tolerance"],
      },
    },
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 mentions the algorithm but does not disclose behavioral traits such as performance implications, error handling, or output format. For a geometry processing tool with no annotations, this is a significant gap in transparency.

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

Conciseness4/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 action and algorithm. It is appropriately sized and front-loaded with the core purpose, though it could be more structured with additional context.

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

Completeness2/5

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

Given no annotations, no output schema, and a tool that performs geometry simplification (a non-trivial operation), the description is incomplete. It lacks information on what the tool returns, error conditions, or typical use cases, making it inadequate for effective 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?

Schema description coverage is 100%, so the schema already documents all parameters. The description adds no additional meaning beyond what the schema provides, such as explaining how tolerance affects simplification or what 'preserve_collapsed' entails. Baseline 3 is appropriate when 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 verb ('simplify') and resource ('geometry'), and specifies the algorithm used (Douglas-Peucker). However, it does not differentiate from sibling tools like 'validate-geometry' or 'geometry-convex-hull' that also process geometries. The purpose is clear but lacks sibling distinction.

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?

No guidance is provided on when to use this tool versus alternatives. The description does not mention use cases, prerequisites, or exclusions. Without annotations or context, it's unclear if this is for preprocessing, visualization, or other purposes.

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