Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak

extract-raster-value

Retrieve raster values at specified coordinates using a PostGIS database. Input a table name, latitude, and longitude to extract spatial data for analysis or mapping.

Instructions

Belirli koordinattaki raster değerini çıkar

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesEnlem
longitudeYesBoylam
raster_columnNoRaster kolonu (varsayılan: rast)
table_nameYesRaster tablosu

Implementation Reference

  • The handler function for the 'extract-raster-value' tool. It parses input using the schema, sanitizes table/raster column names, executes a PostGIS query using ST_Value and ST_Intersects to extract raster pixel value at given longitude/latitude coordinates, and returns the results including value, band1 value, num_bands, and intersection status.
    case "extract-raster-value": {
      const { table_name, longitude, latitude, raster_column } =
        ExtractRasterValueSchema.parse(args);
    
      const sanitizedTableName = table_name.replace(/[^a-zA-Z0-9_]/g, "");
      const sanitizedRasterColumn = raster_column || "rast";
    
      const result = await client.query(
        `
        SELECT 
          ST_Value(${sanitizedRasterColumn}, ST_SetSRID(ST_MakePoint($1, $2), 4326)) as raster_value,
          ST_Value(${sanitizedRasterColumn}, 1, ST_SetSRID(ST_MakePoint($1, $2), 4326)) as band1_value,
          ST_NumBands(${sanitizedRasterColumn}) as num_bands
        FROM ${sanitizedTableName}
        WHERE ST_Intersects(${sanitizedRasterColumn}, ST_SetSRID(ST_MakePoint($1, $2), 4326))
        LIMIT 1;
      `,
        [longitude, latitude]
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                table_name: sanitizedTableName,
                raster_column: sanitizedRasterColumn,
                coordinates: [longitude, latitude],
                raster_value: result.rows[0]?.raster_value || null,
                band1_value: result.rows[0]?.band1_value || null,
                num_bands: result.rows[0]?.num_bands || 0,
                found_intersection: result.rows.length > 0,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the 'extract-raster-value' tool: table_name (required), longitude (required), latitude (required), raster_column (optional, defaults to 'rast'). Used for validation in the handler.
    const ExtractRasterValueSchema = z.object({
      table_name: z.string(),
      longitude: z.number(),
      latitude: z.number(),
      raster_column: z.string().optional().default("rast"),
    });
  • server.ts:936-951 (registration)
    Registration of the 'extract-raster-value' tool in the ListToolsRequestHandler response. Defines the tool name, description, and inputSchema matching the Zod schema.
      name: "extract-raster-value",
      description: "Belirli koordinattaki raster değerini çıkar",
      inputSchema: {
        type: "object",
        properties: {
          table_name: { type: "string", description: "Raster tablosu" },
          longitude: { type: "number", description: "Boylam" },
          latitude: { type: "number", description: "Enlem" },
          raster_column: {
            type: "string",
            description: "Raster kolonu (varsayılan: rast)",
          },
        },
        required: ["table_name", "longitude", "latitude"],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'extract' implies a read operation, it doesn't specify whether this requires specific permissions, what happens with invalid coordinates, whether there are rate limits, or what format the extracted value returns. For a tool with 4 parameters and no annotation coverage, this is insufficient behavioral context.

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 unnecessary words. It's appropriately sized for a straightforward extraction tool and front-loads the core functionality.

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 tool with 4 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what type of value gets returned (numeric, categorical, error handling), coordinate system assumptions, or how it relates to the sibling raster-info tool. The minimal description leaves too many operational questions unanswered.

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 mentions 'specific coordinates' which aligns with latitude/longitude parameters, but doesn't add meaningful context beyond what the 100% schema coverage already provides. The schema descriptions clearly document each parameter's purpose, so the description doesn't compensate with additional semantic value about coordinate systems, raster formats, or table relationships.

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 ('extract') and target ('raster value at specific coordinates'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'raster-info' or explain what makes this extraction tool unique versus other raster or spatial analysis tools.

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 sibling tools like 'raster-info' and various geometry analysis tools available, there's no indication of whether this is for point sampling, what types of raster data it works with, or when to choose it over other spatial query methods.

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