Skip to main content
Glama

Analyze Territories

analyze

Computes territory statistics for one or more alignments, i.e. how balanced the territories are and how alignments compare: account counts, declared metric totals (e.g. Revenue), workload hours, balance scores, and cross-TAL comparison; hypothetical_moves previews a realign. Input: map_session_id (the open map as it is now), ts_handle, or a completed build job_id (pass tal_ids when several TALs exist). metrics: omit for every declared column, or name them; workload and account_count are always available. Workload needs dwell (dwell_time, the build's recorded dwell, or the layer's dwell_time_field); without it the result has every other statistic, no workload, and workload_omitted.ask_user to put to the user. analysis_panel=single with map_session_id fills the map dock (analysis_panel.status=pushed). Territory account_count, metric_totals, workload_total (minutes), and the dock grid cover accounts_point_layer (build point_layer), never seed, contractor, or visit layers; point_counts_by_layer counts every layer. Drive-time alignments count accounts inside each polygon. Returns a task.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "analyze"
  }
}

Input Schema

NameRequiredDescriptionDefault
scopeNoOptional — restrict analysis to a subset of parts or territories.
job_idNotask_id (same value as job_id) of a completed build or ingest task; its Territory Solution is the input.
metricsNoData field names to aggregate per territory. If omitted, server returns all available metrics.
tal_idsNoTAL IDs to analyze. Defaults to the active TAL when unambiguous.
max_depthNoOptional. For hierarchical TALs, return rollup metrics only up to this depth level. Without it, every level is returned.
ts_handleNoTerritory Solution reference (tsh_...) from a build, ingest_accounts, import_geojson, import_designer_project, or get_map_visualization; Territory Solutions are not accepted inline.
dwell_timeNo
part_layerNoPart layer name. Required when not inferable from the TAL(s). Not used for a drive-time (isochrone) TAL, which is measured by polygon.
compare_talsNoWhen true and multiple tal_ids supplied, include a cross-TAL comparison section.
analysis_panelNo
map_session_idNoOpen map session (msess_...) from get_map_visualization. Its Territory Solution is the input; omit ts_handle when set.
hypothetical_movesNoOptional. Compute impact of these hypothetical part moves without persisting any change.
visit_frequency_fieldNoOptional visit-frequency point column override for workload recompute.

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. Changed20 schema fields changed
    • addedInput schema / properties / compare_tals / description
      Added value: +"When true and multiple tal_ids supplied, include a cross-TAL comparison section."
    • changedInput schema / properties / hypothetical_moves / anyOf
      Previous value: -[
      -  {
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "items": {
      +      "additionalProperties": false,
      +      "properties": {
      +        "from_territory_id": {
      +          "type": "string"
      +        },
      +        "part_id": {
      +          "minLength": 1,
      +          "type": "string"
      +        },
      +        "to_territory_id": {
      +          "minLength": 1,
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "part_id",
      +        "to_territory_id"
      +      ],
      +      "title": "Hypothetical Part-Move for Impact Analysis",
      +      "type": "object"
      +    },
      +    "type": "array"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / properties / hypothetical_moves / description
      Added value: +"Optional. Compute impact of these hypothetical part moves without persisting any change."
    • removedInput schema / properties / hypothetical_moves / title
      Removed value: -"Hypothetical Moves"
    • addedInput schema / properties / job_id / description
      Added value: +"task_id (same value as job_id) of a completed build or ingest task; its Territory Solution is the input."
    • addedInput schema / properties / map_session_id / description
      Added value: +"Open map session (msess_...) from get_map_visualization. Its Territory Solution is the input; omit ts_handle when set."
    • addedInput schema / properties / max_depth / description
      Added value: +"Optional. For hierarchical TALs, return rollup metrics only up to this depth level. Without it, every level is returned."
    • addedInput schema / properties / metrics / description
      Added value: +"Data field names to aggregate per territory. If omitted, server returns all available metrics."
    • addedInput schema / properties / part_layer / description
      Added value: +"Part layer name. Required when not inferable from the TAL(s). Not used for a drive-time (isochrone) TAL, which is measured by polygon."
    • changedInput schema / properties / scope / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": true,
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "part_ids": {
      +        "description": "Restrict analysis to these part IDs, e.g. a map selection.",
      +        "items": {
      +          "type": "string"
      +        },
      +        "minItems": 1,
      +        "type": "array"
      +      },
      +      "territory_ids": {
      +        "description": "Restrict analysis to these territory IDs within each TAL.",
      +        "items": {
      +          "type": "string"
      +        },
      +        "minItems": 1,
      +        "type": "array"
      +      }
      +    },
      +    "title": "Optional Scope Constraint",
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / properties / scope / description
      Added value: +"Optional — restrict analysis to a subset of parts or territories."
    • removedInput schema / properties / scope / title
      Removed value: -"Scope"
    • addedInput schema / properties / tal_ids / description
      Added value: +"TAL IDs to analyze. Defaults to the active TAL when unambiguous."
    • removedInput schema / properties / ts
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Ts"
      -}
    • addedInput schema / properties / ts_handle / description
      Added value: +"Territory Solution reference (tsh_...) from a build, ingest_accounts, import_geojson, import_designer_project, or get_map_visualization; Territory Solutions are not accepted inline."
    • addedInput schema / properties / visit_frequency_field / description
      Added value: +"Optional visit-frequency point column override for workload recompute."
    • 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": {
      +      "analysis_panel": {
      +        "type": "object"
      +      },
      +      "caveats": {
      +        "items": {
      +          "type": "string"
      +        },
      +        "type": "array"
      +      },
      +      "cross_tal_comparison": {
      +        "type": "object"
      +      },
      +      "default_presentation": {
      +        "type": "object"
      +      },
      +      "do_this_next": {
      +        "type": "object"
      +      },
      +      "hypothetical_impact": {
      +        "type": "object"
      +      },
      +      "job_id": {
      +        "type": "string"
      +      },
      +      "next_action": {
      +        "type": "string"
      +      },
      +      "presentation_guidance_uri": {
      +        "type": "string"
      +      },
      +      "scoped_aggregates": {
      +        "type": "object"
      +      },
      +      "sleep_ms": {
      +        "type": "integer"
      +      },
      +      "status": {
      +        "type": "string"
      +      },
      +      "tal_analyses": {
      +        "items": {
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "task_id": {
      +        "type": "string"
      +      },
      +      "terminal": {
      +        "type": "boolean"
      +      },
      +      "territory_metric_grids": {
      +        "items": {
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "ts_identity": {
      +        "type": "object"
      +      },
      +      "workload_omitted": {
      +        "type": "object"
      +      },
      +      "workload_units": {
      +        "type": "object"
      +      }
      +    },
      +    "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: -"analyzeDictOutput"
  2. Changed1 schema field changed
    • changedInput schema / properties / dwell_time / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": true,
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": true,
      +    "description": "Onsite (dwell) time per visit: {type: 'scalar', value: <number>, unit: 'minutes'|'hours'} or {type: 'field', field: '<column>', unit: 'minutes'|'hours'}.",
      +    "properties": {
      +      "field": {
      +        "description": "Point column name holding per-account onsite time when type='field'.",
      +        "minLength": 1,
      +        "type": "string"
      +      },
      +      "type": {
      +        "description": "Dwell source: 'scalar' for a fixed per-visit duration or 'field' for an ingested point column.",
      +        "enum": [
      +          "scalar",
      +          "field"
      +        ],
      +        "type": "string"
      +      },
      +      "unit": {
      +        "default": "minutes",
      +        "description": "Time unit for value or field ('minutes' or 'hours').",
      +        "enum": [
      +          "minutes",
      +          "hours"
      +        ],
      +        "type": "string"
      +      },
      +      "value": {
      +        "description": "Confirmed onsite duration per visit when type='scalar'.",
      +        "minimum": 0,
      +        "type": "number"
      +      }
      +    },
      +    "required": [
      +      "type"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  3. Changed1 schema field changed
    • changedInput schema / properties / analysis_panel / anyOf
      Previous value: -[
      -  {
      -    "description": "single fills the open map's analysis dock with this result (needs map_session_id). comparison_slot fills the same dock (no side-by-side layout). none or omitted pushes nothing. Not the same enum as load_analysis_panel.presentation_mode (single|compare).",
      -    "enum": [
      -      "none",
      -      "single",
      -      "comparison_slot"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "description": "single fills the open map's analysis dock with this result (needs map_session_id). The dock shows one alignment at a time: with several tal_ids each TAL gets its own dock entry and the dock follows the map's active TAL. comparison_slot does the same and also returns cross_tal_comparison. none or omitted pushes nothing.",
      +    "enum": [
      +      "none",
      +      "single",
      +      "comparison_slot"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  4. Changed2 schema fields changed
    • changedInput schema / properties / analysis_panel / anyOf
      Previous value: -[
      -  {
      -    "description": "single fills the open map's analysis dock with this result (pass map_session_id); prefer it. comparison_slot fills the same dock (no side-by-side layout). none or omitted pushes nothing. Not the same enum as load_analysis_panel.presentation_mode (single|compare).",
      -    "enum": [
      -      "none",
      -      "single",
      -      "comparison_slot"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "description": "single fills the open map's analysis dock with this result (needs map_session_id). comparison_slot fills the same dock (no side-by-side layout). none or omitted pushes nothing. Not the same enum as load_analysis_panel.presentation_mode (single|compare).",
      +    "enum": [
      +      "none",
      +      "single",
      +      "comparison_slot"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / guidance_handle
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Guidance Handle"
      -}
  5. Changed1 schema field changed
    • changedInput schema / properties / analysis_panel / anyOf
      Previous value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "description": "single fills the open map's analysis dock with this result (pass map_session_id); prefer it. comparison_slot fills the same dock (no side-by-side layout). none or omitted pushes nothing. Not the same enum as load_analysis_panel.presentation_mode (single|compare).",
      +    "enum": [
      +      "none",
      +      "single",
      +      "comparison_slot"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  6. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the annotations it discloses genuinely non-obvious behavior: hypothetical_moves computes impact without persisting, analysis_panel=single pushes into the map dock with status=pushed, and a missing dwell source degrades gracefully to a full result set with no workload plus a workload_omitted.ask_user field. It also specifies exactly which layer (accounts_point_layer) the aggregates cover versus point_counts_by_layer, which prevents a serious misinterpretation.

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?

It is front-loaded with purpose and outputs, then inputs, then caveats, so the key routing information comes first. The prose is very dense and semicolon-chained, with the layer caveats and panel behavior appended as run-ons, but for a 13-parameter tool almost every clause carries distinct information and little is wasted.

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?

For a complex, zero-required-parameter analytics tool with a declared output schema, the description covers input sourcing, metric defaults, workload degradation, panel push semantics, and layer-coverage limits. An agent has everything needed to choose inputs and interpret the result without consulting other tools.

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 already 85%, yet the description adds real cross-parameter meaning: omitting metrics returns every declared column while account_count and workload always exist, workload requires dwell_time or the layer's dwell_time_field, part_layer is needed only when not inferable and is ignored for isochrone TALs, and analysis_panel=single only works with map_session_id. These dependencies are not derivable from the schema alone.

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?

The opening sentence gives a specific verb and resource ('Computes territory statistics for one or more alignments') and enumerates the outputs (account counts, metric totals, workload hours, balance scores, cross-TAL comparison). It also distinguishes itself from the sibling 'realign' by framing hypothetical_moves as a preview rather than a persisted change.

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?

It clearly states the three alternative input modes (map_session_id, ts_handle, completed build job_id) and when to pass tal_ids, plus when to omit metrics and how workload depends on dwell. What's missing is an explicit 'use realign instead when X' exclusion or a pointer to adjacent analysis siblings, so usage is well-contextualized but not fully bounded.

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