Skip to content

gl_run — Code Mode

One tool. Runs sandboxed JavaScript. Calls every other Ganglia tool through typed wrappers. Collapses N sequential tool calls into a single MCP round trip.

gl_run({ code: "return gl.code.overview()" })
gl_run({ code: `
// Find dead code that has no tests — 1 call instead of 50
const dead = gl.code.dead({});
const coverage = dead.map(fn => gl.code.test_for({ name: fn.name }));
return dead.filter((_, i) => coverage[i].tests.length === 0);
` })

Server runs the chain internally. Only the final filtered list comes back.

All wrappers are synchronous from JS. Group by domain:

NamespaceUse for
gl.code.*The 45 core graph tools — grep, get, dead, callers, impact, etc.
gl.code.semantic_search / similarEmbedding-based retrieval
gl.doc.*External document index (markdown, CSV, etc.)
gl.smart.*MemOS comprehension layer
gl.deliberation.*Expert panel multi-perspective synthesis
gl.call(name, args)Escape hatch for any registered MCP tool

Full typed API: ganglia://types/api.d.ts (MCP resource).

  • 3+ sequential tool calls — the math overwhelmingly favors gl_run
  • Filter/transform/aggregate before returning — don’t force intermediate results through your context
  • Map-style operations — “for each X, compute Y” patterns
  • Single-shot lookup (code_get, code_grep directly)
  • Exploratory — you need to see each result to decide the next step
  • The chain needs real await on network I/O (sandbox is sync only)
LimitValue
Memory256 MB
Time30 s
Filesystemblocked
Networkblocked
Processblocked
Recursive gl_runblocked

QuickJS embedded directly in the gl binary. No external runtime.

Got the wrong method name? The Proxy wrapper shows you what’s available:

> gl.code.rgep({pattern: "foo"})
Error: Unknown method gl.code.rgep — available: annotate, build, callees,
callers, ..., grep, hotspots, ...

And for gl.call(name):

> gl.call("code_rgep", {...})
Error: Unknown tool: code_rgep (did you mean `code_grep`?)

On a 462-file Rust project, 5 multi-step workflows:

MetricIndividual toolsgl_runReduction
Schema tokens6,37657591%
Wire tokens4,0142,3161.7×
Effective LLM context170,4249,19118.9×

Run it on your own codebase: python3 scripts/benchmark_code_mode.py <path>