Skip to content

feat: every MCP tool from the shell with slm tool, and an slm-cli skill - #336

Merged
varun369 merged 8 commits into
mainfrom
feat/slm-tool-cli
Nov 20, 2026
Merged

varun369 merged 8 commits into
mainfrom
feat/slm-tool-cli

Conversation

@varun369

Copy link
Copy Markdown
Member

What

slm tool — every MCP tool from a shell, for an agent that can run commands but does not have the SuperLocalMemory MCP server.

slm tool list [--json] [--tool-set NAME]        # 112 tools, one line each
slm tool describe <name> [--json]               # description + input schema
slm tool recall --query "auth flow" --limit 5   # call it (--key value)
slm tool remember --json '{"content": "..."}'   # or --json / --args-file PATH / - (stdin)

Plus a generated slm-cli skill, shipped to every host plugin, that teaches the session protocol by command (start, recall before answering or searching, cue check before editing, remember decisions, pictures and PDFs, close) and lists every tool with its CLI form.

Why

About 30 tools had no CLI form at all (pictures and PDFs, mesh messaging, the code graph, learning signals, assertions, retention, Brain evidence and more). When the MCP server is not available to the agent, those were unreachable, and the agent had no single description of how to run a session from the shell.

How

  • One registration. The register_* calls moved from mcp/server.py into mcp/tool_registry.register_tools, and the tool-set rules (essential set, mesh/image additions, precedence) into mcp/tool_surface. The MCP server and slm tool both use them, so names, descriptions, input schemas and admission gates cannot drift. The server's tool lists are byte-identical to main for whole, the default, core, code, full, power, mesh, an alias and an SLM_MCP_TOOLS allowlist (checked by dumping both before and after).
  • Same execution path as a stdio MCP app. slm tool builds the same SLMFastMCP host slm mcp builds (without its stdio watchdog, stdin monitor and warm-up threads) and calls call_tool, so every tool reaches the daemon exactly as it does over MCP, behind the same @admits / default read gate.
  • Channel from the door, never an argument. The process is the cli door: SLM_CLIENT_CHANNEL is set to cli before any daemon request, so a shell that exports mcp cannot relabel its decisions. The agent is SLM_AGENT_ID, read the way the stdio server reads it; an agent_id argument stays a claim.
  • Arguments checked before the call against the tool's published input schema (jsonschema), and an argument the tool does not take is refused (channel, agent_id_source, typos). Exit 0 success, 1 the tool answered with an error or refusal, 2 the call could not be made (unknown_tool, invalid_arguments with one line per problem, not_in_tool_set, unknown_tool_set). Output is the tool's JSON on stdout only.
  • Tool sets. Default is every tool (a tool set keeps an app's list short; each tool still checks who may call it). --tool-set core|code|full|power|mesh|whole applies the server's own filter; --tool-set mcp is exactly what an MCP connection on this computer sees now.
  • Skill generator. scripts/build_cli_skill.py renders plugin-src/skills/slm-cli/SKILL.md from the registry (--check for CI); the existing plugin builders ship it to Claude Code, Codex, Copilot, Cursor, Antigravity, Hermes, Muse and VS Code. A test fails when the committed skill drifts from the registry.
  • Docs. docs/cli-reference.md gains a slm tool section and the session protocol without MCP; docs/mcp-tools.md points to it.

Defects found and fixed on the way (CRIT)

  1. set_mode loaded the stdio server into the calling process. It imported mcp.server.reset_engine, which in a command-line process started the stdio watchdog and stdin monitor and turned the process channel into mcp. The host that registered the tools now hands its own reset (get_engine.reset); the stdio server keeps its old path. Proven by revert: the e2e test sees stdio_server_imported: True, channel: mcp without the fix.
  2. A daemon started by slm tool would mislabel MCP decisions as cli. The daemon inherits the caller's environment and the embedded MCP server only defaulted the channel. It now sets mcp (the MCP server is always the MCP door). Proven by revert.
  3. Mesh identity in a one-shot process. A fresh peer per call lost every inbox between calls. slm tool binds a session: --session, else SLM_SESSION_ID (or the host's session id), else one stable id per agent and folder. mesh_wait blocks for up to its 20 s bound and returns; the broker keeps a command-line peer for 30 minutes after its last call, which the docs and skill say, with project: / broadcast for longer waits.
  4. Schema drift and silent extra keys, handled by the single registration, parity tests over ten tool-set configurations, and the unknown-argument refusal.

Tests

  • tests/test_cli/test_slm_tool.py (23): registry (112 tools reachable), reserved option names, tool-set filter, channel claim, argument merge/coercion/refusal, result conversion (structured, plain-text refusal, images to files), mesh session binding, CLI form, the skill matches the registry and ships to every host.
  • tests/test_cli/test_slm_tool_parity.py (22): in fresh processes, slm tool lists exactly what mcp/server.py lists (title, description, input schema) for core, code, full, power, mesh, whole, the default, and --tool-set mcp under three connection settings; both register the same 112 tools; the entry point's JSON, exit codes and help; the MCP server says mcp even when started from slm tool.
  • tests/test_integration/test_slm_tool_real_daemon.py (10): one real isolated daemon (private port and data root) with an slm mcp stdio child beside it. Memory, pictures (tiny PNG), mesh send + inbox + wait between two agent ids, code graph on a tiny repo, and a learning signal give the same result shape through both doors; media_upload_link stays refused (not_for_local) through both; every daemon request from slm tool carries X-SLM-Channel: cli with SLM_CLIENT_CHANNEL=mcp in its environment while the MCP child (control) carries mcp; a channel argument is refused before any request; an agent_id argument is recorded as claimed_agent_id with the connection's agent kept; set_mode never loads the stdio server.
  • Non-vacuity (revert, fail, restore, pass): channel claim; unknown-argument refusal (4 tests fail); a drifted CLI registry (9 fail); a changed tool docstring (skill test fails); the set_mode reset hook; the forced mcp channel.
  • Packs run: tests/mcp, tests/test_mcp, tests/cli, tests/test_cli, CLI subparsers, plugin, plugin-src, hooks (codex assets), installers, CI guards, governance, docs-vs-implementation. Updated for the new skill and command: skill lists and counts in the codex/muse/vscode/hermes tests, the Hermes command inventory (tool is marked high-impact there), and the npm entry-count ceiling (300 -> 400: each plugin tree carries one more skill). node scripts/build-all-plugins.mjs --check and python scripts/build_cli_skill.py --check are in sync.
  • Pre-existing timing flakes seen only under parallel load and passing alone (also flaky on main): tests/mcp/test_loop_receipt_races.py::test_postexecution_job_refusal_never_publishes[expired], the native hook deadline tests, test_doctor_health_verdicts::test_deadline_text_mode_names_check_and_exits_one.

Not in this PR

  • No CHANGELOG entry: left for the release that ships it.
  • In-process admission records the transport as mcp (the tool layer's gates say so), while the decision channel is cli. That never grants more than MCP allows; giving the gates a per-host transport is a separate change in core/admission.

🤖 Generated with Claude Code

varun369 and others added 6 commits November 20, 2026 20:11
…kill for agents without MCP

`slm tool list | describe <name> | <name> [--json | --args-file | - | --key value]`
hosts the same tools, schemas and permission checks as the MCP server (one shared
registration), prints the tool's JSON result, and exits 0/1/2. Decisions made this
way are recorded on the cli channel; arguments the tool does not take are refused.
The generated slm-cli skill teaches the session protocol by command and lists every
tool, and ships to every host plugin.

Also: set_mode no longer loads the stdio MCP server into the calling process, and an
MCP server always reports the mcp channel even when started from a CLI process.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…us callers as that agent

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…usage error is JSON on stdout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… later tests see a clean environment

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@varun369
varun369 merged commit 2cf140b into main Nov 20, 2026
10 checks passed
@varun369
varun369 deleted the feat/slm-tool-cli branch November 20, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant