This page combines the main Maat MCP Server documentation with the two client applications that can be used with it:
Maat MCP Server User Guide
Maat MCP Server
MCP (Model Context Protocol) server for Maat inventory system, built with FastMCP in Python. Provides AI-accessible tools for querying Maat's resource and service inventory via TMF-standard APIs. It is available in the Maat MCP Server repository.
The server exposes:
- 4 MCP tools for querying/summarizing resources and services, plus serving the data-model documentation
- MCP prompt describing the Maat data model and query patterns
- Keycloak OAuth2 authentication (Client Credentials flow)
- Streamable HTTP transport for remote connectivity
- Configuration via environment variables / .env
Project Structure
mcp-server-for-maat/
.env
requirements.txt
pyproject.toml # Package metadata (editable install)
README.md
docker/
Dockerfile
src/
maat_mcp/
__init__.py
server.py # Main MCP server, tools, prompts, HTTP client
auth.py # Keycloak OAuth2 Client Credentials auth
config/
__init__.py
config.py # Environment variable loading
logging.py # Logger setup
documentation/ # Documentation catalog (see "Data-Model Documentation")
__init__.py # startup load + fallback chain
manifest.py # YAML manifest parsing and validation
source.py # GitLab fetch (manifest, repo archive, file tree)
catalog.py # topic rendering + manifest/content reconciliation
__main__.py # check / topics / show commands
prompts/
maat-guide.md # Complete guide to Maat data model and queries
# (the only prompt registered in server.py)
docs/ # Offline mirror of the documentation repository
mcp_docs_manifest.yaml # topic catalog (mirrors the repository root copy)
index.md # overview topic (categories, base fields, conventions)
relationships.md
parameter_names.md
fiber_transport_final.md
resources/ # per-category resource docs (device, interface, site, ...)
services/ # per-category service docs (l2.circuit, l3.vrf, bgp, ...)
Requirements
- Python 3.12+
- pip
Dependencies (requirements.txt):
- fastmcp - MCP server framework
- httpx - async HTTP client
- python-dotenv - environment variable loading
- PyYAML - documentation catalog manifest parsing
Installation
Create and activate a virtual environment:
Install dependencies and the package (editable mode, required for the
maat_mcp import / python -m maat_mcp.server to resolve with the src/ layout):
Configuration
Create a .env file in the project root:
# Maat API
MAAT_BASE_URL=http://localhost:8080
MAAT_TIMEOUT=60
MAAT_TLS_VERIFY=true
MAAT_RESOURCE_ENDPOINT=/resourceInventoryManagement/v4.0.0/resource
MAAT_SERVICE_ENDPOINT=/serviceInventoryManagement/v4.0.0/service
# MCP server
MCP_HOST=127.0.0.1
MCP_PORT=8002
LOG_LEVEL=INFO
# Keycloak OAuth2 (optional - enables auth when all are set)
KEYCLOAK_URL=http://localhost:8090
KEYCLOAK_REALM=MaatRealm
KEYCLOAK_CLIENT_ID=maat
KEYCLOAK_CLIENT_SECRET=your-secret
KEYCLOAK_TOKEN_REFRESH_MARGIN=30
# Data-model documentation source (optional - defaults shown)
MAAT_DOCS_ENABLED=true
MAAT_DOCS_GITLAB_URL=https://gitlab.pcss.pl
MAAT_DOCS_PROJECT=geant-netdev/ssot-maat-datamodel-community
MAAT_DOCS_REF=main
| Variable | Default | Description |
|---|---|---|
MAAT_BASE_URL |
http://localhost:8080 |
Maat API base URL |
MAAT_TIMEOUT |
60 |
HTTP timeout (seconds) |
MAAT_TLS_VERIFY |
true |
TLS certificate verification |
MAAT_RESOURCE_ENDPOINT |
/resourceInventoryManagement/v4.0.0/resource |
Resource API path |
MAAT_SERVICE_ENDPOINT |
/serviceInventoryManagement/v4.0.0/service |
Service API path |
MCP_HOST |
127.0.0.1 |
Server bind host |
MCP_PORT |
8002 |
Server bind port |
LOG_LEVEL |
INFO |
Logging level |
KEYCLOAK_URL |
(none) | Keycloak base URL (enables auth when set) |
KEYCLOAK_REALM |
(none) | Keycloak realm name |
KEYCLOAK_CLIENT_ID |
(none) | OAuth2 client ID |
KEYCLOAK_CLIENT_SECRET |
(none) | OAuth2 client secret |
KEYCLOAK_TOKEN_REFRESH_MARGIN |
30 |
Seconds before expiry to refresh token |
MAAT_DOCS_ENABLED |
true |
false skips the network and uses the bundled snapshot |
MAAT_DOCS_GITLAB_URL |
https://gitlab.pcss.pl |
GitLab instance hosting the docs |
MAAT_DOCS_PROJECT |
geant-netdev/ssot-maat-datamodel-community |
Documentation repository |
MAAT_DOCS_REF |
main |
Branch or tag to read |
MAAT_DOCS_MANIFEST_PATH |
mcp_docs_manifest.yaml |
Manifest path within that repository |
MAAT_DOCS_TIMEOUT |
30 |
HTTP timeout for documentation fetches (seconds) |
MAAT_DOCS_TLS_VERIFY |
true |
TLS verification for documentation fetches |
MAAT_DOCS_TOKEN |
(none) | GitLab token, only if the docs repository is private |
Data-Model Documentation
The documentation served by maat_get_documentation lives in an upstream GitLab
repository (ssot-maat-datamodel-community) that is re-synced daily. The server
pulls it automatically, so the files no longer have to be copied by hand.
Two separate things are loaded, from two different places:
| Source of truth | Fetched from | Fallback | |
|---|---|---|---|
| Catalog — topic names, descriptions, topic→file mapping | hand-written mcp_docs_manifest.yaml |
repository root | copy in src/maat_mcp/docs/ |
Content — the .md files |
the repository itself | archive.tar.gz, one request (~45 KB) |
mirror in src/maat_mcp/docs/ |
Descriptions are written by hand and never derived from file content — the topic list is a contract the model depends on, so it is curated rather than guessed.
Both are loaded once, at server startup, and held in memory. Changes to either require a restart. If the repository is unreachable, the server falls back to the bundled snapshot and keeps serving documentation.
Updating the catalog
When a .md file is added, removed, or moved upstream, update
mcp_docs_manifest.yaml (both copies — the repository root and
src/maat_mcp/docs/) and bump its updated field. The server logs that date at
startup, so you can always tell which version of the catalog is loaded.
To find out whether an update is needed:
python -m maat_mcp.documentation check # manifest vs. live repository
python -m maat_mcp.documentation check --scaffold # + ready-made entries to paste
python -m maat_mcp.documentation topics # topics the server exposes
python -m maat_mcp.documentation show resources/device
check reports three things: files the manifest references that no longer exist
upstream (an error — the server would fall back to the bundled snapshot), files
upstream that no topic maps (a warning — the model cannot reach them), and any
divergence between the two manifest copies. The same reconciliation runs at every
startup and is written to the log.
Running
Local
Or using FastMCP CLI:
The server starts on http://{MCP_HOST}:{MCP_PORT}/mcp using Streamable HTTP transport.
Docker
Build the image:
Run:
Docker Compose
The server can be integrated into a broader Maat deployment via docker-compose. See the docker-compose-7.yml example in the Maat docker configuration.
MCP Tools
| Tool | Description |
|---|---|
maat_get_documentation |
Get data-model documentation by topic (categories, fields, relationships). Defaults to the overview topic; call this first to learn the model before querying |
maat_summarize |
Get inventory overview with counts by category. Use this first for general questions like "What's in Maat?" |
maat_get_resources |
Query resources (devices, interfaces, sites, customers, etc.) with filtering and pagination |
maat_get_services |
Query services (L2 circuits, L3 VRFs, BGP, links, etc.) with filtering and pagination |
Query examples
# Learn the data model first (defaults to the "overview" topic)
maat_get_documentation(topic="overview")
maat_get_documentation(topic="resources/interface")
# Get overview
maat_summarize(entity_type="both")
# Get all routers
maat_get_resources(filters={"category": "device.router"})
# Get specific resource by name
maat_get_resources(filters={"name": "ptx-lab-1"})
# Get interfaces of a device
maat_get_resources(filters={"category": "interface", "resourceRelationship.resource.name": "ptx-lab-1"})
# Search by wildcard
maat_get_resources(filters={"name": "*poznan*"})
# Get L2 circuits
maat_get_services(filters={"category": "l2.circuit"})
MCP Prompt
| Prompt | Description |
|---|---|
maat-guide |
Complete guide to Maat data model, relationships, categories, and query patterns |
Authentication
When all KEYCLOAK_* environment variables are configured, the server automatically authenticates using OAuth2 Client Credentials flow. Tokens are cached and refreshed automatically before expiry (controlled by KEYCLOAK_TOKEN_REFRESH_MARGIN).
If Keycloak variables are not set, the server runs without authentication.
MCP Clients
Maat HuggingFace Chat UI
Customized fork of huggingface/chat-ui adapted for the MaatAI deployment. It is available in the Maat HuggingFace Chat UI repository.
Instead of forking the whole repository, we keep only patches (diffs) describing our customizations. A build script clones fresh upstream sources and applies those patches on top. Runtime configuration (API keys, URLs, feature flags) is injected via docker-compose.yml.
maat-ai-hf-chat-ui/
├── maat-hf-chat/ ← customizations (version-controlled)
│ ├── build.sh ← entry point — prepares chat-ui/
│ ├── patches/ ← per-feature diffs applied to upstream
│ └── docker/
│ └── docker-compose.yml ← Docker compose file
└── chat-ui/ ← build output — cloned + patched upstream (gitignored)
Quick start
Prerequisites: Git, Docker, and a bash shell (Git Bash on Windows).
# 1. Prepare chat-ui/ (clone upstream + apply patches)
cd maat-hf-chat
./build.sh --force
# 2. Build and run the Docker image
cd docker
docker compose build
docker compose up
On Windows open Git Bash (installed with Git). ./build.sh will not work in cmd or PowerShell.
What build.sh does
- Removes any existing
chat-ui/directory - Clones upstream at the pinned commit (
UPSTREAM_REFinbuild.sh) - Applies each patch from
patches/in alphabetical order
If any patch fails to apply, the script prints which one and exits with code 1 — the build is aborted before Docker touches it.
Flags
| Flag | Purpose |
|---|---|
--force |
Remove existing chat-ui/ without confirmation |
--latest |
Ignore the pinned commit, use upstream's main HEAD (riskier) |
--install |
Run npm install locally (only needed for npm run dev without Docker) |
--help |
Show usage |
Updating upstream
Upstream version is pinned via UPSTREAM_REF in maat-hf-chat/build.sh. To bump:
- Pick a new commit/tag from https://github.com/huggingface/chat-ui/commits/main
- Edit
UPSTREAM_REFinbuild.sh - Run
./build.sh --force - If all patches apply → commit the new
UPSTREAM_REF - If a patch fails → refresh it (see below), then commit
Refreshing a failing patch
When upstream changes the lines a patch touches, git apply --check fails. To refresh:
cd ../chat-ui
# Manually reapply the customization in the current source tree
# (look at maat-hf-chat/patches/<name>.patch to see what change is needed)
# Regenerate the patch from your edits
git diff -- <file1> <file2> > ../maat-hf-chat/patches/<patch-name>.patch
Then re-run ./build.sh --force — should pass this time.
Current patches
| Patch | What it does |
|---|---|
01-keycloak-logout.patch |
Adds Keycloak end-session support + logout button in nav |
03-maat-tool-preprompt.patch |
Appends MAAT workflow instructions to the MCP tool preprompt (incl. a Maat↔EventListener cross-reference block when both servers are active) |
04-allow-private-network.patch |
Removes 172.16.0.0/12 from SSRF blocklist (MCP server lives there) |
05-disable-welcome-modal.patch |
Disables the first-visit welcome modal for self-hosted deployment |
06-context-usage-indicator.patch |
Adds a context-window usage bar to the chat UI |
07-title-reasoning-fix.patch |
Strips leaked chain-of-thought from conversation titles |
08-mcp-tool-call-ui.patch |
Shows nested object args (e.g. filters) in the tool INPUT panel instead of empty {}, and flags failed tool calls with a red header + ✖ icon (incl. isError results) |
09-mcp-tool-loop-finalize.patch |
Raises the agentic tool-loop ceiling to 20 and forces a final answer (tool_choice: "none") on the last round, so gathered tool context is used instead of discarded for a plain fallback |
10-mcp-iteration-counter.patch |
Shows the current agentic tool-loop round live in the context-usage bar and tooltip (e.g. "round 3/20"); piggybacks on the per-iteration ContextUsage update. Also anglicizes the context-usage bar/tooltip labels (Context/Response/Total/Window/tokens) |
11-maat-intro-prompts.patch |
Replaces the blank empty-conversation intro with 4 clickable Maat/EventListener starter prompts that submit on click |
Configuration
All runtime configuration (API keys, URLs, MCP servers, auth) is set in the environment: section of maat-hf-chat/docker/docker-compose.yml. These override any defaults from upstream's .env.
Do not edit .env inside chat-ui/ — it comes from upstream and is overwritten on every build.
Maat AI Assistant
[WARNING!] This application is currently in a testing phase. It is not recommended for use in production environments.
Streamlit-based client application for the Maat AI system - a platform for managing network resources and services. Integrates with LLMs (via OpenAI-compatible API) and MCP (Model Context Protocol) servers. It is available in the Maat AI Assistant repository.
AI chatbot client for the MCP server. Version 1.0.2
- Connects to remote MCP servers via FastMCP (HTTP / Streamable HTTP)
- Multi-step agentic loop for tool calling (max 10 iterations per query)
- Streaming LLM responses
- Domain context loaded from MCP prompts or local markdown files
- Keycloak-based user authentication (OAuth2 Authorization Code flow)
Quick Start
Prerequisites
- Python 3.12+
- Access to an OpenAI-compatible LLM endpoint
- A running MCP server for Maat
Installation
# Clone the repository
git clone <repo-url>
cd maat_clients
# Install dependencies
cd maat_ai_assistant
pip install -r requirements.txt
Configuration
Create a .env file in the maat_ai_assistant directory:
OPENAI_API_KEY=<api-key>
OPENAI_MODEL=llama3.3:70b
OPENAI_BASE_URL=https://llm.hpc.psnc.pl/v1
MCP_URL=http://127.0.0.1:8002/mcp
For Keycloak authentication, add:
Running
Docker
docker build -f maat_ai_assistant/docker/Dockerfile -t maat-ai-assistant maat_ai_assistant/
docker run -p 8501:8501 --env-file maat_ai_assistant/.env maat-ai-assistant
The application will be available at http://localhost:8501.
Architecture
MCP Tool Calling Flow
User Query
|
v
LLM (OpenAI-compatible API)
|
v (tool_calls in response)
Agentic Loop (max 10 iterations)
|
+--> MCP Server (FastMCP client)
| |
| v
| Maat API (network resources)
| |
+<-- tool results
|
v
Final Response (streamed to user)
get_mcp_tools_cached()- fetches and caches available tools in session statemcp_tools_to_openai()- converts MCP tool schema to OpenAI function calling formatcall_model_with_mcp_tools()- agentic loop that iterates until the model stops requesting toolsmcp_call_tool_with_retry()- executes tools with timeout (30s) and retry logic (2 retries, exponential backoff)
Authentication
User authentication uses a custom OAuth2 Authorization Code flow with Keycloak. The user's access token is forwarded to the MCP server, which in turn uses it to authenticate requests to the Maat API.
MCP Domain Context
The assistant loads domain knowledge from MCP prompts to understand Maat entities and relationships:
| Prompt | Description |
|---|---|
maat-schema-reference |
Schema reference for all Maat entities - fields, types, allowed values |
maat-relationship-navigation |
Guide for navigating relationships between entities |
maat-query-cookbook |
Practical recipes for common queries and multi-step procedures |
If MCP prompts are unavailable, the app falls back to local markdown files with the same names.
Project Structure
maat_clients/
├── maat_ai_assistant/
│ ├── app.py # Main chatbot application
│ ├── requirements.txt
│ └── .env # Environment config (not in repo)
├── CLAUDE.md
└── README.md
NetBox Integration
This section describes how to deploy Maat AI Assistant together with NetBox and the netbox-mcp-server using Docker Compose.
Architecture overview
Browser (port 8501)
|
v
maat-ai-assistant (Streamlit chatbot)
|
| MCP HTTP (internal network)
v
netbox-mcp-server (MCP Server, port 9000 on host)
|
| REST API
v
netbox (NetBox instance, port 8000 on host)
Requirements
- Docker and Docker Compose
- A running
netbox-dockerstack (see netbox-community/netbox-docker) - The
netbox-mcp-serverDocker image built or pulled locally - A NetBox API token (see below)
- Access to an LLM model endpoint
Step 1 – Generate a NetBox API Token
The netbox-mcp-server authenticates with NetBox using a static API token. You must create one before starting the stack.
- Log in to the NetBox UI (e.g.
http://localhost:8000). - Navigate to Admin → API Tokens (top-right user menu → API Tokens), or go directly to
/user/api-tokens/. - Click Add Token.
- Set an expiry date (or leave blank for no expiry) and optionally restrict the token to read-only access.
- Click Save and copy the generated token string.
Keep the token secret. Anyone with this token has full API access to your NetBox instance.
Step 2 – Configure docker-compose.override.yml
Add (or extend) your docker-compose.override.yml in the netbox-docker directory with the three services below. Replace placeholder values with your own:
services:
netbox:
ports:
- "8000:8080"
environment:
SKIP_SUPERUSER: "false"
SUPERUSER_EMAIL: "admin@example.com"
SUPERUSER_NAME: "admin"
SUPERUSER_PASSWORD: "admin" # change in production
netbox-mcp-server:
image: netbox-mcp-server:latest
container_name: netbox-mcp-server
restart: unless-stopped
environment:
# NetBox URL as seen from inside the Docker network
NETBOX_URL: "http://netbox:8080/"
# Paste the API token generated in Step 1
NETBOX_TOKEN: "<your-netbox-api-token>"
TRANSPORT: "http"
HOST: "0.0.0.0"
PORT: "8000"
LOG_LEVEL: "INFO"
ports:
# MCP HTTP endpoint exposed on host (optional, useful for debugging)
- "9000:8000"
maat-ai-assistant:
image: artifactory.software.geant.org/spa-docker/maat-ai-assistant:1.0.0
ports:
- "8501:8501"
environment:
# MCP server URL (internal Docker network address)
- MCP_URL=http://netbox-mcp-server:8000/mcp
# LLM backend
- API_TYPE=openwebui
- OPENAI_BASE_URL=<your-llm-base-url>
- OPENAI_API_KEY=<your-llm-api-key>
- OPENAI_MODEL=<model-name>
- SSL_VERIFY=false
# Keycloak auth (leave empty to disable)
- KEYCLOAK_URL=
- KEYCLOAK_REALM=
- KEYCLOAK_CLIENT_ID=
restart: on-failure
Step 3 – Start the stack
Service availability:
| Service | URL |
|---|---|
| NetBox UI | http://localhost:8000 |
| netbox-mcp-server (MCP endpoint) | http://localhost:9000/mcp |
| Maat AI Assistant | http://localhost:8501 |
Environment variables reference
netbox-mcp-server
| Variable | Required | Description |
|---|---|---|
NETBOX_URL |
yes | Base URL of the NetBox instance, as seen from inside Docker (e.g. http://netbox:8080/) |
NETBOX_TOKEN |
yes | NetBox API token generated in Step 1 |
TRANSPORT |
yes | Must be http when running in a container |
HOST |
yes | Interface to listen on; use 0.0.0.0 to accept connections from other containers |
PORT |
yes | Port the MCP HTTP server listens on inside the container |
LOG_LEVEL |
no | Logging verbosity (DEBUG, INFO, WARNING). Default: INFO |
maat-ai-assistant
| Variable | Required | Description |
|---|---|---|
MCP_URL |
yes | Full URL of the MCP endpoint (e.g. http://netbox-mcp-server:8000/mcp) |
API_TYPE |
yes | Use openwebui for OpenWebUI-compatible backends |
OPENAI_BASE_URL |
yes | Base URL of LLM model API |
OPENAI_API_KEY |
yes | API key for the LLM backend |
OPENAI_MODEL |
yes | Model name to use (e.g. gpt-4o, gpt-oss_120b, llama3.3:70b) |
SSL_VERIFY |
no | Set to false to skip TLS certificate verification (useful for self-signed certs) |
KEYCLOAK_URL |
no | Keycloak base URL; leave empty to disable authentication |
KEYCLOAK_REALM |
no | Keycloak realm name |
KEYCLOAK_CLIENT_ID |
no | Keycloak client ID |
Verifying the connection
Once all containers are running you can verify the MCP bridge is working:
# Check the MCP server responds
curl http://localhost:9000/mcp
# Check container logs
docker logs netbox-mcp-server
docker logs maat-ai-assistant
Then open the assistant at http://localhost:8501 and ask a question such as:
"How many devices are currently in NetBox?"
The assistant should call the appropriate MCP tool and return a result fetched live from NetBox.