Skip to main content
Glama

get_gateway_status

Retrieve gateway status, configuration state, and hot reload diagnostics. Requires debug mode enabled.

Instructions

Get gateway status, configuration state, and hot reload diagnostics.

NOTE: Only available when debug mode is enabled.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idNoYour agent identifier (leave empty if not provided to you)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual implementation of the get_gateway_status tool. It collects reload status (with datetime→ISO conversion), policy engine state (agent counts/IDs/defaults), available servers from ProxyManager, config file paths via get_stored_config_paths(), and returns a GatewayStatusResponse dict.
    async def get_gateway_status(
        agent_id: Annotated[Optional[str], "Your agent identifier (leave empty if not provided to you)"] = None
    ) -> dict:
        """Get gateway status, configuration state, and hot reload diagnostics.
    
        NOTE: Only available when debug mode is enabled."""
        # Defensive check (middleware should have resolved agent_id)
        if agent_id is None:
            raise ToolError("Internal error: agent_id not resolved by middleware")
    
        # Get reload status if available
        reload_status = None
        if _get_reload_status_fn:
            try:
                reload_status = _get_reload_status_fn()
                # Convert datetime objects to ISO strings for JSON serialization
                if reload_status:
                    for config_type in ["mcp_config", "gateway_rules"]:
                        if config_type in reload_status:
                            for key in ["last_attempt", "last_success"]:
                                if reload_status[config_type].get(key):
                                    reload_status[config_type][key] = reload_status[config_type][key].isoformat()
            except Exception:
                reload_status = {"error": "Failed to retrieve reload status"}
    
        # Get PolicyEngine state
        policy_state = {}
        if _policy_engine:
            try:
                policy_state = {
                    "total_agents": len(_policy_engine.agents),
                    "agent_ids": list(_policy_engine.agents.keys()),
                    "defaults": _policy_engine.defaults,
                }
            except Exception:
                policy_state = {"error": "Failed to retrieve policy state"}
    
        # Get available servers from ProxyManager (reflects hot-reload changes)
        available_servers = []
        if _proxy_manager:
            try:
                available_servers = _proxy_manager.get_all_servers()
            except Exception:
                available_servers = []
    
        # Get config file paths from src/config.py
        config_paths = {}
        try:
            from src.config import get_stored_config_paths
            mcp_path, rules_path = get_stored_config_paths()
            config_paths = {
                "mcp_config": mcp_path,
                "gateway_rules": rules_path,
            }
        except Exception:
            config_paths = {"error": "Failed to retrieve config paths"}
    
        return GatewayStatusResponse(
            reload_status=reload_status,
            policy_state=policy_state,
            available_servers=available_servers,
            config_paths=config_paths,
            message="Gateway is operational. Check reload_status for hot reload health."
        ).model_dump()
  • GatewayStatusResponse Pydantic model defining the response schema for get_gateway_status: reload_status, policy_state, available_servers, config_paths, and message.
    class GatewayStatusResponse(BaseModel):
        """Response from get_gateway_status (debug tool)."""
        reload_status: Annotated[Optional[dict], Field(description="Hot reload history with timestamps and errors")]
        policy_state: Annotated[dict, Field(description="Policy engine configuration (agent count, defaults)")]
        available_servers: Annotated[list[str], Field(description="All configured server names")]
        config_paths: Annotated[dict, Field(description="File paths to gateway configuration")]
        message: Annotated[str, Field(description="Summary status message")]
  • src/gateway.py:151-161 (registration)
    Registration of get_gateway_status as a gateway tool via gateway.tool(get_gateway_status). Only called when debug_mode=True.
    def _register_debug_tools():
        """Register debug-only tools when debug mode is enabled.
    
        This function is called by initialize_gateway() when debug_mode=True.
        It registers additional diagnostic tools that should only be available
        in debug/development environments.
        """
        # Register get_gateway_status tool
        # Note: The function itself is always defined (for testing), but only
        # registered as a gateway tool when debug mode is enabled
        gateway.tool(get_gateway_status)
  • initialize_gateway() accepts debug_mode flag and conditionally calls _register_debug_tools() to expose the get_gateway_status tool.
    def initialize_gateway(
        policy_engine: PolicyEngine,
        mcp_config: dict,
        proxy_manager: ProxyManager | None = None,
        check_config_changes_fn: Any = None,
        get_reload_status_fn: Any = None,
        default_agent_id: str | None = None,
        debug_mode: bool = False
    ):
        """Initialize gateway with policy engine, MCP config, and proxy manager.
    
        This must be called before the gateway starts accepting requests.
    
        Args:
            policy_engine: PolicyEngine instance for access control
            mcp_config: MCP servers configuration dictionary
            proxy_manager: Optional ProxyManager instance (required for get_server_tools)
            check_config_changes_fn: Optional function to check for config changes (fallback mechanism)
            get_reload_status_fn: Optional function to get reload status for diagnostics
            default_agent_id: Optional default agent ID from GATEWAY_DEFAULT_AGENT env var for fallback chain
            debug_mode: Whether debug mode is enabled (exposes get_gateway_status tool)
        """
        global _policy_engine, _mcp_config, _proxy_manager, _check_config_changes_fn, _get_reload_status_fn, _default_agent_id, _debug_mode
        _policy_engine = policy_engine
        _mcp_config = mcp_config
        _proxy_manager = proxy_manager
        _check_config_changes_fn = check_config_changes_fn
        _get_reload_status_fn = get_reload_status_fn
        _default_agent_id = default_agent_id
        _debug_mode = debug_mode
    
        # Conditionally register debug tools based on debug mode
        if debug_mode:
            _register_debug_tools()
Behavior3/5

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

No annotations provided, so description carries burden. It implies a read operation and adds the debug mode constraint, but lacks details on side effects or permissions beyond that.

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?

Two sentences, no wasted words. Efficiently communicates purpose and a key usage condition.

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

Completeness5/5

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

Has output schema, so return values are handled. Description covers the three aspects (status, config, diagnostics) and the debug mode condition, sufficient for a read tool.

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?

Schema coverage is 100%, so description does not need to add parameter details. The description provides no extra meaning beyond what the schema already specifies.

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

Purpose5/5

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

The description clearly states 'Get gateway status, configuration state, and hot reload diagnostics' with a specific verb and resource. It distinguishes itself from sibling tools like 'execute_tool' and 'get_server_tools'.

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

Usage Guidelines4/5

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

Includes a note 'Only available when debug mode is enabled,' providing explicit context for when to use the tool. Does not mention alternatives, but siblings are distinct.

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

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/roddutra/agent-mcp-gateway'

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