feature/lab-monitoring #6
Reference in New Issue
Block a user
Delete Branch "feature/lab-monitoring"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
New MCP server (
lab-monitoring) for querying Prometheus and Alertmanager HTTP APIs. Unlike the existing nixpkgs/options servers, this one queries live APIs directly — no database or indexing required.Tools (8 total)
list_alertsget_alertsearch_metricsget_metric_metadataquerylist_targetslist_silencescreate_silence--enable-silencesflag)MCP core changes (
internal/mcp/server.go)ModeCustomserver mode for MCP servers without database dependenciesNewGenericServer(logger, config)constructor (no store parameter)RegisterTool(tool, handler)method for external tool registrationInstructionsFunccallback onServerConfigfor dynamic per-session instructionsDynamic alert instructions
On MCP initialization, the server calls
AlertSummary()to check for active non-silenced alerts. If any are firing, the count and severity breakdown are included in the server instructions so the LLM can proactively inform the user.Security:
create_silenceopt-inThe
create_silencetool is a write operation that can suppress alerts. It is disabled by default and requires explicit opt-in:lab-monitoring serve --enable-silencesservices.lab-monitoring.enableSilences = true;New files
internal/monitoring/— Full package with types, Prometheus client, Alertmanager client, markdown formatters, MCP handlerscmd/lab-monitoring/main.go— CLI withserve,alerts,query,targets,metricscommandsnix/lab-monitoring-module.nix— NixOS module (DynamicUser, no state directory needed)Test coverage
prometheus_test.go— httptest-based tests for all Prometheus client methodsalertmanager_test.go— httptest-based tests for all Alertmanager client methodshandlers_test.go— End-to-end handler tests through the MCP server, including tool count verification with and without silences enabledOther changes
internal/mcp/server.gochange)lab-monitoringpackage andlab-monitoring-mcpNixOS module toflake.nix.mcp.jsonwith dev config entryCLAUDE.mdandTODO.mdStats
19 files changed, ~2700 lines added