Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak

raster-info

Retrieve detailed information about raster data stored in a PostGIS table, including metadata and spatial attributes, for efficient data analysis and management.

Instructions

Raster verisinin bilgilerini al

Input Schema

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

Implementation Reference

  • Handler implementation for 'raster-info' tool. Parses input schema, sanitizes parameters, queries PostGIS for raster metadata (num_bands, width, height, pixel sizes, SRID, envelope, tile_count), and returns JSON response.
    case "raster-info": {
      const { table_name, raster_column } = RasterInfoSchema.parse(args);
    
      const sanitizedTableName = table_name.replace(/[^a-zA-Z0-9_]/g, "");
      const sanitizedRasterColumn = raster_column || "rast";
    
      const result = await client.query(`
        SELECT 
          ST_NumBands(${sanitizedRasterColumn}) as num_bands,
          ST_Width(${sanitizedRasterColumn}) as width,
          ST_Height(${sanitizedRasterColumn}) as height,
          ST_PixelWidth(${sanitizedRasterColumn}) as pixel_width,
          ST_PixelHeight(${sanitizedRasterColumn}) as pixel_height,
          ST_SRID(${sanitizedRasterColumn}) as srid,
          ST_AsText(ST_Envelope(${sanitizedRasterColumn})) as envelope_wkt,
          COUNT(*) as tile_count
        FROM ${sanitizedTableName}
        GROUP BY 
          ST_NumBands(${sanitizedRasterColumn}),
          ST_Width(${sanitizedRasterColumn}),
          ST_Height(${sanitizedRasterColumn}),
          ST_PixelWidth(${sanitizedRasterColumn}),
          ST_PixelHeight(${sanitizedRasterColumn}),
          ST_SRID(${sanitizedRasterColumn}),
          ST_AsText(ST_Envelope(${sanitizedRasterColumn}))
        LIMIT 1;
      `);
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                table_name: sanitizedTableName,
                raster_column: sanitizedRasterColumn,
                raster_info: result.rows[0] || null,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Input schema validation using Zod for 'raster-info' tool: requires table_name, optional raster_column defaulting to 'rast'.
    const RasterInfoSchema = z.object({
      table_name: z.string(),
      raster_column: z.string().optional().default("rast"),
    });
  • server.ts:921-934 (registration)
    Registration of 'raster-info' tool in the ListTools handler, providing name, description, and input schema.
      name: "raster-info",
      description: "Raster verisinin bilgilerini al",
      inputSchema: {
        type: "object",
        properties: {
          table_name: { type: "string", description: "Raster tablosu adı" },
          raster_column: {
            type: "string",
            description: "Raster kolonu (varsayılan: rast)",
          },
        },
        required: ["table_name"],
      },
    },

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