search_modal_logs
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
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | ||
| tail | No | ||
| regex | No | ||
| since | No | ||
| until | No | ||
| source | No | ||
| target | No | auto | |
| exclude | No | ||
| pattern | Yes | ||
| profile | No | ||
| prefilter | No | ||
| identifier | Yes | ||
| timestamps | No | ||
| max_matches | No | ||
| context_lines | No | ||
| case_sensitive | No | ||
| timeout_seconds | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |