Hide empty MAINT slots from get_server_health output by default
Reduces MCP response from ~12.3k tokens (~1000 lines) to only active servers. Empty pool slots (MAINT with no health check) are filtered by default. Added show_all parameter to optionally show all slots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,9 +195,14 @@ def register_health_tools(mcp):
|
||||
|
||||
@mcp.tool()
|
||||
def haproxy_get_server_health(
|
||||
backend: Annotated[str, Field(default="", description="Optional: Backend name to filter (e.g., 'pool_1'). Empty = all backends")] = ""
|
||||
backend: Annotated[str, Field(default="", description="Optional: Backend name to filter (e.g., 'pool_1'). Empty = all backends")] = "",
|
||||
show_all: Annotated[bool, Field(default=False, description="Show all slots including empty MAINT slots. Default: only active/configured servers")] = False,
|
||||
) -> str:
|
||||
"""Get health status of all servers (low-level view). For domain-specific, use haproxy_domain_health."""
|
||||
"""Get health status of all servers (low-level view). For domain-specific, use haproxy_domain_health.
|
||||
|
||||
By default, hides empty pool slots (MAINT with no health check) to reduce output size.
|
||||
Use show_all=True to see all slots including unconfigured ones.
|
||||
"""
|
||||
if backend and not validate_backend_name(backend):
|
||||
return "Error: Invalid backend name (use alphanumeric, underscore, hyphen only)"
|
||||
try:
|
||||
@@ -207,6 +212,9 @@ def register_health_tools(mcp):
|
||||
if stat["svname"] not in ["FRONTEND", "BACKEND", ""]:
|
||||
if backend and stat["pxname"] != backend:
|
||||
continue
|
||||
# Skip empty pool slots (MAINT with no health check = unconfigured)
|
||||
if not show_all and stat["status"] == "MAINT" and not stat["check_status"]:
|
||||
continue
|
||||
servers.append(
|
||||
f"• {stat['pxname']}/{stat['svname']}: {stat['status']} "
|
||||
f"(weight: {stat['weight']}, check: {stat['check_status']})"
|
||||
|
||||
Reference in New Issue
Block a user