MCP server
Bleep ships a Model Context Protocol server. Point Claude Code (or any MCP-aware client) at it and an agent can compile, test, run, and inspect your build through structured tool calls, without parsing CLI output, without keeping a long-running interactive shell open, without reading pages of context for a one-line answer.
The design is built for the world where multiple agents run against multiple checkouts of the same build at the same time:
- Stateless. Every tool call names the checkout it targets via a
required
directoryparameter, is bootstrapped fresh from that workspace'sbleep.yaml, talks to the shared compile server, and disconnects. One MCP server serves a whole session — including subagents working in other git worktrees — and holds nothing that can go stale or leak when a worktree is removed. - Compact by default. Compile and test return a small JSON summary
(error counts, failure suites) plus a
historyId. The full transcript of that exact run is onebleep.history.showcall away. - Program output is recorded, not pasted.
bleep.runandbleep.sourcegenwrite everything a program prints to disk and return its shape — the repeated line patterns with counts, the few lines that differ, when it went quiet. The lines themselves are onebleep.run.outputcall away, by line number or by pattern. - Errors stream. Per-project compile errors land as MCP notifications the instant that project finishes, not at the end of the whole build. The latency floor for a real failure is milliseconds.
- Long calls narrate. Compile, test and run report progress once a second — projects done, suites done, and for a running program its elapsed time and newest line of output. An agent can tell a slow call from a hung one.
Setup
The recommended setup is one user-scoped registration that covers every project and every git worktree — MCP stdio servers launch with the session's working directory, and bleep needs nothing else:
claude mcp add --scope user bleep -- bleep mcp-server
Alternatively, run from a build root:
bleep setup-mcp-server
That writes .mcp.json, the config file that Claude Code,
Cursor, and any other MCP client reads to discover servers. Restart
the client (or trigger a re-scan) and the bleep tools appear.
The flag --force-jvm runs the MCP server through the JVM rather
than the native binary, useful when iterating on bleep itself.
Non-bleep projects
A user-scoped registration advertises the bleep tools in every
session — including sessions on Maven, Gradle, or sbt projects that
bleep cannot build. An agent whose "compile" intent pattern-matches to
bleep.compile in such a project gets a fast, definitive answer: the
call fails in milliseconds with "<directory> is not part of a bleep
build: no bleep.yaml exists there or in any parent directory", and
the error text redirects to the project's own build system rather than
reading like a transient bleep failure.
The inverse deserves stating because agents get it wrong: bleep tool
availability never identifies a project's build system. If the bleep
tools disappear mid-session, the MCP connection dropped (commonly
because the bleep binary was reinstalled underneath the server) —
reconnect with /mcp or fall back to the bleep CLI. Whether a
project is a bleep project is decided by bleep.yaml on disk, and by
nothing else.
The tool surface
| Tool | Effect | Runs code from the checkout | What it does |
|---|---|---|---|
bleep.compile | destructive | yes | Compile selected projects. Returns error counts and a historyId. Optional diffBase adds a diff section vs a previous run. |
bleep.test | destructive | yes | Run tests. Returns pass/fail counts, failure summaries, and a historyId. Optional diffBase adds a diff section vs a previous run. |
bleep.run | destructive | yes | Compile and run a project or script. Reports compile and run progress while it works. Records the output under a runId and returns state, exitCode, durationMs and the shape of each stream. |
bleep.run.output | read-only | no | Numbered lines of a recorded run's stdout or stderr, by range or by pattern. Works while the program is still running. |
bleep.sourcegen | destructive | yes | Run sourcegen scripts for selected projects. Each script is recorded as a run, like bleep.run. |
bleep.test.suites | additive | yes | List test suite class names without running them. Requires projects to be compiled. |
bleep.fmt | destructive | no | Format Scala and Java sources via scalafmt and google-java-format. Rewrites files in place. |
bleep.clean | destructive | no | Delete compile output for selected projects. |
bleep.copy-state | additive | no | Seed a fresh git worktree with the parent worktree's compiled state. Call once after forking. |
bleep.restart | destructive | no | Exit the MCP server process. The client will relaunch it. |
bleep.history.list | read-only | no | The workspace's 20 most recent compile/test runs: historyId, time, mode, target count and first targets, client. limit/offset page back, mode filters. |
bleep.history.show | read-only | no | The full transcript of a completed compile/test run, by historyId. Searchable (regex), 50 items per page, stack traces cut to 60 lines unless fullTraces: true. |
bleep.history.diff | read-only | no | What logically changed between two runs: newly failing/fixed tests, invalidations, new/resolved diagnostics. baseDirectory diffs across worktrees. |
bleep.history.diff-timing | read-only | no | What got slower or faster between two runs, jitter suppressed, plus the target run's slowest items. |
bleep.build.effective | read-only | no | The project config after templates apply, what bleep sees. |
bleep.build.resolved | read-only | no | Fully resolved classpath, source dirs, compiler JARs. Requires prior compile. |
bleep.projects | read-only | no | List projects with their dependencies and test-project flag. |
bleep.programs | read-only | no | List projects with a mainClass (runnable programs). |
bleep.scripts | read-only | no | List the named scripts under scripts: in bleep.yaml. |
What the effect column means
Effect mirrors the MCP spec's tool annotations — read-only maps to
readOnlyHint, destructive to destructiveHint — and clients use
them to decide what may run unattended, without asking the user.
So the column is a security statement, not a description of intent,
and bleep sets it accordingly:
read-onlymeans bleep reads files and its own build model, and nothing else happens. Only the ten tools above qualify: the history tools read transcript JSON off disk,bleep.run.outputreads a recorded run's log files, and the listing tools parsebleep.yamland expand templates. No build code runs, nothing is written.- Building is not read-only. A compile runs sourcegen scripts,
annotation processors, KSP and macros;
bleep.testadditionally runs the test bodies;bleep.runruns the program you name. That is arbitrary code from the checkout, executing with your privileges — it can write files, reach the network, and touch anything your user can. A tool that does this must never be advertised as safe to run without asking, however read-only "compile" sounds.bleep.fmtrewrites your sources in place andbleep.cleandeletes output, so they are destructive for the ordinary reason. bleep.test.suitesruns no test body, but it is not a pure read either. Discovery builds a classloader over the project's classpath and instantiates the test frameworks it finds there, so code from the checkout's dependencies executes in the compile daemon. It writes nothing, henceadditiverather thandestructive.
The practical consequence: if you point an agent at a checkout you do
not trust (a contributor's pull request, a repository you just
cloned), auto-approving bleep.compile is equivalent to auto-approving
run whatever this branch says. The annotations are pinned by tests
(bleep.McpToolEffectTest) so they cannot quietly drift back.
Tools that reach the network — anything that resolves dependencies or
starts the compile daemon — additionally set openWorldHint.
Every tool except bleep.restart requires directory: the absolute
path of the checkout to act on. An agent's current working directory
works — bleep finds the build root from any directory inside it. Even
the bleep.history.* tools take it: history ids are per-workspace, so
an id means nothing without saying whose history to look in.
Output shape
Compile and test return a summary, not a transcript:
{
"success": false,
"errors": 2,
"warnings": 3,
"summary": "Build failed: 2 errors in 1 project. 3 warnings. Use bleep.history.show with this historyId for all diagnostics",
"failedProjects": ["myapp"],
"topErrors": [{"message": "...", "path": "Main.scala", "line": 42}],
"historyId": 7
}
The transcript of every completed run is written by the compile
daemon into the workspace itself
(.bleep/builds/normal/history/<id>.json, the last 32 kept), keyed
by that historyId. History is per-worktree, shared with the CLI
(bleep history, bleep history show, bleep history diff) and IDE builds, and
survives MCP server restarts — the server itself keeps nothing in
memory. The run history & diffs guide
covers the recording and diffing model in depth. When the agent
decides to drill in:
agent: bleep.history.show { directory: "/checkout", historyId: 7 }
→ every diagnostic, every failing test with its stack trace;
project/limit/offset parameters paginate large results
agent: bleep.history.show { directory: "/checkout", historyId: 7, query: "NullPointer|timed out" }
→ only the matching diagnostics or failures — a case-insensitive
regex over messages, paths, suite/test names and stack traces
Even the summary is bounded, because the cases that make it big are the ones agents hit:
- A broken shared fixture can fail hundreds of tests with the same long
assertion. The test summary lists the first 20 failures, each message
cut at 500 characters (
messageTruncated: true), and counts the rest infailuresOmitted.totalFailuresstill counts all of them. - A failed core project skips everything downstream of it.
skippedProjectshas one entry per reason, with acountand the first five project names, rather than one entry per project. - Output of passing suites (
showOutput: true) keeps the last 50 lines per suite, one string per line, stderr prefixed with!.
bleep.history.show is bounded the same way: 50 items unless limit
says otherwise (nextOffset when more remain), and each stack trace
cut to its first 60 lines (throwableLinesOmitted says how many were
cut). A test that timed out carries a thread dump per failure, so an
uncut read of two failures could run to tens of thousands of
characters. Pass fullTraces: true for the uncut traces. The CLI's
bleep history show keeps uncut traces and no default limit.
The query parameter exists because searching output is what agents
do. Given a long log they will divert it to a file and grep it —
losing structure, and often the answer. Searching the structured
transcript server-side returns exactly the matching items, still as
data.
For the edit–run loop, bleep.compile and bleep.test take an
optional diffBase ("previous" for the most recent run of the same
mode, or a historyId to pin a base such as the last green run):
the base is validated before the build starts, and the response gains
a "diff" section — newly failing/fixed tests, new/resolved
diagnostics — so the agent reads what its edit changed instead of
re-reading full results. The CLI mirror is bleep compile --diff /
bleep test --diff.
The diff leaves out what an agent cannot act on. After an edit, most
projects of a large build go from incremental to up-to-date, and
fixing a failed dependency moves everything behind it from skipped to
success. Those projects are counted per transition under modeOnly.
changed keeps diagnostics that appeared or went away, projects that
started or stopped failing, and projects that recompiled because their
own inputs changed. Lists that can be as long as the build (added or
removed projects and tests, invalidated files, changed dependencies)
keep their first 10 entries plus a <name>Total.
A transcript describes its own run, never current state — so it cannot
go stale when someone compiles from the CLI in between. The current
state of the build is always one (cheap, incremental) bleep.compile
away.
Multiple checkouts and git worktrees
MCP clients launch stdio servers once per session, and subagents share
the parent session's connection. A subagent working in a git worktree
therefore talks to an MCP server that was started in the parent
checkout — which is why directory is required on every call rather
than inferred: the server has no ambient workspace, so there is
nothing to silently get wrong. Each call bootstraps the named
workspace fresh (config edits, including JVM changes, take effect on
the next call) and is routed to the shared compile server, which
already serves all worktrees from one deduplicated in-memory state.
If a build declares a $version different from the running MCP
server's, the call fails with an explanation — install the matching
binary and call bleep.restart, which exits the process so the client
relaunches it as the new binary.
A fresh worktree starts cold: it has your parent's sources but none of
its compiled state. bleep.copy-state { directory, from } (CLI:
bleep copy-state <source-worktree>) fixes that in one call — it
clones the parent worktree's classes, zinc analyses and generated
sources into the new one, using the fastest copy the filesystem offers
(clonefile on APFS, reflink where Linux supports it). The copy runs in
the compile daemon under the same per-project locks compiles take, so
it is safe even while other agents keep compiling the parent. The
first build afterwards no-ops through everything unchanged and
compiles incrementally from the parent's baseline for the rest —
typically a few files, not a few hundred. State is copied from the
worktree you forked off and nowhere else: what you start with is
exactly what your parent had, which makes a seeded worktree's behavior
explainable rather than dependent on whatever happens to be in a
cache.
Why these design choices
Stateless over cached
Anything an MCP server caches between calls — a bootstrapped workspace, a daemon connection, "last build" results — can go stale: config edits, binary upgrades, CLI builds racing MCP builds, worktrees deleted under the server. Each piece of held state would need its own invalidation rule. Bootstrapping per call costs roughly what a CLI invocation costs, which is the thing bleep is already fast at; all expensive state lives in the shared compile server, where it is bounded and shared across checkouts.
Compactness over completeness
A full compile transcript can be tens of thousands of tokens, and
dumping it into an agent's context does real damage: the signal
drowns, the agent starts managing output instead of fixing code —
redirecting logs to files, grepping them, paging through noise — and
frequently never finds the line that mattered. Structured data
removes that entire class of failure. The agent gets did anything go
wrong as a boolean, counts, and the first errors in a couple hundred
tokens; everything deeper is a targeted bleep.history.show call —
paginated, or searched with a regex — that returns exactly the items
asked for, still as data.
Errors stream, results summarise
When something is wrong, latency matters, the agent should know about a compile error the instant the project finishes, not 30 seconds later when the rest of the build wraps. So per-project errors stream as notifications during the call, while the summary that wraps up the call is the counts.
A long call still says what it is doing
An agent cannot tell a slow call from a hung one, so every tool that
takes time reports progress once a second. bleep.compile and
bleep.test report what the build knows: projects compiled out of
total, which ones are still going and for how long, suites and tests
done.
bleep.run and bleep.sourcegen report both of their phases. The compile in front of a run
is usually the long part, and it now streams exactly what
bleep.compile streams — including the diagnostics if it fails, which
used to be swallowed in favour of a bare status code. Then the program
itself: elapsed time, how many lines it has printed on each stream,
and the newest line. That last field is the one that matters, because
elapsed time alone cannot separate a program doing work from one stuck
on a socket, while the line it printed four seconds ago can.
A program's output is recorded, and the result is its shape
What a program prints used to be most of what bleep cost an agent's
context: several thousand characters per bleep.run on average, and
tens of thousands for a source generator printing the same warning for
every file. So bleep.run returns no output lines. It records them, and
returns what they look like:
{
"runId": 14,
"project": "codegen",
"mainClass": "com.example.Generate",
"state": "exited",
"exitCode": 1,
"durationMs": 8312,
"pid": 41877,
"stdout": { "lines": 3, "text": ["reading schema", "4012 tables", "writing sources"] },
"stderr": {
"lines": 4005,
"patterns": ["p1 ×4000 L1–4000: WARNING: unresolved column # in <path>"],
"unpatternedLines": 5
},
"rareLines": ["stderr L4005: java.lang.IllegalStateException: vendor repo missing"],
"timing": { "longestSilenceMs": 6100, "longestSilenceBefore": "stderr L4001", "silentAtEndMs": 12 },
"read": "bleep.run.output {runId:14, stream, from, to} returns numbered lines (negative = from the end); pattern:<n> pages only pattern p<n>"
}
- A stream of 10 lines or fewer comes back as
text, verbatim. - A longer stream comes back as its patterns. Lines are masked for numbers, paths, quoted strings and hashes, and grouped by their first six tokens. Each pattern carries its id, count and line range, which is everything needed to page to the lines it stands for.
- Rare lines, the ones printed only once or twice, are quoted in full: error-like lines first, then the most recent. That is usually where the answer is.
- Timing gives the longest silence and the line that ended it, and how long the program had been quiet when it ended. A program stuck on a socket shows up here.
Everything is on disk under .bleep/builds/normal/run-logs/<runId>/.
bleep.run.output returns numbered lines from it, with colour codes
removed:
agent: bleep.run.output { directory: "/checkout", runId: 14, stream: "stderr", from: -5 }
→ the last five lines of stderr
agent: bleep.run.output { directory: "/checkout", runId: 14, stream: "stderr", pattern: 1, from: 1, to: 3 }
→ the first three lines of pattern p1, with their line numbers
Without from it returns the last 20 lines, and at most 200 per call,
with nextFrom when more remain. Negative line numbers count from the
end. Without runId it reads the latest run, and a run that is still
going can be read as it goes. Each stream is recorded up to 64MB, and
lines past that are counted as droppedLines. Run logs are kept
separately from compile/test history, so programs an agent runs never
push transcripts out: the last 64 runs, up to 256MB, oldest removed
first, and never a run that is still going.
timeoutSeconds (default 60, covering the program and not the compile
in front of it) kills the program, and the call still returns — state: "timedOut", no exitCode, and the shape of everything the program
printed before it was killed. A hung program's output is the reason to
look at it at all. A run whose MCP server died before it finished reads
as abandoned.
The program runs with the same environment as bleep run, including
the project's platform.jvmEnvironment.
Sourcegen scripts are runs too
bleep.sourcegen compiles the projects its scripts live in, plus their
declared inputs, then forks each script once with every project it
generates for. Each fork is recorded exactly like a bleep.run. The
result has success (every script exited 0) and one run result per
script under scripts, where mainClass names the script and
sourcegenFor the projects it generated for. A script still running
after 600 seconds is killed.
A sourcegen script never shares the MCP server's own stdin and stdout, which carry the protocol: a script that read stdin or printed freely used to be able to corrupt the connection.
See also
- Bleep build subcommands: the same capabilities exposed on the command line.
- Project globs: the
projectsargument shape every tool accepts.