ashlr__pipe [EXPERIMENTAL]
Experimental multi-step JavaScript expression pipeline. Runs grep/read/ls/glob internally — only the final result enters the model context. 80–95% token savings vs calling tools individually. Gated by ASHLR_PIPE_ENABLE=1.
ashlr__pipe is an experimental tool that lets the model run a multi-step JavaScript expression calling grep, read, ls, and glob internally. Intermediate results never enter the model's context — only the expression's return value does. This yields 80–95% token savings vs calling the same tools individually.
Status: experimental and not registered by default. Set ASHLR_PIPE_ENABLE=1 in the MCP server process environment before starting it to register the tool. It is excluded from the default tool count.
Why it exists
A common pattern in agentic code sessions is a chain like:
grepfor files matching a pattern → 40 resultsreadeach candidate → 40 × 3KB = 120KB of context- Filter to 2 relevant files → 118KB was wasted
ashlr__pipe collapses this into one call. The expression body runs the chain locally; only the final filtered output enters the context window.
Enable
Or export it before starting the MCP server from your shell:
For an MCP client that starts the server itself, set the variable in that server's environment configuration and restart the server.
To also allow bash calls inside expressions (off by default):
Usage
Replace /path/to/project with a directory inside an allowed root. The filter
selects lines containing auth, including any status lines with that text.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | string | yes | JavaScript expression body (max 2000 chars). Must return a string or object. |
cwd | string | no | Directory to validate against allowed roots; pass cwd to a context method separately to select its working directory. |
timeout_ms | number | no | Execution timeout in ms (default: 10000, hard max: 30000). |
max_output_bytes | number | no | Truncate output to this many bytes (default: 4096). |
Available functions inside expr
By default, only read-only context tools are available:
| Function | Maps to |
|---|---|
ctx.grep(args) | ashlr__grep |
ctx.read(args) | ashlr__read |
ctx.ls(args) | ashlr__ls |
ctx.glob(args) | ashlr__glob |
ctx.bash(args) | ashlr__bash — only when ASHLR_PIPE_ALLOW_BASH=1 |
Each method accepts an argument object matching the wrapped tool and returns its text output as a string, which may include status messages. Methods are async and must be awaited. The expression receives ctx and runs in strict mode; the deny-list is a best-effort guardrail, not a sandbox. The pipe serializes the return value as JSON.
Deny-list
The following are blocked regardless of flags:
- File writes (
write,edit,multi_edit) - Destructive shell commands (even with
ASHLR_PIPE_ALLOW_BASH=1, commands matching the deny-list inpipe-server.tsare rejected) - Network calls outside the listed functions
process.exit,require, dynamicimport
Token accounting
ashlr__pipe suppresses per-call accounting for intermediate tool invocations and records a single entry:
This prevents double-counting in /ashlr-savings.
Example — filter TODO output for auth
This returns up to 20 lines containing auth from the grep tool's text. If
none do, it returns No auth lines found. The filter operates on text, so a
status message containing auth can also be included; intermediate output may
be capped.
Limitations
- Experimental: API may change before stable release.
expris limited to 2000 characters.expris an async function body, so it can useawaitdirectly.- Errors inside
exprsurface asisError: trueresponses with the JS error message. bashinside pipe is a separate opt-in flag (ASHLR_PIPE_ALLOW_BASH=1) to prevent accidental shell execution.
Related
ashlr__grep— genome-aware searchashlr__read— snipCompact file reads- Env vars —
ASHLR_PIPE_ENABLE,ASHLR_PIPE_ALLOW_BASH - Tools capabilities matrix — all 54 tools at a glance