Repository navigation
feat(ai): MCP tools for the Infrastructure pages (list_infra, inspect_infra) - #1387
Conversation
list_infra lists hosts, Kubernetes pods/nodes/workloads and Docker containers closest to a limit first, with fleet counts, status filters (hot, at_limit, no_limits), pod restarts and the metrics behind each view. inspect_infra reads one entity over a window: min/avg/max/last, peak time and trend, per-pod peaks for a workload, per-mount disk use for a host, node peers, and a note when memory drops after a peak. diagnose_service now shows the workload and pods a service runs on. create_dashboard accepts resource.<key> group_by on metrics, which the query builder already supported. Adds hostFilesystemsQuery (pins state = used) and podRestartsQuery, a fixture infra world, and a tool playground that lets agents test the tools by using them (apps/ai/src/evals/playground/README.md).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 31 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note A newer push replaced |
Maple review🟢 Confidence 7/10 · likely safe to merge Adds
Findings🟠 Warning · F1 ·
|
| Issue | Service | Occurrences | File |
|---|---|---|---|
| @maple/api/vcs/VcsSourceRepositoryNotFoundError | maple-ai | 68 | apps/ai/src/mcp/tools/registry.ts |
| @maple/mcp/errors/McpQueryError | maple-chat | 42 | apps/ai/src/mcp/tools/registry.ts |
| @maple/mcp/errors/McpQueryError | maple-chat | 36 | apps/ai/src/mcp/tools/registry.ts |
| @maple/mcp/errors/McpQueryError | maple-ai | 18 | apps/ai/src/mcp/tools/registry.ts |
| @maple/api/vcs/GithubAppError | maple-chat | 14 | apps/ai/src/mcp/tools/registry.ts |
| @maple/http/errors/IntegrationsUpstreamError | maple-chat | 14 | apps/ai/src/mcp/tools/registry.ts |
| @maple/http/errors/IntegrationsUpstreamError | maple-chat | 11 | apps/ai/src/mcp/tools/registry.ts |
| @maple/mcp/errors/McpQueryError | maple-ai | 9 | apps/ai/src/mcp/tools/registry.ts |
| @maple/mcp/errors/McpQueryError | maple-ai | 9 | apps/ai/src/mcp/tools/registry.ts |
| @maple/mcp/errors/McpQueryError | maple-chat | 8 | apps/ai/src/mcp/tools/registry.ts |
After this merges, Maple checks whether they stop.
Production traffic of the changed files (last 7 days)
| File | Calls/day | Busiest operations |
|---|---|---|
apps/ai/src/mcp/lib/infra.ts |
58 | infraPresence 48/day, 2.4% errlistHosts 4/day, 6.7% errlistPods 3/day, 0.0% err |
apps/ai/src/mcp/lib/infra-inspect.ts |
6 | podInfraTimeseries 5/day, 0.0% errpodDetailSummary 1/day, 0.0% err |
Telemetry this change adds and removes (2)
- ➕ span name
McpTool.inspectInfra·apps/ai/src/mcp/tools/inspect-infra.ts:111 - ➕ span name
McpTool.listInfra·apps/ai/src/mcp/tools/list-infra.ts:108
What was checked
- New queries filter
OrgIdand the window (queries/infra.ts:240,:280) resource.<key>group_by is served bygroupByResourceAttributeKeyin the metrics builder (queries/metrics.ts:99)diagnose_servicewraps the infra lookup inEffect.result, so its failure cannot replace the diagnosis
Observability coverage: 2 of 2 changes observable
| Change | Kind | Observable | Evidence |
|---|---|---|---|
MCP tool entrypoints list_infra / inspect_infra |
Server | yes | Handlers carry the repo's Effect.fn("McpTool.listInfra") span and the dispatcher annotates maple.mcp.tool (tools/list-infra.ts:108) |
Warehouse reads added by the tools (infraPresence, listHosts, listPods, podRestarts, hostFilesystems) |
Client | yes | Each runs through executor.compiledQuery(...) with a profile and context (lib/infra.ts:54, :254) |
Files not reviewed (1)
The review ended before it read these diffs, so nothing above vouches for them.
apps/ai/src/evals/playground/tool.playground.ts
2260248 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
Pod names repeat across namespaces, so list_infra summed restarts of same-named pods into every one of their rows.
Maple review🟢 Confidence 9/10 · safe to merge The last commit fixes
Fixed since the last review
Production impactOpen errors in the changed files
After this merges, Maple checks whether they stop. Production traffic of the changed files (last 7 days)
Telemetry this change adds and removes (2)
What was checked
Observability coverage: 1 of 1 changes observable
|
What
Agents could only reach infra data through
query_data/run_sql. This adds tools built on the same queries as the Infrastructure pages.list_infra: hosts, Kubernetes pods/nodes/workloads and Docker containers, closest to a limit first. Nokindgives an overview of every kind that reports. Filters: search, namespace, node, host, workload,status(hot, at_limit, no_limits),include_ended. Shows pod restarts and names the metrics behind each view.inspect_infra: one entity over a window: min/avg/max/last, peak time, trend; a workload's per-pod peaks, a host's per-mount disk use and containers, a node's pods and peer nodes; a note when memory drops after a peak (with the recorded restart count).diagnose_service: adds the Kubernetes workload and pods the service runs on. A failed lookup is reported beside the diagnosis, never instead of it.create_dashboard: acceptsresource.<key>group_by on metrics (the query builder already did).hostFilesystemsQuery(pinsstate = 'used') andpodRestartsQuery(k8s.container.restarts, max - min per container), with benchmark builders.Testing
infra-tools.test.tsagainst a fixture infra world (src/mcp/__evals__/infra-world.ts), plus six capability tasks in the tool evals.apps/ai/scripts/tool-playground.sh,src/evals/playground/README.md): agents answer eight realistic questions using only the tools, and report every call and what confused them. Four rounds, fixing the tools between them; results are in the README.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.