Skip to main content
Glama
agarwalvivek29

OpenTelemetry MCP Server

search_logs

Search application logs using filters for service, namespace, text, level, and time range to investigate issues without writing complex queries.

Instructions

Search logs with simple filters. Easier than writing raw LogQL queries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceNoService/job name to filter logs
namespaceNoNamespace to filter logs
search_textNoText to search for in log messages
levelNoLog level filter: 'error', 'warn', 'info', 'debug'
startNoStart time (relative like '1h' or absolute). Default: 1h ago
endNoEnd time. Default: now
limitNoMaximum number of log entries. Default: 100

Implementation Reference

  • Implementation of the search_logs tool handler in src/tools/loki_tools.py.
    async def search_logs(
        client: LokiClient,
        service: Optional[str] = None,
        namespace: Optional[str] = None,
        search_text: Optional[str] = None,
        level: Optional[str] = None,
        start: Optional[str] = None,
        end: Optional[str] = None,
        limit: int = 100
    ) -> Dict[str, Any]:
        """
        Search logs with simple filters.
        
        Args:
            client: Loki client
            service: Service/job name filter
            namespace: Namespace filter
            search_text: Text to search for in logs
            level: Log level filter (error, warn, info, debug)
            start: Start time
            end: End time
            limit: Maximum number of results
            
        Returns:
            Filtered log entries
        """
        try:
            # Build LogQL query
            labels = []
            if service:
                labels.append(f'job="{service}"')
            if namespace:
                labels.append(f'namespace="{namespace}"')
            
            query = "{" + ",".join(labels) + "}" if labels else "{job=~\".+\"}"
            
            # Add search text filter
            if search_text:
                query += f' |= "{search_text}"'
            
            # Add level filter
            if level:
                query += f' | json | level="{level}"'
            
            # Parse time range
            start_dt, end_dt = parse_time_range(start, end)
            start_ns = to_loki_time(start_dt)
            end_ns = to_loki_time(end_dt)
            
            result = await client.query_range(query, start_ns, end_ns, limit)
            
            return {
                "success": True,
                "query": query,
                "filters": {
                    "service": service,
                    "namespace": namespace,
                    "search_text": search_text,
                    "level": level
                },
                "result": result
            }
        except Exception as e:
            logger.error(f"Error searching logs: {e}")
            return {
                "success": False,
                "error": str(e)
            }
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 of behavioral disclosure. It mentions the tool is 'easier than writing raw LogQL queries,' which hints at a simplified interface, but fails to describe key behaviors such as authentication requirements, rate limits, error handling, or the format of returned results. For a search tool with no annotation coverage, this is a significant gap.

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 with two short sentences that are front-loaded and waste no words. Every part earns its place by stating the purpose and a key comparative advantage, making it efficient and easy to parse.

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

Completeness2/5

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

Given the complexity of a search tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, result formatting, error cases, and explicit usage scenarios. While the schema covers parameters well, the overall context for effective tool invocation is insufficient.

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?

The input schema has 100% description coverage, providing clear details for all 7 parameters. The description adds minimal value beyond the schema, only implying that filters are 'simple' without elaborating on parameter interactions or constraints. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't significantly enhance parameter understanding.

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: 'Search logs with simple filters.' It specifies the action (search) and resource (logs) with a qualifier (simple filters). However, it doesn't explicitly distinguish this tool from its siblings like 'query_loki' which might handle more complex queries, though the mention of 'easier than writing raw LogQL queries' hints at differentiation.

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 provides implied usage guidance by stating it's 'easier than writing raw LogQL queries,' suggesting this tool is for simpler searches compared to alternatives. However, it lacks explicit when-to-use rules, prerequisites, or clear comparisons with sibling tools like 'query_loki' or 'list_logs' (if present), leaving some ambiguity.

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/agarwalvivek29/opentelemetry-mcp'

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