Skip to main content
Glama
djm81

Log Analyzer MCP

by djm81

search_log_all_records

Search all log records with filtering by scope and content patterns, providing context before and after matches for comprehensive analysis.

Instructions

Search for all log records, optionally filtering by scope and content patterns, with context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeNodefault
context_beforeNo
context_afterNo
log_dirs_overrideNo
log_content_patterns_overrideNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that executes the tool logic: parses input parameters, initializes AnalysisEngine, builds filter criteria, searches logs, and returns results or raises MCP error.
    @mcp.tool()
    async def search_log_all_records(
        scope: str = "default",
        context_before: int = 2,
        context_after: int = 2,
        log_dirs_override: str = "",
        log_content_patterns_override: str = "",
    ) -> list[dict[str, Any]]:
        """Search for all log records, optionally filtering by scope and content patterns, with context."""
        # Forcing re-initialization of analysis_engine for debugging module caching.
        # Pass project_root_for_config=None to allow AnalysisEngine to determine it.
        current_analysis_engine = AnalysisEngine(logger_instance=logger, project_root_for_config=None)
        print(
            f"DEBUG_MCP_TOOL_SEARCH_ALL: Entered search_log_all_records with log_dirs_override='{log_dirs_override}'",
            file=sys.stderr,
            flush=True,
        )
        logger.info(
            "MCP search_log_all_records called with scope='%s', context=%sB/%sA, "
            "log_dirs_override='%s', log_content_patterns_override='%s'",
            scope,
            context_before,
            context_after,
            log_dirs_override,
            log_content_patterns_override,
        )
        log_dirs_list = log_dirs_override.split(",") if log_dirs_override else None
        log_content_patterns_list = log_content_patterns_override.split(",") if log_content_patterns_override else None
    
        filter_criteria = build_filter_criteria(
            scope=scope,
            context_before=context_before,
            context_after=context_after,
            log_dirs_override=log_dirs_list,
            log_content_patterns_override=log_content_patterns_list,
        )
        try:
            results = await asyncio.to_thread(current_analysis_engine.search_logs, filter_criteria)
            logger.info("search_log_all_records returning %s records.", len(results))
            return results
        except Exception as e:  # pylint: disable=broad-exception-caught
            logger.error("Error in search_log_all_records: %s", e, exc_info=True)
            custom_message = f"Failed to search all logs: {e!s}"
            raise McpError(ErrorData(code=-32603, message=custom_message)) from e
  • Pydantic model defining the input schema for the search_log_all_records tool, inheriting from BaseSearchInput.
    class SearchLogAllInput(BaseSearchInput):
        """Input for search_log_all_records."""
  • Base Pydantic model providing common input fields for search tools, used by SearchLogAllInput.
    class BaseSearchInput(BaseModel):
        """Base model for common search parameters."""
    
        scope: str = Field(default="default", description="Logging scope to search within (from .env scopes or default).")
        context_before: int = Field(default=2, description="Number of lines before a match.", ge=0)
        context_after: int = Field(default=2, description="Number of lines after a match.", ge=0)
        log_dirs_override: str = Field(
            default="",
            description="Comma-separated list of log directories, files, or glob patterns (overrides .env for file locations).",
        )
        log_content_patterns_override: str = Field(
            default="",
            description="Comma-separated list of REGEX patterns for log messages (overrides .env content filters).",
        )
  • The @mcp.tool() decorator registers the search_log_all_records function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'with context' which hints at the context_before/after parameters, but doesn't explain what 'context' means, how results are returned, whether there are rate limits, authentication needs, or what 'search' entails (e.g., regex, exact match). This is a significant gap for a search tool with 5 parameters.

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 a single, efficient sentence that front-loads the core purpose. However, it could be more structured by separating key features (e.g., 'Searches all log records. Optional filters: scope, content patterns. Includes context lines.'), but it avoids unnecessary verbosity.

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 5 parameters with 0% schema coverage, no annotations, but an output schema exists, the description is incomplete. It hints at some parameters but doesn't fully explain their semantics or usage. The output schema mitigates the need to describe return values, but the lack of behavioral and parameter details leaves gaps for effective tool invocation.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions filtering by 'scope and content patterns' and 'with context', which loosely maps to some parameters (scope, log_content_patterns_override, context_before/after), but doesn't explain what 'scope' means, what 'log_dirs_override' does, or how patterns work. This adds minimal value beyond the schema's property names.

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 verb ('search') and resource ('all log records'), and mentions optional filtering by scope and content patterns. It distinguishes from some siblings like 'search_log_first_n_records' by specifying 'all' records, but doesn't fully differentiate from other search siblings like 'search_log_time_based' in terms of when to use each.

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 like 'search_log_first_n_records', 'search_log_last_n_records', or 'search_log_time_based'. It mentions optional filtering but doesn't specify use cases or exclusions, leaving the agent to guess based on tool names alone.

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/djm81/log_analyzer_mcp'

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