Skip to main content
Glama

search_modal_logs

Read-onlyIdempotent

Search Modal app or container logs and return surrounding context lines around each match to locate tracebacks, errors, or request IDs across stdout, stderr, and system streams.

Instructions

Search an app's or container's logs and return each hit WITH surrounding context —
the fastest way to find a traceback, an error or a request ID. Logs are fetched once
and grepped locally, so you get the lines around each match, not just the match.

Covers the stdout/stderr/system streams ONLY. Crash events shown on the Modal
dashboard (e.g. "... exited with ...") are not log lines, so a search for them
returns 0 matches even though the failure is real — check the dashboard instead.

Args:
    identifier: App name/ID ("my-app", "ap-...") or container ID ("ta-...").
    pattern: Text to find, or a Python regex when regex=True.
    target: "auto" (default — "ta-..." is a container), "app", or "container".
    regex / case_sensitive: Match mode. Both default False.
    context_lines: Lines of context each side of a match. Default 3.
    max_matches: Cap on match blocks returned. Default 50.
    since / until: Time range, ISO 8601 or relative ("2h", "30m", "1d"). PREFER a
        bounded range (both ends) when you know roughly when something happened —
        `since` alone fetches every entry from then until now, which on a busy app
        is megabytes and gets cut off at the timeout. Range must be <= 35 days.
    tail: Search only the last N entries (max 20000) instead of a whole range.
        With no since/until/tail, defaults to the last 1000 entries.
    source: Search only "stdout", "stderr", or "system".
    exclude: Drop lines matching this BEFORE searching, to strip repeated noise.
    prefilter: Push `pattern` down to Modal as a server-side substring filter, so
        non-matching lines are never fetched. The big lever for huge logs, but it
        requires regex=False and leaves `context_lines` showing only other matching
        lines — use it to find *where* something is, then re-query that window.
    timestamps: Prefix lines with their timestamp. Default True.
    timeout_seconds: Max seconds spent fetching logs. Default 30.
    env: Modal environment (apps only).
    profile: Modal profile for this call only. Defaults to the active profile.

Returns: {match_count (exact, whole log searched), returned (matches actually shown),
returned_blocks, matches (context blocks, matched lines prefixed ">"), excluded_lines,
output_capped}.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "identifier": "<identifier>",
      "pattern": "<pattern>"
    },
    "name": "search_modal_logs"
  }
}

Input Schema

NameRequiredDescriptionDefault
envNo
tailNo
regexNo
sinceNo
untilNo
sourceNo
targetNoauto
excludeNo
patternYes
profileNo
prefilterNo
identifierYes
timestampsNo
max_matchesNo
context_linesNo
case_sensitiveNo
timeout_secondsNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.1
    • addedInput schema / properties / profile
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Profile"
      +}
  2. Changed2 schema fields changedv0.5.0
    • addedInput schema / properties / prefilter
      Added value: +{
      +  "default": false,
      +  "title": "Prefilter",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / until
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Until"
      +}
  3. Changed4 schema fields changedv0.2.2
    • addedInput schema / properties / exclude
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Exclude"
      +}
    • addedInput schema / properties / source
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Source"
      +}
    • changedInput schema / properties / target / default
      Previous value: -"app"New value: +"auto"
    • addedInput schema / properties / timestamps
      Added value: +{
      +  "default": true,
      +  "title": "Timestamps",
      +  "type": "boolean"
      +}
  4. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, openWorldHint=true, and destructiveHint=false, so safety is covered. The description adds substantial behavior beyond that: crash events produce 0 matches even when failures are real, `since` alone can fetch megabytes and hit timeouts, ranges are capped at 35 days, the default lookback is 1000 entries, and prefilter changes what context lines show. These are exactly the operational traits an agent needs before tuning a query.

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 definition is long, but the length is justified by 17 parameters and several non-obvious behavioral caveats. It is front-loaded with the core purpose and structured with clear Args and Returns sections, and each sentence carries operational information rather than restating the schema.

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?

Given the tool's complexity, 17 parameters, and the existence of an output schema, the description is complete enough to call correctly. It explains scope, limitations, defaults, truncation behavior, prefilter trade-offs, and return fields, so an agent has the context needed without over-explaining return values that the output schema already covers.

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

Parameters5/5

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

Schema description coverage is 0%, but the description documents all 17 parameters with defaults and semantics, including identifier formats, target="auto" behavior, regex/case mode, relative time formats, tail limits, source filtering, exclude-before-search behavior, prefilter constraints, timestamps, and timeout. It adds meaning well beyond the bare schema names and compensates fully for the missing schema descriptions.

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 states a specific verb and resource: search an app's or container's logs and return hits with surrounding context. It implicitly distinguishes targeted search-with-context from raw log retrieval, but it never names the likely sibling get_modal_logs, so an agent must infer the boundary. Purpose is clear, but sibling differentiation is not explicit.

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?

It gives clear when-to-use guidance (finding tracebacks, errors, request IDs) and an explicit when-not case: crash events are not log lines, so check the dashboard instead. It also advises bounded time ranges and explains the prefilter-then-requery workflow for huge logs. However, it does not name get_modal_logs or another sibling as the alternative for full unfiltered log retrieval.

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