Skip to main content
Glama
PovedaAqui

SuzieQ MCP Server

run_suzieq_summarize

Analyze and summarize network data from SuzieQ tables like 'device', 'bgp', or 'interface' by applying optional filters to retrieve structured JSON insights for observability and troubleshooting.

Instructions

Runs a SuzieQ 'summarize' query via its REST API.

Args:
    table: The name of the SuzieQ table to summarize (e.g., 'device', 'bgp', 'interface', 'route').
    filters: An optional dictionary of filter parameters for the SuzieQ query
             (e.g., {"hostname": "leaf01", "vrf": "default"}).
             Keys should match SuzieQ filter names. Values can be strings or lists of strings.
             If no filters are needed, this can be None, null, or an empty dictionary.

Returns:
    A JSON string representing the summarized result from the SuzieQ API,
    or a JSON string with an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filtersNo
tableYes

Implementation Reference

  • The handler function for the 'run_suzieq_summarize' tool, decorated with @mcp.tool() for registration. It processes input parameters, calls the helper to query the SuzieQ API with the 'summarize' verb, serializes the response to JSON, and handles serialization errors.
    async def run_suzieq_summarize(table: str, filters: Optional[Dict[str, Any]] = None) -> str:
        """
        Runs a SuzieQ 'summarize' query via its REST API.
    
        Args:
            table: The name of the SuzieQ table to summarize (e.g., 'device', 'bgp', 'interface', 'route').
            filters: An optional dictionary of filter parameters for the SuzieQ query
                     (e.g., {"hostname": "leaf01", "vrf": "default"}).
                     Keys should match SuzieQ filter names. Values can be strings or lists of strings.
                     If no filters are needed, this can be None, null, or an empty dictionary.
    
        Returns:
            A JSON string representing the summarized result from the SuzieQ API,
            or a JSON string with an error message.
        """
        actual_filters = filters if isinstance(filters, dict) else None
    
        # Call the generalized helper function with verb='summarize'
        result = await _query_suzieq_api(verb="summarize", table=table, params=actual_filters)
    
        try:
            # Serialize the result dictionary to a JSON string
            return json.dumps(result, indent=2, ensure_ascii=False)
        except TypeError as e:
            error_message = f"Error serializing SuzieQ 'summarize' response to JSON: {str(e)}"
            print(f"[ERROR] {error_message}") # Debug print
            return json.dumps({"error": error_message})
  • Supporting helper function that performs the actual HTTP request to the SuzieQ REST API, constructs the URL as /{table}/{verb}, adds authentication via access_token query param, handles various errors, and returns the parsed JSON response or error dictionary.
    async def _query_suzieq_api(verb: str, table: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
        """
        Asynchronously queries the SuzieQ REST API for a given verb and table.
    
        Args:
            verb: The SuzieQ verb to execute (e.g., 'show', 'summarize').
            table: The SuzieQ table name (e.g., 'device', 'bgp', 'interface').
            params: A dictionary of query parameters for filtering (e.g., {'hostname': 'leaf01', 'vrf': 'default'}).
    
        Returns:
            A dictionary containing the API response or an error message.
        """
        # Check if configuration is missing
        if not SUZIEQ_API_ENDPOINT or not SUZIEQ_API_KEY:
            error_msg = "SuzieQ API endpoint or key not configured. Set SUZIEQ_API_ENDPOINT and SUZIEQ_API_KEY environment variables or in .env file."
            print(f"[ERROR] {error_msg}") # Log configuration error
            return {"error": error_msg}
    
        # Construct the API URL using the provided verb and table
        api_endpoint_clean = SUZIEQ_API_ENDPOINT.rstrip('/')
        # Assuming the API structure follows /{table}/{verb} pattern
        api_url = f"{api_endpoint_clean}/{table}/{verb}"
    
        # --- Authentication ---
        # Prepare parameters, adding the API key as 'access_token' query parameter
        query_params = params if params else {}
        query_params["access_token"] = SUZIEQ_API_KEY # Add key as query param
        query_params["format"] = "json" # Ensure response is JSON
        headers = {} # No custom headers needed now for auth
        # ---------------------------
    
        async with httpx.AsyncClient() as client:
            try:
                # Use headers={}, params=query_params
                print(f"[INFO] Querying SuzieQ API: {api_url} with params: {query_params}") # Debug print
                response = await client.get(api_url, headers=headers, params=query_params, timeout=30.0)
                print(f"[INFO] SuzieQ API Response Status: {response.status_code}") # Debug print
                response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)
    
                if response.status_code == 204:
                    return {"warning": f"Received empty response (204 No Content) from SuzieQ API for {verb} {table}"}
    
                content_type = response.headers.get('content-type', '')
                if 'application/json' in content_type:
                    return response.json()
                else:
                    error_detail = f"Unexpected content type received: {content_type}. Response text: {response.text}"
                    print(f"[ERROR] {error_detail}")
                    return {"error": error_detail}
            except httpx.HTTPStatusError as e:
                error_detail = f"HTTP error occurred: {e.response.status_code} - {e.response.text}"
                print(f"[ERROR] {error_detail}") # Debug print
                return {"error": error_detail}
            except httpx.RequestError as e:
                error_detail = f"An error occurred while requesting {e.request.url!r}: {e}"
                print(f"[ERROR] {error_detail}") # Debug print
                return {"error": error_detail}
            except json.JSONDecodeError as e:
                error_detail = f"Failed to decode JSON response from SuzieQ API: {e}. Response text: {response.text}"
                print(f"[ERROR] {error_detail}")
                return {"error": error_detail}
            except Exception as e:
                error_detail = f"An unexpected error occurred: {str(e)}"
                print(f"[ERROR] {error_detail}") # Debug print
                return {"error": error_detail}
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool runs via REST API and returns JSON or error messages, but lacks details on authentication needs, rate limits, side effects, or what 'summarize' entails behaviorally (e.g., aggregation, statistics). This is a significant gap for a tool with no annotation coverage.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the core purpose. The Args and Returns sections are structured clearly, though the 'filters' explanation is slightly verbose. Most sentences earn their place by adding value, with minimal 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 2 parameters, no annotations, no output schema, and moderate complexity, the description covers purpose and parameters well but lacks behavioral context and explicit usage guidelines. It is adequate as a minimum viable description but has clear gaps in transparency and guidance.

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

Parameters4/5

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

The schema description coverage is 0%, so the description must compensate. It effectively adds meaning by explaining 'table' as the SuzieQ table name with examples and 'filters' as an optional dictionary with examples and usage notes. This goes beyond the schema's minimal titles, providing practical context for both parameters.

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 'runs a SuzieQ summarize query via its REST API', specifying the verb (runs), resource (SuzieQ summarize query), and mechanism (REST API). It distinguishes from the sibling tool 'run_suzieq_show' by focusing on 'summarize' queries rather than 'show' queries, though the distinction could be more explicit.

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

Usage Guidelines3/5

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

The description implies usage for SuzieQ summarize queries but does not explicitly state when to use this tool versus the sibling 'run_suzieq_show' or other alternatives. It provides context about the REST API mechanism but lacks explicit guidance on scenarios or prerequisites for choosing this tool.

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/PovedaAqui/suzieq-mcp'

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