Skip to main content
Glama

Query Territory Parts

query_parts
Read-onlyIdempotent

Returns attributes (no geometry) for parts of a part layer listed by list_part_layers or ezt://part-layers. Takes exactly one of filter (e.g. {state_abbr: TX}) or part_ids; neither or both returns INVALID_REQUEST. Paged with page_token. TAL membership (each needs map_session_id or ts_handle inside): filter.in_tal {tal_id, territory_ids?} keeps only the parts that TAL assigns (its whole footprint, however many separate regions; territory_ids narrows to those territories and everything under them); filter.not_in_tal {tal_id} drops that TAL's parts (white space), e.g. {state_abbr: TX, not_in_tal: {...}}. Both AND with other predicates. total_count is the set size. Build from it with the same part_filter.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "part_layer": "<part_layer>"
    },
    "name": "query_parts"
  }
}

Input Schema

NameRequiredDescriptionDefault
filterNoAttribute/text/range/spatial/in_tal/not_in_tal filter. Mutually exclusive with top-level part_ids.
part_idsNoExplicit list of part IDs. Mutually exclusive with filter. Useful for validation or enrichment.
page_tokenNoPagination token from a previous response.
part_layerYesRequired part layer identifier, e.g. 'us_zips'.
max_resultsNoMaximum results per page. Server may enforce lower limits.

Output Schema

NameRequiredDescriptionDefault
okYes
errorNoPresent when ok is false.
resultNoPresent when ok is true. A submission returns the task reference (task_id, next_action, sleep_ms); the completed task result carries the remaining fields.
warningsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / filter / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": true,
      -    "minProperties": 1,
      -    "properties": {
      -      "county_name": {
      -        "type": [
      -          "string",
      -          "array"
      -        ]
      -      },
      -      "part_layer": {
      -        "type": "string"
      -      },
      -      "population": {
      -        "oneOf": [
      -          {
      -            "type": "number"
      -          },
      -          {
      -            "additionalProperties": false,
      -            "minProperties": 1,
      -            "properties": {
      -              "between": {
      -                "items": {
      -                  "type": "number"
      -                },
      -                "maxItems": 2,
      -                "minItems": 2,
      -                "type": "array"
      -              },
      -              "eq": {
      -                "type": "number"
      -              },
      -              "gt": {
      -                "type": "number"
      -              },
      -              "gte": {
      -                "type": "number"
      -              },
      -              "lt": {
      -                "type": "number"
      -              },
      -              "lte": {
      -                "type": "number"
      -              }
      -            },
      -            "type": "object"
      -          }
      -        ]
      -      },
      -      "spatial": {
      -        "additionalProperties": false,
      -        "oneOf": [
      -          {
      -            "required": [
      -              "bbox"
      -            ]
      -          },
      -          {
      -            "required": [
      -              "geometry"
      -            ]
      -          }
      -        ],
      -        "properties": {
      -          "bbox": {
      -            "description": "[min_lon, min_lat, max_lon, max_lat] in EPSG:4326.",
      -            "items": {
      -              "type": "number"
      -            },
      -            "maxItems": 4,
      -            "minItems": 4,
      -            "type": "array"
      -          },
      -          "geometry": {
      -            "description": "GeoJSON Polygon or MultiPolygon in EPSG:4326.",
      -            "type": "object"
      -          },
      -          "operator": {
      -            "enum": [
      -              "intersects",
      -              "within",
      -              "contains"
      -            ],
      -            "type": "string"
      -          }
      -        },
      -        "required": [
      -          "operator"
      -        ],
      -        "type": "object"
      -      },
      -      "state_abbr": {
      -        "type": [
      -          "string",
      -          "array"
      -        ]
      -      },
      -      "territory": {
      -        "additionalProperties": false,
      -        "oneOf": [
      -          {
      -            "required": [
      -              "ts_handle"
      -            ]
      -          },
      -          {
      -            "required": [
      -              "map_session_id"
      -            ]
      -          }
      -        ],
      -        "properties": {
      -          "include_descendants": {
      -            "default": true,
      -            "description": "When true, rollup territories include descendant leaf territory part_ids.",
      -            "type": "boolean"
      -          },
      -          "map_session_id": {
      -            "description": "Open map session whose Territory Solution holds the TAL.",
      -            "minLength": 1,
      -            "type": "string"
      -          },
      -          "tal_id": {
      -            "minLength": 1,
      -            "type": "string"
      -          },
      -          "territory_id": {
      -            "minLength": 1,
      -            "type": "string"
      -          },
      -          "ts_handle": {
      -            "description": "Territory Solution reference (tsh_...) holding the TAL (no inline TS).",
      -            "minLength": 1,
      -            "type": "string"
      -          }
      -        },
      -        "required": [
      -          "tal_id",
      -          "territory_id"
      -        ],
      -        "type": "object"
      -      },
      -      "text": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "case_sensitive": {
      -            "default": false,
      -            "type": "boolean"
      -          },
      -          "field": {
      -            "description": "Safe text field to search. Defaults to the public part ID column.",
      -            "type": "string"
      -          },
      -          "mode": {
      -            "default": "prefix",
      -            "enum": [
      -              "prefix",
      -              "contains",
      -              "exact"
      -            ],
      -            "type": "string"
      -          },
      -          "value": {
      -            "minLength": 1,
      -            "type": "string"
      -          }
      -        },
      -        "required": [
      -          "value"
      -        ],
      -        "type": "object"
      -      }
      -    },
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": true,
      +    "minProperties": 1,
      +    "properties": {
      +      "county_name": {
      +        "type": [
      +          "string",
      +          "array"
      +        ]
      +      },
      +      "in_tal": {
      +        "additionalProperties": false,
      +        "description": "Keep only the parts assigned to a leaf territory of tal_id: the TAL's whole footprint, however many separate regions it has. ANDed with the other predicates (alone it is exactly that footprint). The TAL must use the same part_layer and hold parts. query_parts needs ts_handle or map_session_id here; builds read the TAL from the build's own Territory Solution.",
      +        "properties": {
      +          "map_session_id": {
      +            "description": "query_parts only: open map session whose Territory Solution holds the TAL.",
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "tal_id": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "territory_ids": {
      +            "description": "Narrow to these territory_id values (not display labels); a rollup includes every leaf below it. Unknown ids return UNKNOWN_TERRITORY_ID with available_territory_ids.",
      +            "items": {
      +              "minLength": 1,
      +              "type": "string"
      +            },
      +            "minItems": 1,
      +            "type": "array"
      +          },
      +          "ts_handle": {
      +            "description": "query_parts only: Territory Solution reference (tsh_...) holding the TAL.",
      +            "minLength": 1,
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "tal_id"
      +        ],
      +        "type": "object"
      +      },
      +      "not_in_tal": {
      +        "additionalProperties": false,
      +        "description": "White space: drop every part assigned to a leaf territory of tal_id from whatever the other predicates select (the whole layer when alone). The TAL must use the same part_layer. query_parts needs ts_handle or map_session_id here; builds read the TAL from the build's own Territory Solution.",
      +        "properties": {
      +          "map_session_id": {
      +            "description": "query_parts only: open map session whose Territory Solution holds the TAL.",
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "tal_id": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "ts_handle": {
      +            "description": "query_parts only: Territory Solution reference (tsh_...) holding the TAL.",
      +            "minLength": 1,
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "tal_id"
      +        ],
      +        "type": "object"
      +      },
      +      "part_layer": {
      +        "type": "string"
      +      },
      +      "population": {
      +        "oneOf": [
      +          {
      +            "type": "number"
      +          },
      +          {
      +            "additionalProperties": false,
      +            "minProperties": 1,
      +            "properties": {
      +              "between": {
      +                "items": {
      +                  "type": "number"
      +                },
      +                "maxItems": 2,
      +                "minItems": 2,
      +                "type": "array"
      +              },
      +              "eq": {
      +                "type": "number"
      +              },
      +              "gt": {
      +                "type": "number"
      +              },
      +              "gte": {
      +                "type": "number"
      +              },
      +              "lt": {
      +                "type": "number"
      +              },
      +              "lte": {
      +                "type": "number"
      +              }
      +            },
      +            "type": "object"
      +          }
      +        ]
      +      },
      +      "selection_task_id": {
      +        "description": "Builds only (auto_build, account_build, seed_build): a committed request_part_selection task (psel_...) whose part_ids become the scope; it is the only key in that part_filter.",
      +        "minLength": 1,
      +        "type": "string"
      +      },
      +      "spatial": {
      +        "additionalProperties": false,
      +        "oneOf": [
      +          {
      +            "required": [
      +              "bbox"
      +            ]
      +          },
      +          {
      +            "required": [
      +              "geometry"
      +            ]
      +          }
      +        ],
      +        "properties": {
      +          "bbox": {
      +            "description": "[min_lon, min_lat, max_lon, max_lat] in EPSG:4326.",
      +            "items": {
      +              "type": "number"
      +            },
      +            "maxItems": 4,
      +            "minItems": 4,
      +            "type": "array"
      +          },
      +          "geometry": {
      +            "description": "GeoJSON Polygon or MultiPolygon in EPSG:4326.",
      +            "type": "object"
      +          },
      +          "operator": {
      +            "enum": [
      +              "intersects",
      +              "within",
      +              "contains"
      +            ],
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "operator"
      +        ],
      +        "type": "object"
      +      },
      +      "state_abbr": {
      +        "type": [
      +          "string",
      +          "array"
      +        ]
      +      },
      +      "text": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "case_sensitive": {
      +            "default": false,
      +            "type": "boolean"
      +          },
      +          "field": {
      +            "description": "Safe text field to search. Defaults to the public part ID column.",
      +            "type": "string"
      +          },
      +          "mode": {
      +            "default": "prefix",
      +            "enum": [
      +              "prefix",
      +              "contains",
      +              "exact"
      +            ],
      +            "type": "string"
      +          },
      +          "value": {
      +            "minLength": 1,
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "value"
      +        ],
      +        "type": "object"
      +      }
      +    },
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / filter / description
      Previous value: -"Attribute/text/range/spatial/territory filter. Mutually exclusive with top-level part_ids."New value: +"Attribute/text/range/spatial/in_tal/not_in_tal filter. Mutually exclusive with top-level part_ids."
  2. Changed11 schema fields changed
    • changedInput schema / properties / filter / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": true,
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": true,
      +    "minProperties": 1,
      +    "properties": {
      +      "county_name": {
      +        "type": [
      +          "string",
      +          "array"
      +        ]
      +      },
      +      "part_layer": {
      +        "type": "string"
      +      },
      +      "population": {
      +        "oneOf": [
      +          {
      +            "type": "number"
      +          },
      +          {
      +            "additionalProperties": false,
      +            "minProperties": 1,
      +            "properties": {
      +              "between": {
      +                "items": {
      +                  "type": "number"
      +                },
      +                "maxItems": 2,
      +                "minItems": 2,
      +                "type": "array"
      +              },
      +              "eq": {
      +                "type": "number"
      +              },
      +              "gt": {
      +                "type": "number"
      +              },
      +              "gte": {
      +                "type": "number"
      +              },
      +              "lt": {
      +                "type": "number"
      +              },
      +              "lte": {
      +                "type": "number"
      +              }
      +            },
      +            "type": "object"
      +          }
      +        ]
      +      },
      +      "spatial": {
      +        "additionalProperties": false,
      +        "oneOf": [
      +          {
      +            "required": [
      +              "bbox"
      +            ]
      +          },
      +          {
      +            "required": [
      +              "geometry"
      +            ]
      +          }
      +        ],
      +        "properties": {
      +          "bbox": {
      +            "description": "[min_lon, min_lat, max_lon, max_lat] in EPSG:4326.",
      +            "items": {
      +              "type": "number"
      +            },
      +            "maxItems": 4,
      +            "minItems": 4,
      +            "type": "array"
      +          },
      +          "geometry": {
      +            "description": "GeoJSON Polygon or MultiPolygon in EPSG:4326.",
      +            "type": "object"
      +          },
      +          "operator": {
      +            "enum": [
      +              "intersects",
      +              "within",
      +              "contains"
      +            ],
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "operator"
      +        ],
      +        "type": "object"
      +      },
      +      "state_abbr": {
      +        "type": [
      +          "string",
      +          "array"
      +        ]
      +      },
      +      "territory": {
      +        "additionalProperties": false,
      +        "oneOf": [
      +          {
      +            "required": [
      +              "ts_handle"
      +            ]
      +          },
      +          {
      +            "required": [
      +              "map_session_id"
      +            ]
      +          }
      +        ],
      +        "properties": {
      +          "include_descendants": {
      +            "default": true,
      +            "description": "When true, rollup territories include descendant leaf territory part_ids.",
      +            "type": "boolean"
      +          },
      +          "map_session_id": {
      +            "description": "Open map session whose Territory Solution holds the TAL.",
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "tal_id": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "territory_id": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "ts_handle": {
      +            "description": "Territory Solution reference (tsh_...) holding the TAL (no inline TS).",
      +            "minLength": 1,
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "tal_id",
      +          "territory_id"
      +        ],
      +        "type": "object"
      +      },
      +      "text": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "case_sensitive": {
      +            "default": false,
      +            "type": "boolean"
      +          },
      +          "field": {
      +            "description": "Safe text field to search. Defaults to the public part ID column.",
      +            "type": "string"
      +          },
      +          "mode": {
      +            "default": "prefix",
      +            "enum": [
      +              "prefix",
      +              "contains",
      +              "exact"
      +            ],
      +            "type": "string"
      +          },
      +          "value": {
      +            "minLength": 1,
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "value"
      +        ],
      +        "type": "object"
      +      }
      +    },
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / properties / filter / description
      Added value: +"Attribute/text/range/spatial/territory filter. Mutually exclusive with top-level part_ids."
    • removedInput schema / properties / filter / title
      Removed value: -"Filter"
    • addedInput schema / properties / max_results / description
      Added value: +"Maximum results per page. Server may enforce lower limits."
    • addedInput schema / properties / page_token / description
      Added value: +"Pagination token from a previous response."
    • addedInput schema / properties / part_ids / description
      Added value: +"Explicit list of part IDs. Mutually exclusive with filter. Useful for validation or enrichment."
    • addedInput schema / properties / part_layer / description
      Added value: +"Required part layer identifier, e.g. 'us_zips'."
    • removedOutput schema / additionalProperties
      Removed value: -true
    • addedOutput schema / properties
      Added value: +{
      +  "error": {
      +    "description": "Present when ok is false.",
      +    "properties": {
      +      "ask_user": {
      +        "items": {
      +          "type": "string"
      +        },
      +        "type": "array"
      +      },
      +      "code": {
      +        "type": "string"
      +      },
      +      "details": {
      +        "type": "object"
      +      },
      +      "do_this_next": {
      +        "type": "object"
      +      },
      +      "message": {
      +        "type": "string"
      +      }
      +    },
      +    "type": "object"
      +  },
      +  "ok": {
      +    "type": "boolean"
      +  },
      +  "result": {
      +    "description": "Present when ok is true. A submission returns the task reference (task_id, next_action, sleep_ms); the completed task result carries the remaining fields.",
      +    "properties": {
      +      "do_this_next": {
      +        "type": "object"
      +      },
      +      "job_id": {
      +        "type": "string"
      +      },
      +      "next_action": {
      +        "type": "string"
      +      },
      +      "next_page_token": {
      +        "type": "string"
      +      },
      +      "part_layer": {
      +        "type": "string"
      +      },
      +      "parts": {
      +        "items": {
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "sleep_ms": {
      +        "type": "integer"
      +      },
      +      "status": {
      +        "type": "string"
      +      },
      +      "task_id": {
      +        "type": "string"
      +      },
      +      "terminal": {
      +        "type": "boolean"
      +      },
      +      "total_count": {
      +        "type": "integer"
      +      },
      +      "warnings": {
      +        "items": {
      +          "type": "object"
      +        },
      +        "type": "array"
      +      }
      +    },
      +    "type": "object"
      +  },
      +  "warnings": {
      +    "items": {
      +      "properties": {
      +        "code": {
      +          "type": "string"
      +        },
      +        "message": {
      +          "type": "string"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "type": "array"
      +  }
      +}
    • addedOutput schema / required
      Added value: +[
      +  "ok"
      +]
    • removedOutput schema / title
      Removed value: -"query_partsDictOutput"
  3. Changed1 schema field changed
    • removedInput schema / properties / guidance_handle
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Guidance Handle"
      -}
  4. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnly/idempotent/non-destructive, so credit is for added context: the description discloses the no-geometry payload, the mutual-exclusion failure mode, pagination via page_token, the meaning of total_count, and the TAL footprint vs white-space semantics including the required ts_handle/map_session_id. That is substantive behavior beyond the annotations, though the error surface is only partially enumerated (INVALID_REQUEST, UNKNOWN_TERRITORY_ID).

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?

Front-loaded with the core purpose, then constraints, then TAL semantics and the build-workflow hint; nearly every clause carries operational information. It is dense to the point of being a wall of text, and the TAL explanation repeats itself slightly, but nothing is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the description need not explain return shape, yet it still flags total_count and the absence of geometry. Combined with the exclusivity rule, paging, and TAL requirements, an agent has everything needed to call this correctly without opening the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3; the description earns more by explaining the filter/part_ids exclusivity contract, what in_tal and not_in_tal mean functionally (whole footprint however many separate regions, white space, ANDed with other predicates), and how territory_ids rolls up leaves. Much of the nested TAL detail is duplicated in the schema's own property descriptions, which limits the added value.

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

Purpose5/5

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

States a specific verb and resource ('Returns attributes (no geometry) for parts of a part layer') and immediately scopes where layers come from ('listed by list_part_layers or ezt://part-layers'), which separates it from the sibling that enumerates layers. The no-geometry qualifier alone tells an agent this is an attribute lookup, not a spatial render or selection tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives hard usage rules: exactly one of filter or part_ids, neither or both yields INVALID_REQUEST, and 'Build from it with the same part_filter' links the tool to the build workflow. It stops short of explicitly contrasting with siblings that also return parts (e.g. get_part_selection) for scope selection, so the routing guidance is strong but not exhaustive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources