SuperCompress

Grok Build · Updated 2026-10-30

Grok Build Token usage MCP

Reduce Grok Build Token Usage: Compress Tool Results

Grok Build sessions grow with tool results, file reads, shell output, test and build logs, search results and MCP results that sit in context for later turns. Here is where those tokens go and what supercompress setup wires so the model's copy of a large tool result is replaced with a compressed digest mid-turn.

By Arjun Shah · October 30, 2026 · Guide

In short: run npx supercompress-proxy setup or supercompress setup. Setup opens a browser sign-in link (no API key step), then writes Grok Build MCP registration, hooks, instructions and a skill. When a tool result is large, a PostToolUse hook replaces the model's copy of that result with a compressed digest via updatedToolOutput. The real result stays on the record, and small output passes through unchanged.

Where Grok Build tokens go

How SuperCompress works

SuperCompress is hosted, extractive and query-aware. It keeps original lines chosen against the question and drops the rest. It never rewrites or summarizes, so file paths, error messages, IDs and code come back as they were. The question itself is never compressed.

Every compress call reports original_tokens and kept_tokens, so you can see what was dropped on your own work. In Grok Build the agent can call the MCP tools compress_context, connect_account and runway_check.

What supercompress setup wires in Grok Build

supercompress setup and supercompress plugin write the same Grok Build files. Your existing MCP servers in config.toml are kept untouched, and the SuperCompress entry is appended after them. Grok Build keeps its settings in ~/.grok/config.toml, or under $GROK_HOME when that is set, as described in the Grok Build settings docs.

FileChange
~/.grok/config.tomlAppends [mcp_servers.supercompress], a stdio command running the SuperCompress MCP server with startup_timeout_sec = 60, tool_timeout_sec = 600, enabled = true and env SUPERCOMPRESS_AGENT_NAME = "Grok Build", after your own servers. Also sets [mcp] max_output_bytes = 2000000.
~/.grok/hooks/supercompress.jsonAdds a UserPromptSubmit hook and a PostToolUse hook (matcher ".*"). The PostToolUse hook replaces the model's copy of a large tool result with the compressed digest via updatedToolOutput.
~/.grok/AGENTS.mdAppends a SuperCompress instructions block after your own text.
~/.grok/skills/supercompress/SKILL.mdCopies the SuperCompress skill.

The MCP server shape matches the Grok Build MCP servers docs: servers live under [mcp_servers.NAME] with command, args, env, startup_timeout_sec and tool_timeout_sec. For clients you wire by hand, Grok Build also accepts a [mcp_servers.NAME] entry with url = ..., and the hosted SuperCompress MCP endpoint is https://www.supercompress.dev/api/mcp.

How a turn works

  1. Grok Build runs a tool. The real tool result stays on the record. It is not deleted.
  2. On PostToolUse, if that result is large, the hook compresses it against the task and replaces the model's copy of the result with the digest via updatedToolOutput. Small output passes through unchanged.
  3. Digests are also written to ~/.supercompress/inbox/latest.md and ~/.supercompress/inbox/<sessionId>/.

The Grok Build hooks docs describe updatedToolOutput as replacing the model's copy of the result, which is exactly the path SuperCompress uses. Grok Build discards UserPromptSubmit additionalContext, so PostToolUse replacement is the mid-turn path. The agent can also call compress_context itself, with the bulky text as context and the user's request as query, and can call runway_check before large work.

Why setup raises the MCP output cap

Grok Build truncates MCP tool results at 20KB unless the cap is raised, and compressed digests can be larger than that. Setup sets [mcp] max_output_bytes = 2000000 in config.toml so digests come through whole. supercompress uninstall removes the cap again.

Install

npx supercompress-proxy setup

If the CLI is already installed:

supercompress setup

Or install it first with npm i -g supercompress-proxy, then run supercompress setup. Setup opens a browser sign-in link. There is no API key step. It detects the coding agents on the machine and wires each one, including Grok Build. Restart Grok Build so it loads the new MCP server and hooks.

Check what got wired

supercompress doctor

doctor prints a per-agent health check. For Grok Build the plugin table row is MCP, Hooks and Instructions.

Undo

supercompress uninstall

supercompress uninstall --yes skips the confirm prompt. Uninstall removes the Grok Build instructions and MCP registration, restores config.toml and AGENTS.md byte-for-byte to your originals, removes the [mcp] output cap it added, and removes the hooks file and the skill.

When to skip it

FAQ

Does SuperCompress change my existing Grok MCP servers?

No. Setup appends [mcp_servers.supercompress] to ~/.grok/config.toml after the servers you already have, and your own entries are kept untouched. supercompress uninstall restores config.toml byte-for-byte.

What does the PostToolUse hook do?

When a tool result is large, the PostToolUse hook compresses it and replaces the model's copy of that result with the digest via updatedToolOutput. The real result stays on the record, and small output passes through unchanged.

Does SuperCompress rewrite or summarize what Grok Build reads?

No. It is extractive and query-aware. It keeps original lines chosen against the question and drops the rest. It never rewrites or summarizes, so file paths, error messages and code stay as they were.

Why does setup raise [mcp] max_output_bytes?

Grok Build truncates MCP tool results at 20KB unless the cap is raised, and compressed digests can be larger than that. Setup sets [mcp] max_output_bytes = 2000000 so digests come through whole. Uninstall removes the cap again.

How do I remove the Grok Build setup?

Run supercompress uninstall. It restores config.toml and AGENTS.md byte-for-byte to your originals, removes the [mcp] output cap it added, and removes the hooks file and the skill.

Coding agents guide All coding agents Codex