logcut
Local-First Stacktrace, Runtime Log, Test & Compiler-Error Slicing for AI Coding Agents
Stop pasting 10,000-line logs and compiler walls into your LLM.
logcut keeps the crashing frames, root causes, failing assertions, and exact source lines—and drops the rest.
Why logcut? • Quickstart • MCP Setup • CLI Usage • Architecture
MCP Registry: mcp-name: io.github.bigwalkdoe/logcut
$ wc -l app.log
10482 app.log
$ logcut slice app.log --stats
== Error bursts ==
[x3 | first: 02:14:02 | last: 02:14:58] ERROR Connection refused to <UUID>
== Stacktrace ==
thread 'main' panicked at src/handler.rs:42:9:
... [3 framework/runtime frames hidden] ...
at logcut::handler::process (src/handler.rs:42:9)
== Source context ==
39 | // line 39
> 42 | let conn = connect();
--stats writes JSON size/token savings to stderr, so the report on stdout stays pipe-safe.
Why logcut?
logcut is one Rust binary with two interfaces over the same pure-Rust core: an MCP server for AI hosts and a CLI for terminal pipelines. Each mode is built for the moment an agent or an engineer needs the failure, not the whole file.
- Stacktrace Slicing (
slice_log/logcut slice) — Redacts secrets, deduplicates error bursts, collapses consecutive vendor frames, and inlines the exactpath:linesource around surviving application frames. - Compiler Cascade Collapsing (
slice_build/logcut build) — Parsesrustc/cargo,tsc,go build, andgcc/clangoutput, merges repeated cascades, and reports root causes with occurrence counts. - Test-Failure Slicing (
slice_test/logcut test) — Handles cargo, pytest, jest/vitest, and go test; strips passing lines while keeping assertion diffs and source context. - Structured NDJSON (
--min-level,--where) — Detects NDJSON automatically, drops staticpid/hostname/vmetadata, filters by severity and field value, and attaches up to five correlatedINFO/WARNbreadcrumbs to each error. - Redaction by Default — Masks Bearer tokens,
sk-/rk-keys, GitHub and AWS credentials, credential-bearing database URLs, andapi_key/password/secretassignments before anything reaches your LLM. - Crash Capture (
logcut watch/get_last_crash) — Streams a command, keeps a 500-line ring buffer, and atomically writes.logcut/last-crash.mdwhen a panic, traceback, fatal error, or non-zero exit appears. - Docker & systemd Sources (
slice_container/slice_service) — Runs the same slicing engine overdocker logsandjournalctloutput, with explicit argument arrays instead of shell interpolation. - Hosted Streamable HTTP (
serve-http) — Serves the same six MCP tools at/mcpbehind thehttpfeature for managed hosting, with a stateless server and no persistent disk. - One Core, Two Interfaces —
logcut mcpand the CLI share one pure-Rust core, and MCP schemas are generated from the same structs so the contracts cannot drift. - Built to Pair with treecut —
treecutmaps the codebase;logcutexplains what broke at runtime. Together they give an agent the code map and the failure evidence.
Quickstart
Install via Cargo
Homebrew (macOS/Linux)
Prebuilt archives
Prebuilt archives for Linux x86_64, macOS x86_64, macOS aarch64, and Windows x86_64 are attached to the v0.3.0 release. Each archive has a matching .sha256 checksum; unpack it and put the logcut binary on your PATH.
Build from source
For an MCP-only build that leaves out the ask HTTP client:
For a one-command install of both logcut and treecut with shared agent setup, see agentcut.
MCP Server Setup
logcut mcp speaks JSON-RPC 2.0 over standard stdio with no background daemons and no API keys. JSON-RPC stays on stdout; diagnostics and tracing go to stderr.
Quick setup (logcut init)
With no flags, init writes all three sets.
| Host | Server config | Slash command |
|---|---|---|
| OpenCode | opencode.json |
.opencode/commands/debug-log.md |
| Claude Code | .mcp.json |
.claude/commands/debug-log.md |
| Cursor | .cursor/mcp.json |
.cursor/rules/debug-log.mdc |
Existing files are left untouched, so rerunning init is safe.
OpenCode (opencode.json)
Claude Code (.mcp.json) and Cursor (.cursor/mcp.json)
Exposed MCP tools
| Tool | Purpose | Key arguments |
|---|---|---|
slice_log |
Redacted, deduplicated logs with frames and source | path, raw_text, workspace_root, tail_lines, context_lines, include_vendor_frames, max_chars, min_level, where_filters |
slice_test |
Failing tests with assertion diffs and source | path, raw_text, workspace_root, tail_lines, context_lines, max_chars |
slice_build |
Compiler root causes and collapsed cascades | path, raw_text, workspace_root, tail_lines, max_errors, context_lines, max_chars |
slice_container |
Docker logs through the same engine | container, tail_lines, since, workspace_root, max_chars |
slice_service |
systemd journal through the same engine | unit, lines, workspace_root, max_chars |
get_last_crash |
Report written by logcut watch |
workspace_root |
All tools accept an optional workspace_root for resolving path:line snippets. slice_log additionally accepts min_level and where_filters for NDJSON streams.
Hosted HTTP
For hosted deployments (including MCPRush managed hosting), build with the http feature and run:
--host and --port default to 0.0.0.0 and 8080 and read LOGCUT_HTTP_HOST / LOGCUT_HTTP_PORT from the environment. A root Dockerfile builds the same binary into a small Alpine image. The hosted server declares all six tools, but slice_container, slice_service, and get_last_crash need the host machine and return a "requires a local logcut install" error there; use a local install for those three.
CLI Usage
Use logcut directly in terminal pipelines, Git hooks, or standalone debugging sessions.
# Slice a file, piped output, or inline text
|
# Filter structured NDJSON by severity and fields
# Keep only failing tests with source context
|
# Watch a command and save its last crash
# Collapse compiler error walls into root causes
|
# Container and systemd sources
# Agentic loop (needs OPENAI_API_KEY; optional OPENAI_BASE_URL / OPENAI_MODEL)
--stats writes JSON size/token statistics to stderr, so stdout stays pipe-safe. --workspace-root controls which frames count as application code and where path:line snippets are read from.
Defaults: slice tails 5,000 lines (--tail-lines 5000), keeps 3 context lines (--context-lines 3), and caps rendered text at 12,000 characters (--max-chars 12000); build reports 10 root causes (--max-errors 10) with 3 context lines (--context-lines 3) and a 12,000-character cap (--max-chars 12000), and tails the last 5,000 lines when reading a file (--tail-lines 5000); watch keeps a 500-line ring (--ring-lines 500); docker tails 2,000 lines and journal 1,000 lines. ask requires OPENAI_API_KEY; OPENAI_MODEL defaults to gpt-4o-mini and OPENAI_BASE_URL to https://api.openai.com/v1.
Reports
A slice report deduplicates error bursts, keeps surviving stack frames, and inlines source around application frames. A compiler report collapses cascades into root causes. Structured NDJSON keeps entries and breadcrumbs. Test reports keep failures and assertion diffs.
Stacktrace report
== Error bursts ==
[x3 | first: 02:14:02 | last: 02:14:58] ERROR Connection refused to <UUID>
== Stacktrace ==
thread 'main' panicked at src/handler.rs:42:9:
... [3 framework/runtime frames hidden] ...
at logcut::handler::process (src/handler.rs:42:9)
== Source context ==
39 | // line 39
> 42 | let conn = connect();
Compiler report
== Compiler errors ==
[1] E0277 src/api.rs:42:18 — the trait bound `User: Serialize` is not satisfied
[+3 trait/note lines collapsed]
| serde_json::to_string(user)
== Source context ==
39 | // line 39
> 42 | serde_json::to_string(user)
Structured NDJSON report
== Structured logs ==
02:14:58 ERROR Connection refused
fields: service=auth status=500
breadcrumbs:
02:14:57 INFO retrying request
Test report
== Test failures ==
name: checkout_rejects_expired_card
location: tests/checkout.rs:88
message:
assertion `left == right` failed
left: 402
right: 200
== Source context ==
85 | // line 85
> 88 | assert_eq!(status, 200);
[passing lines stripped: 1204 | failures: 1]
slice keeps the last 5,000 lines by default. --max-chars truncates rendered text only, while structured fields stay complete.
Working with treecut
treecut maps a codebase; logcut explains what broke at runtime. Use them together in OpenCode, Claude Code, or Cursor:
- Ask the agent to run
treecuton the repository to find the modules involved. - Reproduce the failure and pipe runtime output into
logcut sliceor compiler output intologcut build(or let the agent call the MCP tools). logcutreturns redacted, deduplicated errors, vendor-collapsed stack frames, collapsed compiler cascades, and inlinedpath:linesnippets.- The agent uses the treecut map to navigate from those frames to related code, then proposes a fix.
The /debug-log command created by logcut init gives the agent that workflow in one step.
Architecture
logcut is structured around a pure, UI-agnostic Rust core shared identically by the MCP server, the CLI, and the hosted HTTP layer:
┌──────────────────────────┐
│ logcut (binary) │
└────────────┬─────────────┘
│
┌────────────────────┼────────────────────┐
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ MCP stdio (rmcp) │ │ CLI (clap) │ │ HTTP (axum) │
│ JSON-RPC / stdio │ │ slice · test · │ │ /mcp │
│ │ │ watch · build │ │ │
└────────┬─────────┘ └────────┬─────────┘ └────────┬─────────┘
└────────────────────┼────────────────────┘
▼
┌──────────────────────────────────────────────────────────┐
│ Pure core engine │
│ redaction · dedup · stacktraces · NDJSON · tests · │
│ compiler cascades · source snippets · bounded reads │
└──────────────────────────────────────────────────────────┘
- stdout is reserved for reports and JSON-RPC. Diagnostics, tracing, and
--statsgo to stderr, so MCP framing and terminal pipelines stay clean. - Redaction runs before rendering and again over the final text. Structured
snippetsremain raw source lines; treat them as sensitive if your sources hold credentials. - File input is tailed backwards in 8 KiB chunks. The reader never seeks from the beginning or allocates the whole file, and
max_charstruncates rendered text only. - MCP schemas are generated from the same Rust structs (
schemars). The published contract cannot drift from the implementation. - Hosted mode is stateless. No tool writes files, creates caches, or needs a persistent disk, and host-dependent tools are refused there.
Feature flags
| Feature | Default | Provides |
|---|---|---|
cli |
yes | logcut ask agent loop (reqwest) |
mcp |
yes | logcut mcp stdio server (rmcp) |
http |
no | logcut serve-http (axum; implies mcp) |
slice, test, watch, build, docker, journal, and init are available in every build.
Documentation
Start with the documentation index:
- Usage guide — commands, flags, defaults, and examples
- MCP and agent reference — stdio tools, host setup, and
logcut ask - Architecture guide — modules, invariants, and extension points
- Troubleshooting — common symptoms and fixes
Development
Contributing
Contributions are welcome—especially new language parsers, compiler-output fixtures, and redaction edge cases. See CONTRIBUTING.md for development setup, validation expectations, and PR guidance, and CHANGELOG.md for release notes.
Privacy
logcut is local-first and collects no telemetry. logcut itself makes no network calls in slice, test, watch, build, docker, or journal; ask is the exception and sends the sliced context to the OpenAI-compatible endpoint you configure. Redaction is on by default, but structured snippets are raw source lines.
License
Dual-licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://apache.org)
- MIT License (LICENSE-MIT or http://opensource.org)
at your option.