RLM Tools

io.github.stefanoshea由 GitHub 帳號 stefanoshea 發布v0.1.0更新於 Oct 24, 2026

Persistent Python sandbox for token-efficient codebase exploration in MCP clients

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

一個本機 Python 沙箱 MCP 伺服器,讓 AI 程式助理在伺服器端探索程式碼庫並只回傳精簡摘要,藉此降低上下文用量。

可以做什麼
RLM Tools 提供三個 MCP 工具:rlm_start 在某個目錄上開啟工作階段,rlm_execute 在常駐沙箱中執行 Python,rlm_end 關閉工作階段並釋放資源。沙箱內提供 read_file、read_files、grep、grep_summary、grep_read、glob_files、tree 等輔助函式,以及選用的 llm_query 子模型分析。變數在多次 execute 呼叫之間保留,原始檔案與搜尋結果留在沙箱記憶體中,只有 print 輸出會進入模型上下文。
適用情境
適合在大型程式碼庫上工作的助理,避免把大量 grep、glob 與檔案讀取的原始輸出塞進上下文。適用於探索、搜尋與理解模組等只需結論進入模型的場景。它是標準 MCP 伺服器,可用於 Claude Code、Codex、Cursor 等用戶端。
執行需求
透過 stdio 在本機執行,從 PyPI 安裝 rlm-tools 並以 uvx 啟動,因此需要 Python/uv 執行環境。核心的讀取、grep、glob 與 tree 功能不需要 API 金鑰。選用的 llm_query 需要環境變數 ANTHROPIC_API_KEY 並呼叫 Anthropic API。選用設定包括 RLM_SUB_MODEL、RLM_MAX_SESSIONS 與 RLM_SESSION_TIMEOUT。
安裝前請注意
沙箱被描述為唯讀、限定在工作階段目錄內、阻擋路徑穿越,僅允許安全的 stdlib 匯入,並封鎖 exec、eval、compile 與 import。選用的 llm_query 會把提示與上下文送往 Anthropic API,需要 ANTHROPIC_API_KEY,因此傳給它的程式碼內容會離開本機。工作階段會占用資源,並受逾時與呼叫頻率限制約束。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 RLM Tools,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

RLM Tools

Your AI coding agent spends most of its token budget just reading your code — not reasoning about it. Every grep, file read, and glob result gets dumped into the conversation. On a large codebase, that's 25-35% of your context (and cost) burned on raw data the model never needed to see.

RLM Tools gives your agent a persistent sandbox to explore code in. Data stays server-side. Only the conclusions come back.

bash
# Install in one line (Claude Code)claude mcp add rlm-tools -- uvx rlm-tools
# Or Codexcodex mcp add rlm-tools -- uvx rlm-tools

That's it. Your agent automatically uses the sandbox for exploration. No config, no prompting changes.

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. Data stays in sandbox memory. Only the print() output enters context:

python
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

In typical coding workflows: 25-35% context reduction. That means your agent can explore roughly 40-50% more code before hitting context limits.

In heavy exploration tasks (reading many files, broad searches), savings go much further:

ScenarioStandard ToolsRLM ToolsSaved
Grep across full app40,045 chars1,644 chars95.9%
Read 10 large files1,493,720 chars13,588 chars99.1%
Multi-step exploration136,102 chars5,285 chars96.1%
Grep then read matches340,408 chars6,022 chars98.2%
Find all usages of a pattern13,478 chars3,691 chars72.6%
Understand a module94,745 chars16,925 chars82.1%

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

How It Works

Three MCP tools. That's the entire API:

ToolPurpose
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) — Sub-LLM analysis (optional, requires API key)

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.

Works With

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

Other installation methods

JSON MCP config (Cursor, Windsurf, etc.)

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

Direct run

bash
uvx rlm-tools

From source

bash
git clone https://github.com/stefanoshea/rlm-tools.gitcd rlm-toolsuv syncuv run rlm-tools

Then point your MCP client to command: uv, args: ["--directory", "/path/to/rlm-tools", "run", "rlm-tools"].

Configuration

Copy .env.example to .env to customize. All settings are optional — RLM Tools works out of the box with zero config.

The core exploration features (read, grep, glob, tree) require no API key. The optional llm_query() helper calls the Anthropic API for semantic analysis within the sandbox — this is the only feature that requires a key.

VariableDefaultDescription
ANTHROPIC_API_KEY—Required for llm_query() only. Uses Anthropic's API (Claude).
RLM_SUB_MODELclaude-haiku-4-5-20251001Claude model used for llm_query()
RLM_MAX_SESSIONS5Max concurrent sessions
RLM_SESSION_TIMEOUT10Session timeout in minutes

Security

The sandbox is read-only and restricted:

  • Imports: Safe stdlib only (re, json, collections, math, etc.)
  • Builtins: Blocks exec, eval, compile, __import__, breakpoint
  • File access: Read-only, scoped to session directory, path traversal blocked
  • Execution: Configurable per-call timeout (default 30s)
  • Rate limits: Configurable max calls per session

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

bash
git clone https://github.com/stefanoshea/rlm-tools.gitcd rlm-toolsuv sync --devpytest tests

Run comparative benchmarks (requires a local project checkout):

bash
RLM_EVAL_PROJECT_PATH=/path/to/project pytest evals -q -s

License

MIT

來源:README.md,提交 81c1062

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分