Skip to main content
Glama

gva_query

Query geographic data from the Valencian Community's GIS layer using SQL-like filters, field selection, and pagination controls to retrieve land activity information.

Instructions

Query features from the GVA GIS layer with SQL-like WHERE clause and optional parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
whereNoSQL WHERE clause (e.g., '1=1' for all, 'MUNICIPIO="Valencia"')1=1
out_fieldsNoComma-separated field names or '*' for all fields*
return_geometryNoWhether to return geometry data
result_record_countNoMaximum number of records to return
result_offsetNoOffset for pagination

Implementation Reference

  • The handler function for the 'gva_query' tool. It constructs the query parameters from the input arguments and makes an HTTP request to the ArcGIS FeatureServer /query endpoint, returning the JSON response as text content.
    elif name == "gva_query":
        # Query features
        url = f"{BASE_URL}/{LAYER_ID}/query"
        params = {
            'where': arguments.get('where', '1=1'),
            'outFields': arguments.get('out_fields', '*'),
            'returnGeometry': str(arguments.get('return_geometry', True)).lower(),
            'resultRecordCount': arguments.get('result_record_count', 10),
            'resultOffset': arguments.get('result_offset', 0),
            'f': 'json'
        }
    
        data = make_request(url, params)
    
        return [TextContent(
            type="text",
            text=json.dumps(data, indent=2, ensure_ascii=False)
        )]
  • Registration of the 'gva_query' tool in the list_tools function, including its description and detailed input schema.
    Tool(
        name="gva_query",
        description="Query features from the GVA GIS layer with SQL-like WHERE clause and optional parameters",
        inputSchema={
            "type": "object",
            "properties": {
                "where": {
                    "type": "string",
                    "description": "SQL WHERE clause (e.g., '1=1' for all, 'MUNICIPIO=\"Valencia\"')",
                    "default": "1=1"
                },
                "out_fields": {
                    "type": "string",
                    "description": "Comma-separated field names or '*' for all fields",
                    "default": "*"
                },
                "return_geometry": {
                    "type": "boolean",
                    "description": "Whether to return geometry data",
                    "default": True
                },
                "result_record_count": {
                    "type": "integer",
                    "description": "Maximum number of records to return",
                    "default": 10
                },
                "result_offset": {
                    "type": "integer",
                    "description": "Offset for pagination",
                    "default": 0
                }
            },
            "required": []
        }
    ),
  • The TypeScript handler for the 'gva_query' tool. Constructs query parameters and performs an HTTP request to the ArcGIS FeatureServer /query endpoint, returning the JSON response.
    case "gva_query": {
      // Query features
      const queryArgs = args as QueryArguments;
      const url = `${BASE_URL}/${LAYER_ID}/query`;
      const params: RequestParams = {
        where: queryArgs.where || "1=1",
        outFields: queryArgs.out_fields || "*",
        returnGeometry: String(queryArgs.return_geometry ?? true).toLowerCase(),
        resultRecordCount: queryArgs.result_record_count || 10,
        resultOffset: queryArgs.result_offset || 0,
        f: "json",
      };
    
      const data = await makeRequest(url, params);
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(data, null, 2),
          },
        ],
      };
    }
  • Registration of the 'gva_query' tool in the TypeScript list tools handler, including description and input schema.
    {
      name: "gva_query",
      description: "Query features from the GVA GIS layer with SQL-like WHERE clause and optional parameters",
      inputSchema: {
        type: "object",
        properties: {
          where: {
            type: "string",
            description: 'SQL WHERE clause (e.g., "1=1" for all, "MUNICIPIO=\'Valencia\'")',
            default: "1=1",
          },
          out_fields: {
            type: "string",
            description: "Comma-separated field names or '*' for all fields",
            default: "*",
          },
          return_geometry: {
            type: "boolean",
            description: "Whether to return geometry data",
            default: true,
          },
          result_record_count: {
            type: "number",
            description: "Maximum number of records to return",
            default: 10,
          },
          result_offset: {
            type: "number",
            description: "Offset for pagination",
            default: 0,
          },
        },
        required: [],
      },
    },
  • Shared helper function used by gva_query (and other tools) to perform HTTP requests to the ArcGIS API with browser-like headers to avoid blocking.
    def make_request(url: str, params: dict) -> dict:
        """Make HTTP request to the API with browser-like headers"""
        headers = {
            'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
            'Accept': 'application/json, text/plain, */*',
            'Accept-Language': 'es-ES,es;q=0.9,en;q=0.8'
        }
    
        try:
            response = requests.get(url, params=params, headers=headers, timeout=30)
            response.raise_for_status()
            return response.json()
        except requests.RequestException as e:
            logger.error(f"Request failed: {e}")
            raise

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/pepo1275/mcp4gva'

If you have feedback or need assistance with the MCP directory API, please join our Discord server