Skip to main content
Glama

RLM Tools

RLM Tools gives coding agents a read-only Python sandbox for exploring a repository. An agent can search files, keep results in memory across calls, and return a count, a list of paths, or a short excerpt to the conversation. Local exploration needs no API key. Optional model helpers can send repository content to an external provider when you enable them for that workspace.

Plugins & Extensions

The 0.1.3 plugins register the MCP server and install the rlm-explore skill for Codex CLI, Claude Code, and Gemini CLI. The server runs on macOS and Linux and requires uvx on the client's PATH. Run uvx --version in your terminal to check. Linux also requires libseccomp.so.2. Release notes · Install uv

For Cursor, VS Code, Kiro, and standalone MCP setup, see other clients and installation methods.

Codex CLI

Install the plugin once from your terminal.

codex plugin marketplace add stefanoshea/rlm-tools
codex plugin add rlm-tools@rlm-tools

Each time you start Codex, run this from the repository you want to explore. Codex launches the server in the installed plugin directory, so the workspace grant tells it which checkout it can read.

RLM_ALLOWED_ROOTS="$(pwd -P)" codex --no-daemon

Claude Code

Open Claude Code in your repository and enter these commands at the Claude prompt.

/plugin marketplace add stefanoshea/rlm-tools
/plugin install rlm-tools@rlm-tools

Gemini CLI

Install the extension from your terminal.

gemini extensions install https://github.com/stefanoshea/rlm-tools

Restart Gemini in your repository and run /skills list. You should see rlm-explore, ready to load when an exploration task needs it.

Try it

Try this prompt in the client you just configured.

Use RLM Tools to list the top-level directories in this repository, then close the session.

The agent should call rlm_start, run tree(max_depth=1) through rlm_execute, and finish with rlm_end. If startup returns Directory outside RLM_ALLOWED_ROOTS, check that the MCP server received the absolute path to your checkout. Workspace configuration

Related MCP server: projscan

What Changes

Without RLM Tools — agent greps for import UIKit, gets 500 matches dumped into context. Reads 10 files, burns all their content as tokens. Context window fills up. Agent forgets what it was doing.

With RLM Tools — agent runs the same exploration in a server-side Python sandbox. In this example, only the printed summary enters the agent's context:

matches = grep("import UIKit")
by_module = {}
for m in matches:
    module = m["file"].split("/")[0]
    by_module.setdefault(module, []).append(m)
for module, ms in sorted(by_module.items(), key=lambda x: -len(x[1]))[:5]:
    print(f"{module}: {len(ms)} files")

500 lines of grep results become 5 lines of summary. The agent sees what it needs, nothing more.

Real-World Impact

On the four checked-in Python and TypeScript fixture tasks, the RLM scripts used 13.6% to 54.5% fewer estimated context characters than the baseline file and search operations. The estimate counts script or tool arguments, returned text, and 350 characters of overhead per measured turn. It excludes session startup and teardown. Run uv run --extra dev python -m pytest evals/test_comparative.py -q -s for the per-task counts. The prompt benchmark measures root-agent token usage and answer quality separately.

In heavy exploration tasks (reading many files, broad searches), savings go much further. The table below is a worst-case comparison: the "Standard Tools" baseline dumps full grep/file payloads into context, which is the upper bound on what naive tool use costs — a careful agent dumps less. Treat these as the ceiling on savings, not the typical case, and look at the scored evals for whether answer quality holds up at those reductions.

Scenario

Standard Tools

RLM Tools

Saved

Grep across full app

40,045 chars

1,644 chars

95.9%

Read 10 large files

1,493,720 chars

13,588 chars

99.1%

Multi-step exploration

136,102 chars

5,285 chars

96.1%

Grep then read matches

340,408 chars

6,022 chars

98.2%

Find all usages of a pattern

13,478 chars

3,691 chars

72.6%

Understand a module

94,745 chars

16,925 chars

82.1%

Full benchmark methodology and reproduction steps: docs/benchmarks.md

Scored Evals

The repo now carries fixture-backed, always-runnable evals under evals/ plus checked-in corpora under tests/fixtures/.

  • evals/test_correctness.py checks helper semantics and security boundaries

  • evals/test_task_completion.py checks multi-step task workflows

  • evals/test_comparative.py keeps context-size microbenchmarks

  • evals/test_robustness.py checks error handling and timeout behavior

  • evals/test_session_effectiveness.py compares a complete session with targeted Read/Grep, including follow-ups where the baseline can reuse its first result

  • evals/test_longcontext_quality.py checks grounded answers and plausible wrong answers on the long-context fixture

  • evals/test_evidence_effectiveness.py measures how much tool output the recursive loop replays while checking whether the answer survives filtering

  • evals/test_stdio_workflow.py exercises independent sessions and compact responses through the actual stdio server

Prompt benchmarks are defined in evals/specs/rlm_core.json and the harder evals/specs/rlm_long_context.json, graded by evals/grade_eval.py, and aggregated with variance notes plus a pass-rate-first preferred-config summary by evals/aggregate_benchmark.py.

How It Works

Three MCP tools. That's the entire API:

Tool

Purpose

rlm_start(path, query)

Open a session on a directory

rlm_execute(session_id, code)

Run Python in the sandbox

rlm_end(session_id)

Close session, free resources

The sandbox provides built-in helpers:

  • read_file(path) / read_files(paths) — Read files into variables (cached across calls)

  • grep(pattern) / grep_summary(pattern) / grep_read(pattern) — Search

  • glob_files(pattern) — Find files by pattern

  • tree(path, max_depth) — Directory structure

  • llm_query(prompt, context) / llm_query_batched(prompts, context) — Sub-LLM analysis (optional, requires API key)

  • rlm_recurse(prompt, context) / rlm_recurse_batched(prompts, context) — Ask a sub-agent to explore the session directory (optional, requires API key)

  • rlm_finalize(value) — Return structured final output in rlm_execute responses

Variables persist across rlm_execute calls within a session. The agent can build up understanding incrementally — search, filter, read, analyze — without any intermediate data touching the context window.

Evidence Gate

A rlm_recurse sub-agent re-sends every tool result on every turn of its loop, so a large file read is paid for once per remaining turn. When TypeSafe scoring is enabled, each result is scored in chunks before it joins that history and only the parts bearing on the question are kept:

worker_runtime.py   12,247 -> 1,256 chars   1 of 9 chunks kept
server.py           15,924 -> 1,491 chars   1 of 11 chunks kept
helpers.py           9,200 -> 3,193 chars   2 of 7 chunks kept

81% of bytes dropped across those reads with every answer still intact. Scoring is batched, so judging a dozen chunks costs about what judging one costs.

The gate fails open. A scoring error, an exhausted call budget, a result too small to judge, a flat score distribution, or an exhaustive question (every, all, list) all return the original text untouched — exhaustive questions need every mention, and relevance scores cannot tell the last one from noise.

The gate uses TypeSafe System One models. To enable it, run the server with the semantic extra (uvx --from 'rlm-tools[semantic]' rlm-tools) and pass both API keys, set RLM_RECURSE_GATE=1, and include the repository in RLM_EXTERNAL_ROOTS. TypeSafe receives the question and candidate excerpts, including excerpts the gate later drops.

Works With

RLM Tools is a standard MCP server. It works with any MCP-compatible client: Claude Code, Codex, Cursor, and others.

Other clients

  • Cursor, VS Code / GitHub Copilot, and Amazon Kiro can use the Agent Plugins 1.0 package in plugins/rlm-tools. If your client starts the server from the plugin directory, set RLM_ALLOWED_ROOTS to the absolute checkout path in the server environment.

  • Agent Skills clients such as Windsurf, OpenCode, Cline, and Zed can use the standalone skill alongside a standard MCP registration for uvx rlm-tools.

Optional Strict Mode

If your MCP client supports tool permissions or hooks, disable/block default read/grep/glob tools for repository exploration and keep rlm-tools enabled. This is the strongest way to force the token-efficient path.

JSON MCP config (Cursor, Windsurf, etc.)

{
  "mcpServers": {
    "rlm-tools": {
      "command": "uvx",
      "args": ["rlm-tools"]
    }
  }
}

Setup helper command

To configure a single client and write exploration guidance into the current repository, run the corresponding command from its root.

# Codex
uvx --from rlm-tools rlm-tools-setup --client codex --write-policy AGENTS.md

# Claude Code
uvx --from rlm-tools rlm-tools-setup --client claude --write-policy CLAUDE.md

To register just the server manually, use codex mcp add rlm-tools -- uvx rlm-tools or claude mcp add rlm-tools -- uvx rlm-tools.

# Auto-detect Claude/Codex CLIs and configure rlm-tools
uvx --from rlm-tools rlm-tools-setup

# Print JSON config snippet for other clients
uvx --from rlm-tools rlm-tools-setup --print-json

# Print policy text instead of writing it
uvx --from rlm-tools rlm-tools-setup --print-policy

Direct run

uvx rlm-tools

From source

git clone https://github.com/stefanoshea/rlm-tools.git
cd rlm-tools
uv sync
uv run rlm-tools

Then point your MCP client to command: uv, args: ["--directory", "/path/to/rlm-tools", "run", "rlm-tools"], and set RLM_ALLOWED_ROOTS to the checkout you want to explore.

Configuration

Set these variables in the MCP server environment and restart the server after changing them. By default, the server allows exploration underneath its launch directory. If a client launches it from your home directory or the filesystem root, configure an explicit workspace. Multiple roots use the platform path separator (: on macOS and Linux).

For example, this configuration permits local exploration of two repositories and enables Anthropic helpers only for the second, when the server also has an Anthropic key:

{
  "RLM_ALLOWED_ROOTS": "/work/private:/work/shareable",
  "RLM_EXTERNAL_ROOTS": "/work/shareable"
}

A grant covers the named directory and its descendants. Keep private repositories outside roots granted external processing. Anthropic receives the prompts, context, and tool results used by the model helpers. Enabling the optional TypeSafe gate also sends the question and candidate excerpts to TypeSafe. Ordinary read, grep, glob, and tree operations require no provider. Keep real credentials in your client's secret configuration or an environment file outside the explored checkout.

Variable

Default

Description

RLM_ALLOWED_ROOTS

Server launch directory, except home or filesystem root

Absolute directories the operator permits sessions to explore. An explicitly empty list denies all roots.

RLM_EXTERNAL_ROOTS

Empty

Subset of allowed directories eligible for external model helpers.

ANTHROPIC_API_KEY

—

Enables Anthropic model helpers for external-enabled sessions.

TYPESAFE_API_KEY

—

Credential for optional TypeSafe scoring.

TYPESAFE_DEFAULT_MODEL

jev-latest

System One model used by the evidence gate

RLM_RECURSE_GATE

0

Set to 1 to enable TypeSafe scoring for external-enabled Anthropic sessions.

RLM_SUB_MODEL

claude-haiku-4-5-20251001

Claude model used for llm_query()/rlm_recurse()

RLM_SUB_TIMEOUT_SECONDS

60

Per-request timeout for sub-LLM calls

RLM_SUB_MAX_RETRIES

3

Retry attempts for transient sub-LLM failures

RLM_RECURSE_MAX_DEPTH

2

Max recursion depth for rlm_recurse() child agents

RLM_MAX_SESSIONS

5

Max concurrent sessions

RLM_SESSION_TIMEOUT

10

Session timeout in minutes

Security

The stdio server is designed for one local MCP client. It starts each Python worker with an empty environment, a private IPC socket, and isolated Python startup. macOS uses Seatbelt. Linux requires libseccomp.so.2 and permits the system calls needed for computation and the private socket. Worker startup fails if the OS or launcher cannot apply the policy, including hosts that forbid nested macOS sandboxing. The trusted parent holds repository descriptors and provider credentials.

  • A session can open only an operator-approved directory. Helpers open paths relative to a retained directory descriptor, skip symlinks and multiply linked files, and read regular files only. They exclude Git metadata, local MCP configuration, registry token files, and .env variants except .env.example, .env.sample, and .env.template. Other files within the root can be returned to the agent.

  • Reads, batches, regex searches, directory scans, and IPC messages have size limits. A file read returns at most 4 MiB of source text plus a truncation marker. Grep uses RE2 syntax and a 1 MiB engine memory budget. For patterns that need Python lookaround or backreferences, apply the worker's re module to a bounded file read. Narrow the path or pattern when a search reports a limit. Metadata can include truncated: true.

  • Python imports expose selected public names from approved standard-library modules. Relative imports, private attributes, and wrapper helpers are restricted inside the OS-confined worker.

  • Workers enforce an execution timeout, restrict Python imports and builtins, and bound printed output. CPU and address-space backstops depend on OS support. Parent-side model requests use the remaining execution time for their network timeouts. An in-flight filesystem or network operation can still delay a response.

  • Model helpers are enabled per root. A local session never registers them, even when the server has provider credentials. Treat any root enabled for external processing as shareable with the selected providers.

Background

RLM Tools implements an RLM-style exploration loop: keep raw data in tool-side memory, send only compact outputs to the model. Built on the Model Context Protocol.

Development

git clone https://github.com/stefanoshea/rlm-tools.git
cd rlm-tools
uv sync --locked --extra dev
uv run --no-sync python -m pytest

Run fixture-backed evals:

uv run --extra dev python -m pytest evals -q

Run comparative benchmarks:

uv run --extra dev python -m pytest evals/test_comparative.py -q -s

Run scored prompt benchmarks:

./evals/run_ab_eval.sh

By default this now runs the checked-in long-context benchmark corpus at tests/fixtures/rlm_corpus_longcontext. Use RLM_AB_SPEC_PATH and RLM_AB_TARGET_PATH to switch back to lighter smoke-style cases or to point at a different corpus.

Rlm Tools MCP server

License

MIT

Available Tools

3 tools
rlm_endA

End an RLM exploration session and free resources.

Inputs: session_id (required). Returns: result

rlm_executeA

Execute Python in the session sandbox. detail_level controls response payload size (compact, usage, or full).

Inputs: code (required), session_id (required), detail_level, max_new_variables. Returns: result

rlm_startC

Start an RLM exploration session. Returns session_id, metadata, limits, and available functions. Set include_guidance=true to include strategy/example coaching text.

Inputs: path (required), query (required), max_llm_calls, include_guidance, +5 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 3 tools

    Disambiguation5/5

    The three tools map to clearly distinct lifecycle actions: start, end, and execute. There is no overlap between starting a session, ending it, and running code within it.

    Naming Consistency5/5

    All tools use the same rlm_ prefix followed by a concise snake_case verb. The pattern is predictable and easy to extend.

    Tool Count5/5

    Three tools is a tight, sufficient surface for a session-based Python sandbox: create session, use session, destroy session. Each tool earns its place without extraneous operations.

    Completeness4/5

    The core session lifecycle is fully covered, but there is no explicit status/list or interrupt operation outside of executing code. Agents can likely work around this via the sandbox, but a direct session inspection tool would make the surface more complete.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers