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 分