Skip to content

Agentic Inventory Q&A for Maat

Maat is GÉANT's inventory of network resources and services — routers, sites, cables, optical spans, circuits, customers, and the relationships between them. It has an API, and Maat already ships an MCP server (Model Context Protocol — a standard way of exposing a system to an AI agent) that a chat UI can talk to directly. Connected that way, the chat is single-pass: one MCP tool call, then an answer. It handles straightforward lookups well and falls over on anything that requires reasoning across related objects — a real operational question is usually a multi-hop graph traversal (circuit → SAPs → interfaces → routers → sites), or a count over every object of a kind, and a one-shot lookup cannot do either reliably.

This project wraps the Maat MCP in a set of deterministic Python tools and a LangChain deep agent that plans, traverses the relationship graph, and answers with a cited, traceable reasoning path — instead of a guess dressed up as an answer.

⚠ Read-only, by design. The agent never writes to Maat. Every read goes through the MCP server; nothing talks to the Maat database or REST API directly. This is a deliberate design constraint, not a current limitation — Maat is a source of truth, and this project puts nothing at risk to it.

Why a deep agent over the existing chat lookup?

A plain chat-plus-MCP setup gives poor answers on anything beyond a single lookup, because it has no way to plan a sequence of calls or check its own work. Two examples that motivated this project:

  • "Which services are affected if this router fails?" — requires sweeping every service category that touches the router's interfaces, not just the router's immediate neighbours.
  • "Total fibre length in the network" — requires an exact pass over every object of that type, not a handful of samples extrapolated into an answer.

A single language-model call cannot do either reliably. It can, however, plan — decide which of a small set of purpose-built functions to call, read the results, and decide what to call next. That is the shape of a "deep agent": the model plans and orchestrates, and the actual traversal, counting and aggregation is done by deterministic code underneath it.

Why an agent, and not just MCP?

Version 1.0.5 of the Maat MCP server is a real step forward: exact totals, server-side counting, filters on relationships, and a maat-guide prompt that teaches a model how to use the four tools. So the question was re-opened: does the server now make the agent unnecessary? The agent and plain MCP were measured on the same questions, with the same expected answers, limits and timeouts, across 12 models:

This agent Plain MCP + the server's guide prompt Plain MCP only
Hard questions (108 stress questions) 96% 57% 52%
Randomized questions (126) 99% 96% 94%
Coverage questions (one per attribute and relationship type) 99% 93% 88%

The gap is not spread evenly. By question family:

Question family Agent Plain MCP + guide
Impact — what breaks if X fails 98% 28%
Aggregation — count, sum, rank 94% 33%
Absence — unused, orphaned, "none" 95% 36%
Path — how are A and B connected 100% 46%
Filter-and-join 97% 65%
Single-object lookup 99% 97%

💡 Where plain MCP is enough: looking up one object, or following one hop, on a strong model. Where it is not: anything that needs every object of a category (12,602 services, 11,853 resources). The server pages and caps its results, so a model working from pages undercounts or stops early — and its answer is wrong but sounds confident. On those hard questions the agent also uses roughly 6× fewer tokens per correct answer, because its tools make the pass in Python instead of in the model's context.

The outcome of the comparison: keep the agent, slimmed down to 17 tools, over MCP 1.0.5.

Architecture

   user question
        │
        ▼
   deep agent (orchestrator, LangChain deepagents)         agent/agent.py
    ├─ plan / decompose            (write_todos)
    └─ 17 purpose-built Python tools (MCP-only at runtime)  agent/tools.py
         lookup/traversal:   summarize · resolve_entity · get_entity
                              find_entities · find_connected
                              path_between · common_between
         aggregation:        rank_resource_usage · rank_service_usage
                              aggregate_characteristic · group_by_characteristic
                              relate_and_count · find_unused · filter_by_connections
                              describe_category · find_orphans
         impact:             impact_of
        │  (Streamable HTTP)
        ▼
   maat-mcp-server 1.0.5  :8002/mcp                          deploy/docker-compose.yml
        │  MAAT_BASE_URL
        ▼
   Maat API  :8080  ──▶  MongoDB :27017
        │  (schema validation on every POST)
        ▼
   schema-server (nginx) — serves the TMF schemas locally     deploy/schemas/

The agent can be reached in several ways — a command line, LangGraph Studio, as one tool inside another chat model (an MCP server on :8011), or as the model itself behind an OpenAI-compatible endpoint (:8010) — all described in Process.

  • MCP-only at runtime. The agent never calls Maat's REST API directly; every read goes through the MCP server.
  • The language model is served via an OpenAI-compatible inference gateway and is a single configuration setting (MAAT_LLM_MODEL) — the agent is deliberately not tuned to any one model. Thirteen candidate models have been benchmarked on the current server; see Lessons Learnt for what that comparison found.
  • Everything runs locally in a single docker-compose.yml: Maat + MongoDB + the MCP server + a local schema server (so Maat validates POSTs without reaching out over the network).

The two-layer design — why not hand the model the MCP directly

The MCP server already exposes generic operations (fetch services, fetch resources, summarise). The model never sees those. It only ever sees the 17 purpose-built functions, and those functions are what call the MCP:

   model  ──▶  17 purpose-built functions  ──▶  MCP server  ──▶  Maat

Asked "what exists in the inventory, and how many?", the raw MCP maat_summarize call and the agent's wrapped summarize disagree:

raw MCP maat_summarize the agent's summarize
total reported exact exact
resource categories listed 21 of 25 25 of 25
service categories listed 17 of 21 21 of 21
count in a listed category site: 500 (true: 501) site: 501

Every one of the 17 functions exists to add at least one of:

  • repair — detect and correct limits like the one above, so a partial result never passes as a complete one;
  • distillation — the raw inventory format is deeply nested and verbose; a compact shape keeps the dominant cost (what the model has to read) under control;
  • honest errors — a mistyped object type returns an error naming the valid alternatives, never an empty result that reads as "there are none";
  • exact computation — counting, ranking, totalling and proving absence happen in one deterministic pass over the whole inventory, not by the model sampling and extrapolating.

The kinds of questions it answers

kind example
Blast radius — what breaks if something fails "if this cable is cut, which customers are affected?"
Dependency / path — how two things are connected "how is this circuit connected to that site?"
Cross-layer — following the optical stack "which transport links ride over this cable?"
Superlatives — most, busiest, largest "which vendor supplies the most routers?"
Statistics — totals and averages "total fibre length in the network"
Absence — what is unused or missing "which cables carry nothing?"
Data quality — auditing the inventory itself "are any object names duplicated?"
Set questions — combinations "which sites host both a router and a DWDM node?"
Attributes on links — facts that live on a relationship "which cables have their Z-end at this site?" · "which fiber spans use buffer tube 3?"
Scoping — what exists, how much "how many services are there, by type?"

It also refuses questions the inventory cannot answer. Maat records equipment and services, not people, tickets or live traffic — so "who is on call for this circuit?" gets "Maat does not track that", rather than a related fact dressed up as an answer. When a name matches several objects (an interface name such as et-0/0/1 exists on many routers), it lists the candidates and asks which one, rather than guessing.

Design requirements

  1. Read-only, MCP-only. No risk to the source of truth; the agent reuses the sanctioned interface and never writes.
  2. Reliable logic lives in the tools, not the prompt. The model decides which tool to call; the tools do counting, ranking and traversal deterministically.
  3. One generic traversal capability, not per-type hardcoding. A new service or resource category works with no code change.
  4. An error must never look like an empty result. A silent zero is indistinguishable from a genuine "there are none" and would be reported with full confidence either way.
  5. Model-independent. The agent must work with more than one LLM vendor — a deployment cannot assume one model stays available, priced as it is, or best in class.
  6. Bounded cost and time. A question that spirals must stop with a clear message rather than consuming an unbounded budget.
  7. Work with the MCP server as it is. The agent treats the server exactly as shipped and does not assume that any reported problem will be fixed upstream.
  8. Respect each user's permissions where Maat has them. By default the agent reads Maat as one identity; an optional per-user mode checks each user's Keycloak token on every question and reads Maat as that user (see Setup).

Where this lab picks up

  • Setup — bring up the local stack (Maat + MongoDB + MCP 1.0.5 + schema server), seed a test inventory, run the agent, and serve it to a chat UI such as LibreChat.
  • Process — how the agent actually works: the 17 tools, the ways to reach it, the conversation/memory layer, what MCP 1.0.5 changed, and how it is tested and benchmarked.
  • Lessons Learnt — what broke, why, and the engineering rules that came out of fixing it — including two findings that run against intuition: a model that is perfect on single questions can still be a poor chat model, and a better MCP server did not make the agent unnecessary.