Skip to main content
Glama

magg_check

Monitor server health status for all mounted servers and manage unresponsive ones by reporting, remounting, unmounting, or disabling them based on specified actions.

Instructions

Check health of all mounted servers and handle unresponsive ones.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoAction to take for unresponsive servers: 'report' (default), 'remount', 'unmount', or 'disable'report
timeoutNoTimeout in seconds for health check per server

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorsNo
outputNo

Implementation Reference

  • The handler function that implements the core logic of the 'magg_check' tool. It checks the health of all mounted backend servers by attempting to list their tools within a timeout period. Servers that timeout or error are marked unresponsive. Depending on the 'action' parameter, it can report only or take remedial actions like remounting, unmounting, or disabling unresponsive servers.
    async def check(
        self,
        action: Annotated[Literal["report", "remount", "unmount", "disable"], Field(
            description="Action to take for unresponsive servers: 'report' (default), 'remount', 'unmount', or 'disable'"
        )] = "report",
        timeout: Annotated[float, Field(
            description="Timeout in seconds for health check per server"
        )] = 2.5,
    ) -> MaggResponse:
        """Check health of all mounted servers and handle unresponsive ones."""
        try:
            results = {}
            unresponsive_servers = []
    
            for server_name, server_info in self.server_manager.mounted_servers.items():
                client = server_info.get('client')
                if not client:
                    results[server_name] = {"status": "error", "reason": "No client found"}
                    unresponsive_servers.append(server_name)
                    continue
    
                try:
                    async with asyncio.timeout(timeout):
                        async with client:
                            tools = await client.list_tools()
                    results[server_name] = {
                        "status": "healthy",
                        "tools_count": len(tools)
                    }
                except asyncio.TimeoutError:
                    results[server_name] = {"status": "timeout", "reason": f"No response within {timeout}s"}
                    unresponsive_servers.append(server_name)
                except Exception as e:
                    results[server_name] = {"status": "error", "reason": str(e)}
                    unresponsive_servers.append(server_name)
    
            actions_taken = []
            if unresponsive_servers and action != "report":
                if action == "disable":
                    config = self.config
                    any_changes = False
    
                    for server_name in unresponsive_servers:
                        if server_name in config.servers:
                            server = config.servers[server_name]
                            if server.enabled:
                                server.enabled = False
                                any_changes = True
                                await self.server_manager.unmount_server(server_name)
                                actions_taken.append(f"Disabled {server_name}")
                                results[server_name]["action"] = "disabled"
                            else:
                                actions_taken.append(f"{server_name} already disabled")
                                results[server_name]["action"] = "already_disabled"
                        else:
                            actions_taken.append(f"Failed to disable {server_name}")
                            results[server_name]["action"] = "disable_failed"
    
                    if any_changes:
                        if not self.save_config(config):
                            logger.error("Failed to save config after disabling servers")
    
                else:
                    for server_name in unresponsive_servers:
                        if action == "remount":
                            await self.server_manager.unmount_server(server_name)
                            server = self.config.servers.get(server_name)
                            if server and server.enabled:
                                mount_success = await self.server_manager.mount_server(server)
                                if mount_success:
                                    actions_taken.append(f"Remounted {server_name}")
                                    results[server_name]["action"] = "remounted"
                                else:
                                    actions_taken.append(f"Failed to remount {server_name}")
                                    results[server_name]["action"] = "remount_failed"
    
                        elif action == "unmount":
                            await self.server_manager.unmount_server(server_name)
                            actions_taken.append(f"Unmounted {server_name}")
                            results[server_name]["action"] = "unmounted"
    
            return MaggResponse.success({
                "servers_checked": len(results),
                "healthy": len([r for r in results.values() if r["status"] == "healthy"]),
                "unresponsive": len(unresponsive_servers),
                "results": results,
                "actions_taken": actions_taken if actions_taken else None
            })
    
        except Exception as e:
            return MaggResponse.error(f"Failed to check servers: {str(e)}")
  • Registers the 'magg_check' tool by including (self.check, f\"{self_prefix_}check\", None) in the tools list and applying the FastMCP tool decorator via the loop. self_prefix_ resolves to 'magg_' making the tool name 'magg_check'. Also wraps handlers to convert MaggResponse to JSON text content.
    tools = [
        (self.add_server, f"{self_prefix_}add_server", None),
        (self.remove_server, f"{self_prefix_}remove_server", None),
        (self.list_servers, f"{self_prefix_}list_servers", None),
        (self.enable_server, f"{self_prefix_}enable_server", None),
        (self.disable_server, f"{self_prefix_}disable_server", None),
        (self.search_servers, f"{self_prefix_}search_servers", None),
        (self.smart_configure, f"{self_prefix_}smart_configure", None),
        (self.analyze_servers, f"{self_prefix_}analyze_servers", None),
        (self.status, f"{self_prefix_}status", None),
        (self.check, f"{self_prefix_}check", None),
        (self.reload_config_tool, f"{self_prefix_}reload_config", None),
        (self.load_kit, f"{self_prefix_}load_kit", None),
        (self.unload_kit, f"{self_prefix_}unload_kit", None),
        (self.list_kits, f"{self_prefix_}list_kits", None),
        (self.kit_info, f"{self_prefix_}kit_info", None),
    ]
    
    def call_tool_wrapper(func):
        @wraps(func)
        async def wrapper(*args, **kwds):
            result = await func(*args, **kwds)
    
            if isinstance(result, MaggResponse):
                return result.as_json_text_content
    
            return result
    
        return wrapper
    
    for method, tool_name, options in tools:
        self.mcp.tool(name=tool_name, **(options or {}))(call_tool_wrapper(method))
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'handle unresponsive ones' which implies mutation capabilities, but doesn't specify what 'handle' entails (the action parameter reveals this), whether permissions are required, if operations are reversible, or what happens to responsive servers. For a tool that can perform actions like 'disable' or 'unmount', this is insufficient behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 10 words, front-loading the core functionality. Every word earns its place: 'Check health' establishes the primary action, 'of all mounted servers' defines scope, and 'and handle unresponsive ones' indicates secondary capability. There's zero waste or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values), 100% parameter schema coverage, and no annotations, the description is minimally adequate but lacks important context. For a tool that can perform potentially destructive actions like 'disable' or 'unmount', the description should provide more guidance about consequences, prerequisites, or safety considerations that aren't captured in structured fields.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the schema already documents both parameters thoroughly. The description mentions 'handle unresponsive ones' which aligns with the 'action' parameter, but adds no additional semantic context beyond what's already in the schema descriptions. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: checking health of mounted servers and handling unresponsive ones. It uses specific verbs ('check', 'handle') and identifies the resource ('mounted servers'), but doesn't explicitly differentiate from sibling tools like 'magg_status' or 'magg_analyze_servers' that might also involve server status monitoring.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools like 'magg_status', 'magg_analyze_servers', and 'magg_list_servers' that might overlap in server monitoring functionality, there's no indication of when this specific health check tool is preferred or what distinguishes it from other status-related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sitbon/magg'

If you have feedback or need assistance with the MCP directory API, please join our Discord server