Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak

calculate-distance

Measure the distance between two geographic points using longitude and latitude coordinates with optional geographic calculations, powered by PostGIS MCP Server.

Instructions

İki nokta arasındaki mesafeyi hesapla

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
point1_latYesBirinci nokta enlem
point1_lonYesBirinci nokta boylam
point2_latYesİkinci nokta enlem
point2_lonYesİkinci nokta boylam
use_geographyNoCoğrafi hesaplama kullan (varsayılan: true)

Implementation Reference

  • Handler for calculate-distance tool: validates input with Zod schema, computes distance using PostGIS ST_Distance on two points (with optional geography casting), returns distance in meters/km and input points.
        case "calculate-distance": {
            const { point1_lon, point1_lat, point2_lon, point2_lat, use_geography } = CalculateDistanceSchema.parse(args);
            const castType = use_geography ? "::geography" : "";
            const result = yield client.query(`
      SELECT ST_Distance(
        ST_SetSRID(ST_MakePoint($1, $2), 4326)${castType},
        ST_SetSRID(ST_MakePoint($3, $4), 4326)${castType}
      ) as distance
    `, [point1_lon, point1_lat, point2_lon, point2_lat]);
            const distance = parseFloat(result.rows[0].distance);
            const response = {
                distance_meters: distance,
                distance_km: distance / 1000,
                point1: [point1_lon, point1_lat],
                point2: [point2_lon, point2_lat],
                calculation_type: use_geography ? "geography" : "geometry",
            };
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify(response, null, 2),
                    },
                ],
            };
        }
  • Zod schema for input validation of calculate-distance tool parameters.
    const CalculateDistanceSchema = zod_1.z.object({
        point1_lon: zod_1.z.number(),
        point1_lat: zod_1.z.number(),
        point2_lon: zod_1.z.number(),
        point2_lat: zod_1.z.number(),
        use_geography: zod_1.z.boolean().optional().default(true),
    });
  • server.js:103-117 (registration)
    Tool registration in ListTools response, including name, description, and MCP inputSchema.
    {
        name: "calculate-distance",
        description: "İki nokta arasındaki mesafeyi hesapla",
        inputSchema: {
            type: "object",
            properties: {
                point1_lon: { type: "number", description: "Birinci nokta boylam" },
                point1_lat: { type: "number", description: "Birinci nokta enlem" },
                point2_lon: { type: "number", description: "İkinci nokta boylam" },
                point2_lat: { type: "number", description: "İkinci nokta enlem" },
                use_geography: { type: "boolean", description: "Coğrafi hesaplama kullan (varsayılan: true)" },
            },
            required: ["point1_lon", "point1_lat", "point2_lon", "point2_lat"],
        },
    },
Behavior2/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 what the tool does (calculates distance) without mentioning any behavioral traits: e.g., what units the distance is returned in (e.g., meters, kilometers), whether it's a straight-line or geodesic calculation, performance characteristics, error handling, or how the 'use_geography' parameter affects results. This leaves significant gaps for an AI agent to understand the tool's 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, clear sentence in Turkish: 'İki nokta arasındaki mesafeyi hesapla' (Calculate the distance between two points). It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for a straightforward tool. Every part of the sentence earns its place by directly stating the tool's function.

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 the complexity (a spatial calculation tool with 5 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't cover critical context: what the output looks like (e.g., numeric distance, units), how 'use_geography' influences results, error cases (e.g., invalid coordinates), or relationships to sibling tools. For a tool with no structured behavioral data, this minimal description leaves too many unknowns 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 input schema has 100% description coverage, with clear parameter names and descriptions (e.g., 'Birinci nokta enlem' for point1_lat). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain coordinate formats (e.g., decimal degrees), range constraints, or the practical effect of 'use_geography'. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 tool's purpose: 'calculate the distance between two points' (İki nokta arasındaki mesafeyi hesapla). It specifies the verb (calculate) and resource (distance between two points), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'find-nearby' or 'geometry-info', which might also involve distance calculations in different contexts.

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. It doesn't mention sibling tools like 'find-nearby' (which might find points within a distance) or 'transform-coordinates' (which might be needed before distance calculation). There's no context about prerequisites, such as coordinate systems, or when to use the optional 'use_geography' parameter.

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