Skip to main content
Glama

Batfish Run Question

batfish_run_question

Run Batfish questions on network snapshots to return JSON-safe rows, including differential comparisons and trace-detail controls for configuration analysis.

Instructions

Run a Batfish question and return its JSON-safe rows.

  • fun is the pybatfish question function name (see batfish_list_questions); options is its keyword-argument dict.

  • snapshot runs the question on that snapshot (the session's current snapshot otherwise).

  • reference_snapshot + snapshot runs a differential question comparing the two; both are required for differential questions. In the answer, Snapshot_* columns come from snapshot (the snapshot under test) and Reference_* columns come from reference_snapshot (the baseline).

  • network points the session at a network first, if given.

  • debug=True includes the raw Batfish exception log in the response.

  • trace_detail controls trace columns (Traces, Snapshot_Traces, Reference_Traces): "summary" (default) keeps disposition, node path, and hop count; "none" drops the trace columns but keeps the trace counts; "full" returns the original hop-by-hop traces.

  • max_rows caps the number of returned rows (default 50). Use 0 for no limit; total_rows, returned_rows, and truncated report whether the cap was applied.

  • A named snapshot/reference_snapshot must exist in the network; otherwise a ValueError lists the available snapshots.

Returns {fun, snapshot, reference_snapshot, status, rows, removed_columns, total_rows, returned_rows, truncated} where rows is a list of row dicts. A differentialReachability answer also includes trace_columns, which maps Snapshot_Traces to the snapshot argument and Reference_Traces to reference_snapshot. A Batfish failure returns {status: "error", code, message, rows: []} instead of raising; known codes include SNAPSHOT_INCOMPATIBLE, INVALID_ARGUMENT, INVALID_PORT_SPEC, and BIDIRECTIONAL_REQUIRES_DST.

Header values are Batfish specifiers: srcIps/dstIps accept IPs, prefixes, node names, or named IP spaces; srcPorts/dstPorts take strings such as "443". If ipProtocols is omitted, Batfish tests ICMP, so set ipProtocols and dstPorts for service-level checks. Batfish returns representative flows for broad headers, so a prefix such as 10.0.0.0/24 may yield a network or broadcast source; prefer node names, interface locations, or explicit host IPs for realistic examples.

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": {
      "fun": "<fun>"
    },
    "name": "batfish_run_question"
  }
}

Input Schema

NameRequiredDescriptionDefault
funYes
debugNo
networkNo
optionsNo
max_rowsNo
snapshotNo
trace_detailNosummary
reference_snapshotNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so well: failures return ``{status: "error", code, message, rows: []}`` instead of raising, named error codes are listed, and a missing snapshot raises ``ValueError`` listing available snapshots. It also discloses default row capping (50, ``0`` for unlimited), truncation reporting, and Batfish's quirk of returning representative flows for broad headers.

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-loads the one-line purpose, then uses scannable bullets per parameter and a short caveat paragraph. Every bullet carries information, though the returns paragraph and header-specifier paragraph are dense and could be tightened slightly.

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 an 8-parameter, low-schema-coverage tool with no annotations, the description covers invocation, defaults, failure modes, truncation, differential semantics, and a known subtlety about flow selection. Nothing an agent needs to call it correctly appears missing.

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

Parameters5/5

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

Schema description coverage is 0% across 8 parameters, so the description must compensate and it does: every parameter is explained with meaning beyond its name, including the three ``trace_detail`` modes and which trace columns each affects. It also explains the header-value specifiers (``srcIps``/``dstPorts``) and the ICMP default when ``ipProtocols`` is omitted.

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 ('Run a Batfish question and return its JSON-safe rows') and immediately ties the required ``fun`` argument to the sibling tool ``batfish_list_questions``, so an agent knows both what it does and where to get the argument.

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 clear conditional guidance for the main modes: ``snapshot`` alone for a normal question, ``reference_snapshot`` + ``snapshot`` for differential questions, and ``network`` to point the session first. It routes to ``batfish_list_questions`` for question names, but does not explicitly say when to prefer this over assertion-running siblings.

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