Journeys
Journey: Extend Without Forking: Plugins & WASM
Extend the context layer without patching its source. Declare a tool in a plugin manifest, react to lifecycle hooks, or compile a custom compressor or chunker to a sandboxed WASM module — each is discovered, advertised in /v1/capabilities and conformance-checked exactly like a built-in.
You areadding your own tools, compressors or providers
plugin.toml[[tools]]hooksLEAN_CTX_WASM_DIRconformance/v1/capabilities
You need a domain tool (an internal lookup) and a custom compressor for your data shape. Forking the engine and maintaining a patched build is a non-starter. LeanCTX gives you two ways to extend it, neither of which touches its source — and one command that installs either.
1. A tool the agent can call — declare an MCP server
Your tool already speaks MCP, or you write it in whatever language you like and give it an MCP interface. It stays yours: your repo, your release cadence, your process. LeanCTX only needs to know how to run it.
# lean-ctx-addon.toml
[addon]
name = "crm"
version = "0.1.0"
description = "Look up an account in the CRM"
[mcp]
transport = "stdio"
command = "crm-bin"
args = ["mcp", "serve"]
sha256 = "…" # optional pin; checked before every spawn
integration = "memory" # optional: fold results into ctx_knowledge
lean-ctx addon add ./crm-0.1.0.ctxpkg
LeanCTX prints the exact command it would spawn, says plainly that the server
runs as a normal process with your privileges, and asks. It does not install
the binary for you — no uv tool install, no npx. Fetching crm-bin stays
your step, where your own package manager’s trust model applies.
2. A custom compressor or context provider — WASM
This one has to run inside the pipeline, so it is a sandboxed WASM module
compiled from any language that targets wasm32-unknown-unknown:
lean-ctx addon release ./my-compressor # signed .ctxpkg, module embedded
lean-ctx addon add ./my-compressor-1.0.0.ctxpkg
The module travels inside the signed package. No artifact host, no checksum files, no CI of your own: the signature covers the executable bytes, so there is nothing external to serve and nothing to download at install time.
/v1/capabilities → extensions.compressors: ["identity","markdown","prose","whitespace","my_ext"]
conformance scorecard → [ok] extensions/compressor:my_ext
While authoring, skip packaging entirely:
export LEAN_CTX_WASM_DIR=~/.local/share/lean-ctx/wasm # *.wasm → registered compressors
lean-ctx conformance # checked like a built-in
That override is a developer convenience with none of the install-time verification — not a distribution path.
3. Under the hood — core/context_package + core/wasm_ext.rs
Install verifies the package signature locally rather than trusting its source, checks every module against its pinned SHA-256 and the WebAssembly magic bytes, and writes modules read-only, never executable — they are fed to an interpreter, not to the OS loader.
At runtime the WASM host implements wasm-abi-v1 (alloc +
lctx_compress / lctx_provider_fetch) with a fresh store per call, no ambient
environment, and a byte budget the host applies after decoding, so a faulty
or hostile guest can never overrun it. Declared MCP servers go through the
gateway instead: global-only, opt-in, and pinned to a binary digest when the
manifest says so.
Payoff
The engine is extensible in any language, verified at install, discoverable and conformance-checked — your tools and transforms are first-class without ever touching LeanCTX’s source, and without needing a release pipeline of your own.