grounded-kql-mcp
Integrates with Cisco IOS and Cisco ISE logs to correlate on-premises network events and support connectivity troubleshooting across on-prem devices, firewall, and Azure VNet flow data.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@grounded-kql-mcp why can't 10.0.10.15 reach 10.0.20.8 on port 443?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
grounded-kql-mcp
An MCP server that answers network questions with deterministic, pre-shaped KQL against Azure Log Analytics custom tables — correlating firewall, VNet flow, on-premises Cisco IOS and Cisco ISE logs to answer the question an engineer actually asks: why can't A reach B?
The agent never writes KQL. It picks a tool and fills typed parameters; the server renders the query. That is the whole design, and the reason this is safe to point at a production workspace.
Runs with no Azure dependency at all (stdlib only), and against a real Log Analytics workspace by flipping one environment variable.
Why it is built this way
The tool catalog is the authorization surface. There is no free-form KQL
entry point. The agent picks a tool and fills typed parameters; src/kqlmcp/query.py
renders the query. That is what keeps the blast radius of the server's identity
bounded by tools.py rather than by whatever the model decides to write — and
it is the argument that matters in a security review.
Two backends, one tool contract. local runs the same tool semantics over
generated CSVs in stdlib SQLite; azure runs the rendered KQL against a real
workspace. Both return the KQL, so a local demo shows exactly the query that
would run in production.
Credential resolution is pluggable. Today: application identity (managed
identity in Azure, az login locally) with Log Analytics Reader on one
workspace. The same tool contract accepts a per-user delegated credential for a
tenant-wide, RBAC-scoped deployment — see docs/design.md.
Related MCP server: TowerWatch Ops Agent MCP Server
Quick start (no Azure needed)
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e . # mcp is the only dependency
python data/generate_logs.py # writes data/out/*.csv
python smoke_test.py # all six scenarios should passRun the server:
python -m kqlmcp.server --transport stdio # Claude Desktop / VS Code
python -m kqlmcp.server --transport http --host 0.0.0.0 --port 8080 # any MCP client over HTTPHTTP mode serves streamable HTTP at /mcp. SSE is deprecated in the MCP spec
and deliberately not supported.
Claude Desktop
claude_desktop_config.json:
{
"mcpServers": {
"kqlmcp": {
"command": "C:\\path\\to\\grounded-kql-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "kqlmcp.server", "--transport", "stdio"],
"env": {
"PYTHONPATH": "C:\\path\\to\\grounded-kql-mcp\\src",
"KQLMCP_BACKEND": "local"
}
}
}
}VS Code
.vscode/mcp.json:
{
"servers": {
"kqlmcp": {
"type": "stdio",
"command": "${workspaceFolder}/.venv/Scripts/python.exe",
"args": ["-m", "kqlmcp.server", "--transport", "stdio"],
"env": { "PYTHONPATH": "${workspaceFolder}/src", "KQLMCP_BACKEND": "local" }
}
}
}Switching to a real workspace
pwsh ./infra/provision.ps1 -ResourceGroup rg-kqlmcp -Location westeurope
pip install -e ".[azure]"
python ./infra/ingest.py # uses the values provision.ps1 printedThen set KQLMCP_BACKEND=azure and KQLMCP_LA_WORKSPACE_ID=<customer id>.
Nothing else changes — same tools, same output shape.
The ingested data is perishable by design, and does not refresh itself.
data/generate_logs.py writes a rolling window ending at generation time,
Log Analytics rows don't move once ingested, and every tool — trace_connection
included — defaults to a 1440-minute (24h) window (D-017). Generate and ingest
right before you intend to query — data ingested more than a day earlier is
invisible to default time windows, not broken, just outside the window a
default query looks at. (The local backend doesn't have this property: its
container regenerates the dataset at every start, so it can't go stale. The
Azure path has no equivalent — there's nothing to regenerate at, since the
data already lives in the workspace.) When a hop's query does come back empty,
trace_connection now runs one bounded 30-day follow-up per miss to tell you
whether that means "never happened" or "outside your window" (D-017).
infra/ingest.py also refuses to run a second time against a workspace whose
tables already hold rows in that window — custom-table rows can't practically
be deleted, so a repeat run would silently double the dataset. Pass --append
to add anyway, or tear down and re-provision for a clean workspace.
Adding your own KQL queries
This project's tool catalog is deliberately closed: there is no free-form
KQL entry point, and every tool goes through the same typed pipeline
(QuerySpec → Filter/Agg → to_kql/to_sql in src/kqlmcp/query.py).
Adding a new query means adding a new tool function to src/kqlmcp/tools.py,
not writing raw KQL anywhere the agent can reach.
The fastest way to do that correctly is to fill in
docs/new-query-template.yaml with:
the table you want to query (must already be in
src/kqlmcp/schemas.py, or described as a new table if not)the parameters the tool should accept, and which real column/operator each one maps to
a reference KQL query you've already run by hand in Log Analytics, as proof the question is answerable against that data
Then hand the filled-in file to Claude Code (or another AI coding agent)
working in this repo, pointing it at CLAUDE.md's conventions and an
existing tool such as search_firewall_sessions as a pattern to follow.
Review the generated function before trusting it — in particular, confirm
every IP-typed parameter routes through _valid_ip() the same way
src_ip/dst_ip do elsewhere — then run
python data/generate_logs.py && python smoke_test.pyas a baseline check against the local/SQLite backend before pointing the new tool at a real workspace.
This only works for questions expressible as a single QuerySpec: a
filtered/projected row search, or a group-by aggregation, over one table. If
your reference query needs something the IR can't express — joins across
tables, window functions, multi-stage let statements — that's a sign it
needs new capability in query.py itself, not just a new tool.
The tools
Tool | Answers |
| what topology and tables exist |
| why can't A reach B — correlates ISE → IOS → firewall → NIC |
| did traffic leave / arrive at a NIC |
| what did the hub firewall decide, under which rule |
| was it stopped on-premises before reaching Azure |
| who was using this on-premises IP |
| ranked denies by rule, source, destination, application |
| top talkers by bytes |
Layout
src/kqlmcp/
topology.py reference hub-and-spoke + on-prem estate (single source of truth)
schemas.py custom table definitions -> generator, SQLite DDL, Azure table JSON
query.py query IR + KQL and SQLite renderers
tools.py the grounded tool catalog
server.py MCP server (stdio + streamable HTTP)
backends/ local_sqlite.py | azure_la.py (pluggable credential)
data/generate_logs.py seeded synthetic logs with six planted scenarios
infra/ provision.ps1, ingest.py, emit_table_schemas.py
docs/ feasibility note, demo script, new-query-template.yamlLicense
Apache-2.0. The synthetic data, topology and vendor log shapes are illustrative and do not describe any particular organisation's network.
Available Tools
8 toolsdescribe_environmentA
Describe the network topology and the available log tables. Call this first when you are unsure which addresses, VMs or tables exist.
Inputs: no named parameters. Returns: result
lookup_user_sessionsB
Cisco ISE authentication events. Give an endpoint_ip to find who was using an on-premises address, or a user_name to find their endpoints. result is Passed or Failed.
Inputs: limit, result, user_name, endpoint_ip, +1 more. Returns: result
search_firewall_sessionsC
Search PaloAlto sessions on the hub firewalls. action is allow, deny, drop or reset-both. Returns the security rule that made the decision.
Inputs: limit, action, dst_ip, src_ip, +6 more. Returns: result
search_flowsC
Search Azure VNet flow logs. direction is Inbound or Outbound; action is Allow or Deny. Answers whether traffic left or arrived at a NIC.
Inputs: limit, action, dst_ip, src_ip, +5 more. Returns: result
search_onprem_device_logsC
Search Cisco IOS syslog from on-premises routers and switches: ACL permit and deny hits, interface state changes. action is permitted or denied.
Inputs: limit, action, dst_ip, src_ip, +4 more. Returns: result
top_denied_trafficC
Rank firewall denies. group_by is one of RuleName, SrcIp, DstIp, Application, DstPort.
Inputs: limit, group_by, since_minutes. Returns: result
trace_connectionA
Trace one conversation across every log source on its path and report where it stopped. Use this for 'why can't A reach B' questions. Correlates Cisco ISE identity, on-premises Cisco IOS ACLs, hub PaloAlto firewall sessions and VNet flow logs at both NICs.
Inputs: dst_ip (required), src_ip (required), dst_port, since_minutes. Returns: result
traffic_volumeB
Top talkers by bytes from the flow logs. group_by is one of VmName, VnetName, SrcIp, DstIp, DstPort, Direction.
Inputs: limit, group_by, since_minutes. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a distinct purpose: environment discovery, connection tracing, and specialized searches on different log sources. The two flow log tools (search_flows and traffic_volume) differ in scope (detailed search vs. aggregate top talkers), but an agent might occasionally confuse them when seeking traffic summaries. Overall boundaries are clear.
Most names follow a verb_noun pattern (describe_environment, trace_connection, search_flows, etc.), but 'traffic_volume' lacks a verb and 'top_denied_traffic' uses a different structure. The inconsistency is minor and names remain readable.
8 tools are well-scoped for a network troubleshooting server covering multiple log sources. Each tool serves a distinct investigative need without redundancy, fitting the typical 3-15 range.
The set covers discovery, tracing, and searches across logs, but lacks operations for modifying or configuring network elements (e.g., create/update rules, manage devices). For a diagnostic-focused server, completeness is partial; it's read-only and missing lifecycle operations.
Maintenance
Related MCP Connectors
Find, vet, and run MCP tools through a secure audited gateway with prompt-injection risk scoring
BYOK AI router & FinOps control plane: audit token waste, check tool safety, and rank models.
Zero-trust gateway for AI agents: score tool calls, verify agent cards, enforce policy, audit.
LLM Orchestration Observability Agent
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables LLMs to answer Berserk observability questions by calling verified KQL tools instead of hand-authoring queries, with role-based tool filtering and automated query discovery.352MIT
- AlicenseAqualityDmaintenanceExposes network-monitoring tools (query metrics, analyze windows, compare, logs, status, runbooks, speed tests) as an MCP server for agentic workflows. Designed with evaluation suites, cost-aware model routing, and semantic tool retrieval.1MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to safely troubleshoot networks through read-only tools for device inventory, interface status, VLAN paths, BGP neighbors, route lookups, and interface error detection. Integrates with Microsoft Copilot Studio and Teams for natural-language-driven network diagnostics.-
- FlicenseAqualityBmaintenanceEnables LLM clients to run structured, bottom-up network diagnostics across OSI Layers 1–3, including Wi-Fi telemetry, ping checks, and runbook-based remediation.7-