feat: include active alert count in MCP server instructions
Add InstructionsFunc callback to ServerConfig, called during each initialize handshake to generate dynamic instructions. The lab-monitoring server uses this to query Alertmanager and include a count of active non-silenced alerts, so the LLM can proactively inform the user. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -168,10 +168,15 @@ func runServe(c *cli.Context) error {
|
||||
|
||||
logger := log.New(os.Stderr, "[mcp] ", log.LstdFlags)
|
||||
config := mcp.DefaultMonitoringConfig()
|
||||
server := mcp.NewGenericServer(logger, config)
|
||||
|
||||
prom := monitoring.NewPrometheusClient(c.String("prometheus-url"))
|
||||
am := monitoring.NewAlertmanagerClient(c.String("alertmanager-url"))
|
||||
|
||||
config.InstructionsFunc = func() string {
|
||||
return monitoring.AlertSummary(am)
|
||||
}
|
||||
|
||||
server := mcp.NewGenericServer(logger, config)
|
||||
monitoring.RegisterHandlers(server, prom, am)
|
||||
|
||||
transport := c.String("transport")
|
||||
|
||||
Reference in New Issue
Block a user