Skip to main content
Glama
README.md
# squeeze-mcp

An MCP server that runs shell commands for your AI agent and hands back **only the part of the output worth reading**.

Builds, test runs and installs print thousands of lines. An agent that reads all of them spends its context window on progress bars and download logs, then forgets the instructions you gave it. `squeeze` keeps:

- the first few lines and the last ~20 lines,
- every error, stack frame and failure, with two lines of context on each side,
- summary lines (`3 failed, 41 passed`, `Compiled with 2 warnings`, `exit code 1`),

and collapses repeated lines (`Downloading 1/400` … `Downloading 400/400`) into one. Nothing is thrown away: the full output stays in memory under a run id, and the agent can search it with `grep_output` or page through it with `read_output`.

## Example

A made-up test run that prints 402 lines, with one error in the middle:

```
$ node noisy-test.js
exit 1 · 0.1s · 402 lines, 9 shown · run id r1
Search the full output with grep_output or read_output (id r1).
----
fetch 0/400
  … 199 similar lines
fetch 200/400
Error: connection reset by peer
fetch 201/400
  … 197 similar lines
fetch 399/400
1 failed, 9 passed
```

## Install

Requires Node.js 18 or newer.

```bash
git clone https://github.com/isaiahagi/squeeze-mcp.git
cd squeeze-mcp
npm install        # also builds dist/
```

**Claude Code**

```bash
claude mcp add squeeze -- node /absolute/path/to/squeeze-mcp/dist/index.js
```

**Claude Desktop, Cursor, or any client with an `mcpServers` config**

```json
{
  "mcpServers": {
    "squeeze": {
      "command": "node",
      "args": ["/absolute/path/to/squeeze-mcp/dist/index.js"]
    }
  }
}
```

Then tell your agent once, for example in `CLAUDE.md`: *"Run builds, tests and installs with the squeeze `run` tool."*

## Tools

| Tool | What it does |
| --- | --- |
| `run` | Runs a command (`command`, optional `cwd`, `timeout_seconds`, `budget_lines`) and returns the compact output, exit code, duration and a run id. |
| `grep_output` | Searches a run's full output with a regular expression, with line numbers and context. |
| `read_output` | Returns a range of lines from a run's full output. |
| `squeeze_text` | Compacts text you already have, such as a pasted log or stack trace. |
| `list_runs` | Lists the runs still kept, newest first. |

## How the squeezing works

1. Colour codes are stripped and carriage-return progress redraws are reduced to their final state.
2. Consecutive lines that differ only in numbers, hashes or timestamps are collapsed to first, count and last.
3. If the result is still over budget, each line is scored: start and end are always kept, then errors (score 3), lines near errors (2) and summary lines (1) fill the remaining budget.
4. Gaps are marked with `… [N lines omitted]`, so the agent knows exactly what it has not seen.

The logic is in [`src/squeeze.ts`](src/squeeze.ts) and has no dependencies, so you can reuse it elsewhere.

## Settings

| Environment variable | Default | Meaning |
| --- | --- | --- |
| `SQUEEZE_KEEP_RUNS` | `30` | How many runs to keep in memory. |
| `SQUEEZE_MAX_BYTES` | `20971520` (20 MB) | Output kept per run. Past this, the first and last halves are kept. |

Commands run with `CI=1`, `NO_COLOR=1` and `FORCE_COLOR=0` so tools print plain, non-interactive output. Stdin is closed, so a command that waits for input ends instead of hanging.

## Safety

`run` executes shell commands with your user's permissions, exactly like your agent's built-in shell tool. Keep your MCP client's approval prompts on for it, and don't connect it to agents you don't trust.

## Development

```bash
npm test   # builds, then runs unit tests and end-to-end tests against the real server
```

## License

MIT

TDQS

A3.8/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: run executes and compacts, squeeze_text compacts without executing, read_output retrieves line ranges, grep_output searches by regex, and list_runs discovers runs. The only surface overlap is between grep_output and read_output, but they are clearly differentiated by search vs. range access.

Naming Consistency4/5

Four of five tools follow a clear verb_noun pattern (grep_output, read_output, squeeze_text, list_runs), while run is a bare verb. The deviation is minor and still readable, so the set is mostly consistent.

Tool Count5/5

Five tools is well-scoped for a focused log/output squeezing server. Each tool serves a distinct part of the workflow—execution, standalone compaction, discovery, and full-output retrieval—with no redundant entries.

Completeness4/5

The core lifecycle is covered: run creates stored output, list_runs discovers it, and read_output/grep_output retrieve it, while squeeze_text handles standalone text. Minor gaps exist around run metadata (e.g., exit status/duration) and cleanup/deletion of stored runs, but these are workable omissions.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues