Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak

find-nearby

Locate features within a specified distance from a given point using spatial queries. Enter coordinates, distance, and table name to retrieve results from a PostGIS database via the MCP protocol.

Instructions

Belirli bir noktanın çevresindeki özellikleri bul

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
distance_kmYesArama mesafesi (km)
latitudeYesMerkez nokta enlem
limitNoMaksimum sonuç sayısı (varsayılan: 10)
longitudeYesMerkez nokta boylam
table_nameYesAranacak tablo adı

Implementation Reference

  • The main handler for the 'find-nearby' tool. It parses input using FindNearbySchema, sanitizes the table name, executes a PostGIS query using ST_DWithin to find nearby geometries within distance_km and ST_Distance to compute distances, orders by distance, limits results, and returns JSON of the rows.
        case "find-nearby": {
            const { latitude, longitude, distance_km, table_name, limit } = FindNearbySchema.parse(args);
            // Tablo adını sanitize et (basit güvenlik)
            const sanitizedTableName = table_name.replace(/[^a-zA-Z0-9_]/g, '');
            const result = yield client.query(`
      SELECT 
        *,
        ST_AsGeoJSON(geom) as geometry,
        ST_Distance(
          geom, 
          ST_SetSRID(ST_MakePoint($1, $2), 4326)::geography
        ) / 1000 as distance_km
      FROM ${sanitizedTableName}
      WHERE ST_DWithin(
        geom, 
        ST_SetSRID(ST_MakePoint($1, $2), 4326)::geography, 
        $3
      )
      ORDER BY distance_km
      LIMIT $4;
    `, [longitude, latitude, distance_km * 1000, limit]);
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify(result.rows, null, 2),
                    },
                ],
            };
        }
  • Zod validation schema for the input parameters of the 'find-nearby' tool.
    const FindNearbySchema = zod_1.z.object({
        latitude: zod_1.z.number(),
        longitude: zod_1.z.number(),
        distance_km: zod_1.z.number(),
        table_name: zod_1.z.string(),
        limit: zod_1.z.number().optional().default(10),
    });
  • server.js:118-132 (registration)
    Tool registration entry in the ListTools handler, defining the name, description, and input schema for 'find-nearby'.
    {
        name: "find-nearby",
        description: "Belirli bir noktanın çevresindeki özellikleri bul",
        inputSchema: {
            type: "object",
            properties: {
                latitude: { type: "number", description: "Merkez nokta enlem" },
                longitude: { type: "number", description: "Merkez nokta boylam" },
                distance_km: { type: "number", description: "Arama mesafesi (km)" },
                table_name: { type: "string", description: "Aranacak tablo adı" },
                limit: { type: "number", description: "Maksimum sonuç sayısı (varsayılan: 10)" },
            },
            required: ["latitude", "longitude", "distance_km", "table_name"],
        },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions finding features around a point but doesn't disclose what types of features, how results are returned (e.g., list, count, geometry), whether there are rate limits, authentication needs, or error conditions. This leaves significant gaps for a tool with 5 parameters.

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 tool's function. It's appropriately concise without unnecessary words, though it could be more informative given the tool's complexity.

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?

For a spatial query tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'features' are, how results are structured, or provide context about the spatial database environment. This leaves too many unknowns 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%, providing clear documentation for all 5 parameters. The description adds no additional parameter semantics beyond implying a spatial search around coordinates. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, though the description doesn't compensate with any extra context like valid table_name examples or distance unit clarifications.

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

Purpose3/5

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

The description 'Belirli bir noktanın çevresindeki özellikleri bul' (Find features around a specific point) states a clear verb+resource action but is vague about what 'features' means. It doesn't specify whether these are geographic features, database records, or spatial objects, nor does it differentiate from siblings like 'spatial-join' or 'smart-query' which might perform similar spatial operations.

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. With siblings like 'spatial-join', 'calculate-distance', and 'smart-query' that might handle proximity or spatial queries, there's no indication of this tool's specific use case, prerequisites, or exclusions.

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