STM CLI Reference
The mms command is installed with the memtomem-stm v0.7.10 package. This page mirrors the complete top-level command surface; run mms <command> --help for the installed option spelling and mms --version (or mms version) for the runtime version.
STM’s import is reversible. Pulling an upstream behind the STM proxy preserves its original registration, so if the result isn’t what you want, mms eject restores it to the original host MCP-client config.
Setup & Registration
Section titled “Setup & Registration”mms init
Section titled “mms init”For a deterministic first success, create the bundled read-only demo, register a detected client, and run the end-to-end diagnostic:
mms init --demo --client automms doctorWith no selection flags, the wizard asks for one upstream, optionally probes it, writes the proxy config, and offers client registration. Current client choices are auto, claude, codex, json, and skip; --mcp claude|json|skip remains a compatibility spelling.
| Option | Description |
|---|---|
--config PATH | Proxy config path (default ~/.memtomem/stm_proxy.json) |
--no-validate | Skip the optional connectivity probe |
--client auto|claude|codex|json|skip | Select current client registration flow |
--mcp claude|json|skip | Compatibility spelling for the older registration flow |
--resume | Continue client registration when the proxy config already exists |
--demo | Configure the bundled deterministic read-only server |
--freshness live|balanced|reuse | Response-cache freshness preset (default balanced) |
--allow-project-configs | Acknowledge discovery of project-local MCP configs |
--replace-registration | Replace an existing selected-client registration |
--save-unverified | Save when an optional connection probe fails |
--json | Emit one JSON result document |
--prune-originals | Remove imported direct host registrations after successful setup |
--lang en|ko | Token-budget language preset; ko writes CJK-specific ratios and limits |
--lang ko writes Korean / CJK token-equivalent defaults: chars_per_token=1.85, default_max_result_chars=8500, and a per-server max_result_tokens=2000. Non-TTY callers default to en when --lang is omitted.
mms init normally aborts if the config exists. Use --resume for the interrupted registration stage, mms add for more upstreams, or mms register to register another host without changing the proxy config.
mms register
Section titled “mms register”Re-run the MCP-client registration flow after mms init. Useful if you picked skip the first time or want to re-register after reinstalling the client.
mms register --client auto # detected supported clientmms register --client claude # Claude Codemms register --client codex # Codexmms register --client json # write .mcp.json in cwdmms register --client skip # print manual registration hintsThe complete options are --config, --client auto|claude|codex|json|skip, compatibility --mcp claude|json|skip, --replace-registration, and --json. It is safe to re-run; an existing selected-client registration is kept unless replacement is requested.
mms register writes <python> -P -m memtomem_stm (and mms init --demo writes args: ["-P", "-m", "memtomem_stm.demo_server"]) so Python does not prepend an untrusted working directory to sys.path (GHSA-2p94-5932-5f3p). When upgrading from before 0.7.8, refresh existing registrations with mms register --client json --replace-registration (per project .mcp.json), mms register --client claude --replace-registration, or mms register --client codex --replace-registration (passing the same --config <path> if non-default), insert "-P" before "-m" in any hand-edited host config, and update upstream_servers.demo.args in stm_proxy.json to ["-P", "-m", "memtomem_stm.demo_server"] (mms init --demo --resume leaves an existing entry unchanged).
mms add <name>
Section titled “mms add <name>”Register an upstream MCP server to proxy through STM.
mms add filesystem --command filesystem-server --prefix fsmms add github --command github-mcp --args "--token $GH_TOKEN" --prefix ghmms add remote-api --transport streamable_http --url https://example/mcp --prefix apimms add filesystem --command filesystem-server --prefix fs --validate| Flag | Description |
|---|---|
--command | Executable command (stdio transport) |
--args | Space-separated arguments |
--prefix | Tool namespace (required unless --from-clients); tools appear as {prefix}__{tool} |
--transport | stdio (default), sse, or streamable_http |
--url | Endpoint URL for sse / streamable_http |
--env KEY=VALUE | Environment variable to forward to the upstream process (repeatable) |
--header KEY=VALUE | Plaintext header for sse / streamable_http (repeatable; config file is mode 0600) |
--compression | auto (default), none, truncate, selective, hybrid |
--max-chars | Per-server character budget. Omitted by default, so nothing is written and the server inherits the model-aware global budget (default_max_result_chars, 16,000 by default); pass a value to pin one |
--validate | Probe the server (MCP initialize + list-tools) before saving |
--timeout | Probe timeout in seconds when --validate is set (default 10) |
--json | Emit one JSON result document |
Bulk import from MCP clients
Section titled “Bulk import from MCP clients”mms add --from-clients (alias --import) discovers servers registered with Claude Desktop, Claude Code, and project .mcp.json files and imports them into the STM proxy config (stm_proxy.json) — reusing mms init’s discovery + TUI flow. Servers already registered in this proxy config are skipped. (This is a different command from mms import, which copies host configs into ~/.mms/registry.toml.)
mms add --from-clients # interactive bulk importmms add --import # aliasmms add --from-clients --prune # also remove the direct registration from each source clientAfter a successful import, the same server is advertised on two paths — direct from the source client and via STM’s proxied namespace — and the direct path bypasses compression, caching, and LTM surfacing. Each imported entry also records its provenance — the source-client kind plus a copy of the original registration — so mms eject can restore it at any time.
--prune (or an interactive confirm prompt shown in TTY, defaulting to No) closes the dual-registration by calling claude mcp remove for each Claude Code scope and atomically rewriting the Claude Desktop JSON. Each pruned entry is backed up to ~/.memtomem/pruned_upstreams.json first, so the cleanup is undoable too. Non-TTY callers without --prune keep the hint-only behavior — the import still succeeds, and the warning prints the exact manual removal command.
Incompatible with NAME / --prefix / --command / --args / --url / --env. --prune requires --from-clients / --import.
Host discovery
Section titled “Host discovery”mms init, mms add --from-clients and mms prune read Claude Code’s config the way Claude Code does: $CLAUDE_CONFIG_DIR/.claude.json when CLAUDE_CONFIG_DIR is an absolute path, otherwise ~/.claude.json, and within it the project entry of the repository root, so a subdirectory finds the servers registered at the root. In a linked worktree, a submodule or behind a symlinked .git, no project entry is read. When STM cannot tell which file Claude Code reads (for example a relative or empty CLAUDE_CONFIG_DIR, a set CLAUDE_CODE_CUSTOM_OAUTH_URL, or a legacy .config.json in Claude Code’s config directory), it reads no Claude Code user or project servers and prints a note; <cwd>/.mcp.json is still read. mms import, mms host and mms eject follow the same rules.
mms import and mms host read Codex’s user config from $CODEX_HOME/config.toml, or from ~/.codex/config.toml when CODEX_HOME is unset or empty. When CODEX_HOME is relative or has a . or .. path component, they read no Codex config.
mms init, mms add --from-clients and mms prune also name servers that bypass STM, without importing them:
- Claude Code plugin servers: when
claudeis onPATH, they runclaude plugin list --jsonin the current directory and list each MCP server an enabled plugin registers, as/mcpshows it (plugin:<plugin>:<server>). STM does not proxy those servers. To route one through STM, add it withmms add … --validateand then disable the plugin’s copy.--jsoncarries the rows inplugin_bypass, andplugin_bypass_disables_unreadsays why servers disabled in/mcpcould not be checked ("no_key","no_config", ornullwhen no reason was recorded). - Codex registrations outside the command’s discovery, by name only (
--json:codex_extra_servers,nullwhen the listing was unavailable).
mms import and mms host status|scan|sync print the same servers on stderr, without these JSON fields, and never import or remove a plugin’s server; mms doctor reports them as WARN rows. These host CLI listings are optional and can make network requests; set MMS_NO_HOST_PROBE=1 to skip them.
mms list
Section titled “mms list”List all registered upstream servers — the per-server view.
mms list # human-readablemms list --json # scriptable JSONThe table includes an ORIGIN column reporting each upstream’s import source. The value is the source-client kind (mcp-json, claude-user, claude-project, claude-desktop); manually mms add-ed entries show -. A trailing * marks an entry whose host original was pruned, so it now exists only behind STM — mms eject <name> restores it. As of v0.1.32 the table also carries a SURFACING column — the visible home of the per-server mms surfacing toggle.
The SOURCE column reports where each server definition comes from — file, env, or file+env — and servers defined only in the environment get rows too. COMPRESSION shows the resolved server default rather than the file’s value: a server that omits compression inherits default_compression, MEMTOMEM_STM_PROXY__* environment overrides are applied. When the file fails validation, the table shows the environment/default fallback that startup actually uses; unknown appears only when no runtime configuration can be built, such as an environment that startup rejects. Tables with at least one server end with COMPRESSION shows the resolved server default; tool overrides may differ. followed by one "server"/"tool": strategy (tool override) line per explicit tool-level compression. The table strips URL userinfo, query strings and fragments, and shows the arguments of rows the environment touches (env, file+env) as [args hidden]. Per-server max_result_chars has no column, because tool overrides can make it misleading; read it from --json or the config file.
With no upstream servers and a valid runtime configuration, mms list prints No upstream servers configured. followed by Run `mms add` (or `mms init`) to register an upstream.. The hint is left out when the file or the proxy environment fails validation, because adding an upstream would not fix that.
Scripts should read --json rather than parse the table. Its servers map still describes the file, while effective_servers, server_sources and effective_compression (keyed by server name, with strategy, source — server or global — and tool_overrides) describe the runtime view. They are {} when no runtime configuration can be built, and also when the effective configuration simply has no servers, so an empty map alone does not mean the configuration failed; read config_valid and config_error for that. Each effective_servers entry also carries the server’s resolved delivery_format and tool_delivery_overrides, the resolved format of each tool that has a tool_overrides entry.
mms status
Section titled “mms status”Answer “is the proxy set up and pointed at the right config?” — a config summary, not the per-server view.
mms statusmms status --json # scriptable JSONAs of v0.1.32 status is a summary: config path, the enabled flag, any schema-validation warning, and Servers: N (P host-pruned). Per-server detail (compression strategy, surfacing state) moved to mms list. status --json keeps its full redacted servers map and adds server_count / pruned_count, plus effective_server_count (null if environment parsing prevents startup). Its enabled field reports the runtime value after environment overrides whenever startup parsing succeeds.
The human-readable output ends with the next step to take: Run `mms config validate` to fix the proxy file. for a file error, Fix the runtime configuration named in the warning above first. when the environment keeps the server from starting (for example MEMTOMEM_STM_PROXY=[]), a pointer to mms list and mms health when servers are configured, and the mms add hint otherwise. --json does not carry this line.
list and status validate the configuration the way server startup does, so an environment variable that startup rejects marks the configuration invalid. config_error reports the location and type code of each error without values; a location can name a key, such as an env or header name, but never its value. Run mms config validate for the details of a file error.
mms remove <name>
Section titled “mms remove <name>”Remove a registered upstream server.
mms remove filesystem # confirmation promptmms remove filesystem -y # skip confirmationRemoving an imported server emits a hint pointing at mms eject, so the original host registration can be restored rather than lost.
mms prune
Section titled “mms prune”After registering upstreams via mms init or mms add --import, this removes the direct entries left in source MCP clients (Claude Code, Claude Desktop, project .mcp.json) so tool calls route through the STM proxy on a single path — picking up compression, caching, and LTM surfacing. It’s an explicit opt-in command.
mms prune --all # every dual-registered upstreammms prune filesystem github # specific namesmms prune --all --dry-run # show what would be pruned, no writesmms prune --all -y # skip the confirm prompt (CI)Each entry is backed up to ~/.memtomem/pruned_upstreams.json before removal, so the operation is reversible — use mms eject to restore the original client registration. STM’s own config (~/.memtomem/stm_proxy.json) is left alone.
mms eject <name>
Section titled “mms eject <name>”The inverse of prune. It restores an imported upstream back to its original host MCP-client config and only removes the STM entry once the restore is verified. This lets you try the STM proxy and back out safely if it isn’t what you want. Multiple names can be ejected at once.
mms eject filesystem # restore to host config, then remove the STM entrymms eject filesystem github # several at oncemms eject filesystem --dry-run # preview what would be restoredmms eject filesystem --keep # restore to host but keep the STM entry (dual registration)mms eject filesystem --yes # non-interactive — skip the confirm promptIt writes the verbatim host entry captured at import time (the provenance) back where it came from, verifies the restore against the host config, and only then removes the STM entry. If any step fails, the server stays registered in at least one place — worst case is dual registration, never a disappeared server.
Restores through claude mcp add-json (the claude-user and claude-project targets) check the entry’s env and headers with the same secret classifier as mms import, because those values would appear on the claude argv. On a TTY each such entry asks for confirmation; a non-TTY run, --json included, needs --allow-argv-secrets, and --yes never bypasses the gate. Since 0.7.10 the classifier catches more values, so an eject script that passed before may now need the flag. A failed restore prints a manual restore command that embeds the full payload, secrets included, in stderr and in --json failed[].hint; treat that output like the host config itself.
eject refuses, even with --force, when the target host config is unreadable or malformed, or when a Claude Code project entry was recorded in a linked worktree, a submodule or behind a symlinked .git. A Claude Code target also refuses when STM cannot tell which config file Claude Code reads (host discovery). In those cases, restore the entry manually from upstream_servers.<name>.origin.original in stm_proxy.json.
| Flag | Description |
|---|---|
--to TARGET | Restore target for entries without a recorded origin (claude-user / claude-project[:PATH] / mcp-json[:PATH] / claude-desktop). Entries with a recorded origin ignore this |
--keep | Restore to the host but keep the STM entry (dual registration) |
--force | Overwrite a same-name host entry whose identity differs |
--allow-argv-secrets | Permit claude mcp add-json restores whose env or headers carry secret-classified values (argv is visible in the process list); required outside a TTY, and not implied by --yes |
--accept-schema-loss | Proceed with STM removal even when the restored host entry does not structurally match the original (default keeps the STM entry and fails). A restore whose verify cannot read the host config, or finds no entry there, keeps the STM entry even with this flag |
--dry-run | Print the plan; no writes |
--yes / -y | Skip the confirm prompt (scripts / CI / non-TTY) |
Surfacing & Hooks
Section titled “Surfacing & Hooks”mms surfacing <server> [on|off]
Section titled “mms surfacing <server> [on|off]”Toggle proactive memory surfacing for a single upstream server. Omit the state argument to print the current value.
mms surfacing filesystem # show current statemms surfacing filesystem off # disable surfacing for this upstreammms surfacing filesystem on # re-enablesurfacing_enabled is written into the shared proxy config (stm_proxy.json). A running proxy hot-reloads it without a restart, and because the flag lives in the shared config rather than per-client env, every MCP client that proxies through this mms sees the same scope. See Proactive Surfacing for how surfacing works.
mms hook
Section titled “mms hook”Bridge supported host built-in tool calls into STM surfacing. Claude Code and compatible hosts call it as a PostToolUse hook: the JSON payload arrives on stdin, and mms hook prints hook output that can include additionalContext with surfaced memories. Bash output compression is separate, Claude-only and opt-in via MEMTOMEM_STM_HOOK__COMPRESSION__ENABLED=1, and it replaces output only when the hook command passes an explicit --host claude. A bare mms hook auto-detects the host, cannot tell Claude from Codex, and never replaces output. Since 0.7.10, on a call that auto-detection routes to the Claude adapter and that compression would have attempted (a Bash result that passes every check made before the compressor runs), the hook still passes the output through, but prints a warning to stderr and returns it as a top-level systemMessage.
{ "hooks": { "PostToolUse": [ { "matcher": "Read|Grep|Glob|WebFetch|Bash", "hooks": [{ "type": "command", "command": "mms hook --host claude" }] } ] }}mms hook install --host claude --apply writes an equivalent handler, whose command passes --host claude and explicit daemon, timeout and query-text flags, into Claude Code’s user settings ($CLAUDE_CONFIG_DIR/settings.json, otherwise ~/.claude/settings.json), not into project or local settings. It replaces the STM hook commands it recognizes in that file with one new command, carrying settings over from the first of them only and keeping, of that command’s inline env assignments, only the daemon, timeout and query-text settings, as flags. A command it does not recognize, such as MEMTOMEM_STM_HOOK__COMPRESSION__ENABLED=1 mms hook, stays next to the new one, and install names its location (hooks.PostToolUse[i].hooks[j]) when it looks like STM’s hook. To add --host claude to an existing registration, edit it by hand.
The hook always exits 0. If surfacing, the daemon, or compression fails, the host tool output passes through unchanged.
| Option | Description |
|---|---|
--host HOST | Host adapter. auto (the default) recognizes Cursor and Kimi payloads and a non-empty Codex turn_id, and falls back to Claude; an unrecognized or bare value warns and falls back to auto. Output replacement needs an explicit claude. mms hook install and uninstall take a required --host of claude, codex, cursor or kimi |
--use-daemon / --no-daemon | Override daemon routing for this invocation |
--surfacing-timeout-seconds N | Override the cold-path surfacing timeout |
--daemon-timeout-seconds N | Override hook-to-daemon round-trip timeout |
--persist-query-text / --no-persist-query-text | Override query-text retention for this portable hook invocation |
mms hook install and mms hook uninstall use the config file under the host’s home variable (CLAUDE_CONFIG_DIR, CODEX_HOME or KIMI_CODE_HOME) when it is an absolute path. When the variable is relative or has a . or .. path component, or when CLAUDE_CONFIG_DIR or KIMI_CODE_HOME is empty, STM cannot tell which file the host reads, so the command exits with an error without reading or changing the host’s hook config. An empty CODEX_HOME means ~/.codex.
mms daemon
Section titled “mms daemon”Manage the local surfacing daemon used by mms hook. Daemon mode is on by default (MEMTOMEM_STM_HOOK__USE_DAEMON=1) and auto-spawns on the first eligible hook call, so manual startup is usually unnecessary.
mms daemon status # show whether the warm daemon is runningmms daemon status --json # scriptable statusmms daemon start # start it explicitlymms daemon stop # stop the daemon for this configmms daemon stop --all # also stop daemons under other config fingerprintsmms daemon restart # stop this config, then start it oncemms daemon run # foreground long-lived server loopThe daemon holds one warm LTM MCP session for the active config. Set MEMTOMEM_STM_HOOK__USE_DAEMON=0 to force the legacy cold in-process hook path, or MEMTOMEM_STM_HOOK__FALLBACK=cold if you prefer a cold fallback when the daemon is unavailable. A busy or expired daemon reply skips surfacing for that call either way. A daemon under a different config fingerprint can belong to a running STM process with a different MEMTOMEM_STM_* environment (the MCP-launched server versus your shell or hook), so check mms daemon status before stopping it with --all.
The hook↔daemon protocol version is part of the daemon fingerprint; it is v9 since 0.7.0. When a release’s upgrade notes say the protocol changes, quit the MCP hosts that run STM and run mms daemon stop with the old build before upgrading: the new build cannot reach a daemon the old one started, and processes that share the pending SQLite store must run the same version. Upgrading to 0.7.9 keeps protocol v9 but keys the fingerprint with <data_dir>/stm-discovery.key, so a daemon an earlier build started is listed as foreign: mms daemon stop and restart no longer reach it and hooks start a new daemon beside it. Stop it with mms daemon stop --all on macOS/Linux, or end the listed process on Windows; afterwards the old stm-daemon-*.json and .lock files can be deleted, but keep stm-discovery.key. Even when the protocol version does not change, quit MCP hosts and stop old daemons after upgrading so running processes pick up the new code and -P launch flags (mms daemon stop --all on macOS/Linux; on Windows --all does not signal them, so end old daemon processes from Task Manager — and fix any invalid OTLP endpoint first since mms daemon loads the config). The upstream Upgrading runbook has the full sequence. A daemon pinned with idle_timeout_seconds=0 never idles out: stop it with mms daemon stop --all. On Windows that command cannot terminate it, so end the process from Task Manager instead.
mms daemon stop exits 0 only when every daemon it acted on finished shutting down, none was running, or the record it found was stale. Otherwise it exits 1 with the reason on stderr: for example, the daemon’s lifetime lock is still held after a 5-second wait, a pid cannot be signalled, or, on Windows, a daemon that would need the signal fallback is still listening. --all waits up to 10 seconds in total and exits 1 if a daemon listed without a handshake still holds its lock, or its lock cannot be checked, when the wait ends; when data_dir exists but cannot be listed it stops none of the foreign daemons and exits 1. An unreadable or malformed stm-discovery.key makes start, stop, restart, and status exit 1. mms daemon restart starts a replacement only after its stop step succeeds.
mms daemon status reports this config’s daemon as starting or unknown when there is no handshake but its lifetime lock is held or cannot be checked. mms daemon status --json lists daemons running under a different config fingerprint as foreign entries. Each entry carries fingerprint, pid, host, port, idle_shutdown_seconds and exits_when_idle, never the auth token. exits_when_idle is true for a daemon that shuts down when idle, false for one that never does (idle_shutdown_seconds is null), and null when the handshake does not say or holds a value no daemon writes. Entries also carry listening and lock. A foreign daemon that holds its lock without a handshake is listed with handshake_absent: true and pid null (pid=? in the text output). With an unreadable key, status --json reports "state": "unknown" with an error, and on a data_dir it cannot walk with no key it reports "unknown" where earlier builds reported "stale". A foreign daemon whose record cannot be read is listed only while its lock is held or cannot be checked, with handshake_unreadable: true and pid, host, port, idle_shutdown_seconds and exits_when_idle set to null. When data_dir exists but cannot be listed, foreign is null and foreign_error names the error class. The queue object, and the queue: line of the text output, report pre_auth_evictions: the daemon keeps at most 64 connections that have not authenticated yet, and past that it drops the oldest one and counts it here.
Diagnostics & Tuning
Section titled “Diagnostics & Tuning”mms health
Section titled “mms health”Probe every registered upstream server and report MCP connectivity status. Output is pretty-printed to match status / list.
mms health # human-readablemms health --json # scriptable JSONmms health --timeout 5 # per-server connect timeout (seconds)mms health --names # also flag tools whose proxied name overflows the 64-char MCP limit--names is the way to find an upstream tool that silently disappeared after registration because the composed mcp__<server>__<prefix>__<tool> name exceeded the MCP 64-char limit (#261).
The servers probed are the file’s entries with environment overrides applied (MEMTOMEM_STM_PROXY / MEMTOMEM_STM_PROXY__UPSTREAM_SERVERS…), the same map mms doctor checks. An upstream defined only in the environment is probed and listed in --json servers, and a field the environment overrides, such as command, is probed with the environment’s value. When the runtime configuration or the overlaid map fails validation, health probes the servers declared in the file. upstream_servers in the file must still be an object: null or a list exits 1 before any probe. A single server entry that is not an object, such as "bad": 7, is skipped and reported as an invalid config, and health exits 0.
health also renders a per-upstream circuit breaker line. As of v0.1.32 the breaker is on by default: after 3 consecutive failed calls an upstream’s tools fast-fail with circuit_open for ~60s instead of each call burning the full retry/deadline budget; cached responses keep serving and other upstreams are unaffected. Set circuit_max_failures: 0 on an upstream in stm_proxy.json to restore the old always-retry behavior.
health and doctor validate the configuration the way server startup does: an environment that startup rejects, such as MEMTOMEM_STM_PROXY='[1]', reports config_valid: false in health. Their error text omits rejected values and exception messages, and a few fields are redacted:
- Configuration errors show only their location and type.
- A failed probe reads as its exception type —
ConnectError,HTTP 401 (HTTPStatusError),MCPError -32602 (Invalid params)— instead of the exception text, which could quote a URL, argument or header back. The same applies tomms add --validateand import validation. Run the server command or reach the endpoint directly for the underlying message. - URLs drop their query string and fragment.
- SQLite errors from the feedback or metrics DB read e.g.
DatabaseError (SQLITE_CORRUPT). - A stdio LTM server’s launch arguments show as
<command> [args hidden]. In--json,surfacing.ltm_server.argsholds one<REDACTED>per argument, so scripts can still count them; readMEMTOMEM_STM_SURFACING__LTM_MCP_ARGSdirectly for the values.
--json also carries surfacing.runtime_profile_checks, the same rows doctor prints.
mms doctor
Section titled “mms doctor”Run the status, health, and config checks as one PASS/WARN/FAIL report. The default is passive and never edits state or searches LTM; FAIL exits 1 and WARN-only exits 0.
mms doctormms doctor --json --timeout 5mms doctor --measure-ltm # five read-only searches through an already-running daemonOptions: --config, --json, --timeout, and --measure-ltm. Measurement never starts a missing daemon.
An environment variable that startup rejects FAILs the config schema check, so doctor exits 1. An informational surfacing opportunities check appears when the opportunity log has something to count. Until an upgraded process opens stm_feedback.db, doctor reports the new table as missing. Errors are rendered as in mms health. WARN rows also name Codex MCP registrations outside STM (codex_extra_servers) and Claude Code plugin servers that bypass STM (plugin_bypass); MMS_NO_HOST_PROBE=1 skips those listings. Since 0.7.10 a hook registration row ("id": "hook_registration" in --json) reads the PostToolUse handlers in Claude Code’s user settings and WARNs, by location and never with command text, when an STM hook command lacks --host claude, does not run the hook, or cannot be checked because it is not made of plain words (quotes, $HOME or ~, another launcher; on Windows, every shell-form command). An unreadable settings file is a WARN that names the reason. The row appears only when the file holds an STM-looking handler or cannot be read, so a setup that passed before can now report WARN; the exit code is unchanged. Its next: line is a hand edit, not mms hook install --apply, which would merge handlers and drop inline settings. Project, local and managed Claude Code settings are not read.
mms config validate
Section titled “mms config validate”Strictly lint the JSON file as written, without environment overlay. Missing files, parse/schema errors, and unknown keys exit non-zero.
mms config validatemms config validate --config ./stm_proxy.json --jsonmms stats
Section titled “mms stats”Read persistent compression and surfacing statistics without creating or migrating stores. The totals cover the rows still retained, not all time: compression rows are capped per source at proxy.metrics.max_history, and progressive reads and surfacing rows age out after their retention periods.
mms stats [--config PATH] [--tool TOOL] [--source mcp|hook] [--all-time] [--json]The CLI sees disk-backed metrics only; process-local live counters remain available through the observability MCP tools.
- Compression measurement: compression statistics measure the initial response text before surfacing, and exclude follow-up
stm_proxy_read_morereads.- When an explicit
progressiveresponse is chunked, its row records the first chunk plus footer, so saved percentages rise for those tools. mms statswarns about successful MCP rows recorded before this accounting.- The
--jsonsummary addsinitial_response_calls,unclassified_mcp_callsand ameasurementdescription. - Calls that used the experimental structured delivery are counted on a separate
Structured delivery:line (calls, serialized base characters, measured MCP bytes;--json:compression.structured_delivery) and stay out of the saved ratio.
- When an explicit
--all-time: switches the compression block alone to all-time totals; the progressive and surfacing blocks keep their retained windows. All-time totals are the retained rows plus aproxy_metrics_dailytable that keeps daily aggregates (per day, source, server and tool) of every deleted row. The table is installed the first time a 0.7.7 or later metrics writer (the MCP server,mms hookormms tune) opens the metrics database; rows trimmed before that cannot be recovered, and an Incomplete before line reports when and how many.--jsonnames the scope incompression_scope(retainedorall_time). The first time a 0.7.10 or later writer opens the database, it also adds ahook_compression_statuscolumn toproxy_metricsand a second never-pruned table,proxy_metrics_hook_status_daily, which keeps the hook status of trimmed rows; an older STM sharing the file keeps writing rows that read asnot recorded.- Resetting the history: delete the rows of both tables in one transaction,
proxy_metricsfirst:BEGIN IMMEDIATE; DELETE FROM proxy_metrics; DELETE FROM proxy_metrics_daily; COMMIT;. The other order refills the daily table from the rows being deleted, and the transaction keeps another process from writing between the two statements. Deleting aproxy_metrics_dailyrow also deletes the hook status rows of the same day, server and tool through a third trigger, so the same statements resetproxy_metrics_hook_status_dailywhile that trigger is in place. Do notDROPeither daily table while a trigger that writes to it exists: every trim then fails withno such tableand rolls back the write that triggered it, and startup reconciliation fails too. - Per-source lines: when rows from both proxied MCP tools and
mms hookare present, the compression block prints anmcpline and ahookline under the aggregate, each with its own saved ratio; a source with no text characters, such as one whose rows are all structured deliveries, showsno text ratioinstead.--jsoncarries them incompression_by_source, which isnullwhen--sourceis given. Since 0.7.10mms hookrecords the host in the row’sserverasbuiltin:<host>(builtin:claude,builtin:codex, …); rows written before the upgrade stay underbuiltin, so one tool can show both, and a query onserver = 'builtin'no longer matches new hook rows. Thehookline is split by host when that adds something: a host that cannot replace output (Codex, Cursor, Kimi) is markedmeasured only, rows without a host are grouped as(host not recorded), and each host that can replace output gets astatus:line counting its rows by the compression stage’s decision (for examplecompressed,below_threshold, orreplacement_not_requestedfor a registration without--host claude).--jsonaddshook_by_hostandhook_status. The per-tool table’s server column is 14 characters wide. - Progressive delivery: this block compares the characters produced for paged responses with the characters delivered to the agent. Every recorded read counts, so rereads can push the ratio above 100%. It is filtered by
--toolbut not by--source, ends with the oldest retained row, and appears in--jsonasprogressive. - Invalid config file:
mms statsreads the configuration the server builds from the environment in that case, not built-in defaults. A database moved by an environment variable is the one it reads, and theEnabled/Serverslines (enabled/serversin--json) report the environment’s values. - Error counts:
lock_timeoutandinternal_errorrows recorded by the proxy’s own call path count as errors. Rows recorded before the upgrade are not rewritten. - Surfacing:
- Only shown events count as surfacings.
- Withheld (holdout) calls appear on a separate
withheld (holdout)line, and the opportunity log on anopportunitiesline. Each line appears only when there is something to count.
- Per-tool rows: the table and
by_toolgroup rows by server and tool across both sources, so a hook tool appears once per host label. - Per-tool
tuner_calls: in retained-mode--json, a tool’scallscounts every matching row andtuner_callscounts the rows the auto-tuner uses. Rows annotated as metadata bypass are dropped from the tuner’s profiles, so they are left out oftuner_calls. A database without thecompression_strategycolumn counts every row. All-timeby_toolentries have notuner_calls. - Unknown values: a rating or surfacing decision outside STM’s own vocabulary is counted under
other. --jsonerrors: a SQLite error incompression.errororsurfacing.errorreads as its type, e.g.DatabaseError (SQLITE_CORRUPT).
mms tune
Section titled “mms tune”Preview or apply per-tool compression recommendations derived from the existing metrics and feedback stores.
mms tune [--config PATH] [--since-hours 24] [--tool TOOL] [--json]mms tune --apply [--yes]Preview is the default. --apply takes a timestamped backup and writes accepted tool_overrides under the config lock; the running proxy hot-reloads them. Unlike mms stats, tune may run idempotent schema migrations on stores that already exist.
An empty filter such as --tool "" matches no tools; omit --tool to analyze all of them. In particular, mms tune --apply --yes --tool "" writes no overrides.
A tool whose strategy, resolved from the current configuration, is none gets no max_result_chars recommendation, because that path does not read the budget. An explicit progressive tool gets one only under the experimental structured delivery (delivery_format: "structured"), where the budget caps each serialized frame: a raise, from missing_example feedback. Such a raise is suggested only when it exceeds the current budget, which it shows as current, and a tool whose dominant feedback over three or more reports is missing_example gets no cut. A tool that inherits a server token budget under token_estimation_mode: "unicode" gets no budget suggestion. Ratio-based advice reads only rows recorded with the current accounting, so a tool with only older rows gets none until new calls accumulate.
mms selection replay
Section titled “mms selection replay”Replay sanitized selection telemetry and evaluate deterministic risk penalties. Recommendations are previews and never update proxy config. A --dataset whose decoded text matches STM’s sensitive-content patterns is refused (dataset matched sensitive-content patterns, exit 1).
mms selection replay [--config PATH] [--log FILE] [--dataset FILE] [--active-only] [--no-telemetry] [--output-dir DIR] [--json]mms selection feedback
Section titled “mms selection feedback”Record an operator correction for selection telemetry; this writes feedback, not proxy configuration.
mms selection feedback --selection-id SELECTION_ID --operator-override --yesmms selection feedback --last --user-corrected --yesFilters and output options: --config, --log, --active-only, --server, --tool, --json. Explicit negative flags are --no-operator-override and --no-user-corrected.
Projects & Hosts
Section titled “Projects & Hosts”.mms/project.toml markers let you scope which MCPs are active per directory — for example, GitHub MCP only when working in your work repo, filesystem only in side projects. Project markers are indexed at ~/.mms/projects.toml so the active set is consistent regardless of where you invoke mms from.
mms project init [PATH]
Section titled “mms project init [PATH]”Create <path>/.mms/project.toml and add it to the projects index. Defaults to cwd.
mms project init # create .mms/project.toml in cwdmms project init ~/work/billing # create in another directorymms project init --name acme # override directory-basename namemms project init --force # overwrite an existing markermms project show [NAME]
Section titled “mms project show [NAME]”Show the detected (or named) project’s enabled MCP list and marker path.
mms project showmms project show acmemms project show --jsonmms project list
Section titled “mms project list”List indexed projects. The current cwd’s project is marked with *.
mms project listmms project list --jsonmms project list --prune # drop entries with missing markers or non-directory rootsIf any indexed project’s config is corrupt, --prune aborts and leaves the index unchanged.
mms project enable / disable <mcps...>
Section titled “mms project enable / disable <mcps...>”Add or remove MCP names from a project’s mcp.enabled list. Target is auto-detected from cwd; pass --project <name> to override.
mms project enable filesystem githubmms project disable githubmms project enable filesystem --project acmeenable only accepts MCPs that are already in the registry — it errors clearly when the registry is empty. disable works regardless of registry state.
mms project route
Section titled “mms project route”Preview or add the detected project’s enabled registry MCPs to the STM config.
mms project routemms project route --project acme --config ~/.memtomem/stm_proxy.json --applymms project route --jsonOptions are --project, --config, --apply, and --json. Routing is additive: existing entries remain, conflicts are reported and skipped, and source host configs are never pruned.
mms import
Section titled “mms import”Discover MCP definitions in host MCP clients (Claude Code, Claude Desktop, Cursor, …) and copy them into ~/.mms/registry.toml. This populates the registry used by project management — a different target file and purpose from mms add --from-clients, which imports upstreams into the proxy config. --plan is the default — pass --apply to actually write.
mms import --plan # default: show what would be imported (secrets redacted)mms import --apply # write to the registrymms import --from claude-code --plan # restrict source (claude-code / cursor / codex / claude-desktop / all)mms import --plan --show-imported # reveal secret values in the plan output (use carefully)mms import --apply --allow-project-configs # also register entries from project config files--apply refuses entries discovered in project config files under the current directory (<cwd>/.mcp.json, <cwd>/.cursor/mcp.json) unless --allow-project-configs is given, because a repository checkout can ship those files. --plan only prints a warning that --apply will need the flag. mms import --help ends with examples and two notes: the command writes ~/.mms/registry.toml, not the proxy config mms add writes, and --apply needs --allow-project-configs for project config entries.
First import wins: identical names with different definitions are flagged as conflicts and skipped; identical definitions are left unchanged.
--plan shows each secret-classified env value as <REDACTED> with the reason. A value is classified by its key (*TOKEN*, *KEY*, *SECRET*, *PASSWORD*, *PASS*, *AUTH*, *CREDENTIAL*, *API_KEY*, and since 0.7.10 *COOKIE*, *BEARER*, *DSN*), by its form (since 0.7.10 a URL with a password, a JWT, a recognized provider token also behind Bearer , a PEM private-key header, or a password= / api_key= label), or as a long base64- or hex-like string. mms host sync and mms eject use the same classifier. A host config source that mms import did not inspect is named in a Note: line on stderr, and an empty result says how many sources were not inspected.
mms gateway
Section titled “mms gateway”Inspect and configure the optional Toolgraph policy source.
mms gateway status [--config PATH] [--json]mms gateway mode strict|review|explore [--config PATH] [--bundle PATH] [--apply|--dry-run]mms gateway explain server::tool [--config PATH] [--json]mode previews by default. --apply enables the bundle source and atomically aligns the Toolgraph query profile with STM exposure; explain reports one bundle decision.
mms host
Section titled “mms host”Inspect and reconcile the host MCP configurations that feed the project registry.
mms host scan [--from claude-code|cursor|codex|claude-desktop|all] [--json]mms host status [--json]mms host sync [--plan|--apply] [--json] [--yes] [--force] [--allow-project-configs]scan is a host-anchored, read-only inventory; status is a registry-anchored drift comparison. sync previews by default, adds new entries, removes entries absent from every host, and backfills sidecar baselines. A source STM could not inspect is not read as empty: when STM cannot tell which Claude Code config or project entry is in use, or that file or <cwd>/.mcp.json exists but is not a readable JSON object, a registry entry whose baseline came from that source is not_inspected and kept, even when a same-name entry at another host was found. status --json gives such a row a reason and counts it in summary.not_inspected, scan --json lists the skipped sources under not_inspected, and sync --json carries them in plan.not_inspected and summary.not_inspected. Adopting changed host shapes requires --apply --force (--force alone only previews); mutating JSON runs require --yes. Since 0.7.9 drift hashes are hmac-sha256:<16-hex> under ~/.mms/import_state.toml.key: until the first --apply that writes creates the key, current_hash is null, and that write moves ~/.mms/import_state.toml to schema_version = 2, which 0.7.8 cannot read (to go back, delete the file and run mms host sync --apply with the older build). If the key is lost or replaced, the rows it stamped read no_baseline until --apply stamps them again; an unreadable or malformed key makes host status, host sync, and a writing --apply exit 1. A missing key is created with a hard link, so on a filesystem without hard links a mms host sync --apply or mms import --apply that has to create it exits 1 before writing. --allow-project-configs explicitly acknowledges project-local discoveries. The --plan preview shows the secret-classified env values of entries it would add as <REDACTED> (see mms import); host sync has no --show-imported, so inspect those values with mms import --plan --show-imported before --apply.
Operational statistics
Section titled “Operational statistics”To inspect proxy, surfacing, selection, and compression behavior at runtime, STM ships eight observability actions on a single stm_admin tool (proxy_stats, proxy_cache_clear, proxy_health, surfacing_stats, selection_stats, compression_stats, progressive_stats, tuning_recommendations). stm_admin is hidden from tools/list by default; set MEMTOMEM_STM_ADVERTISE_OBSERVABILITY_TOOLS=true to advertise it. See MCP Tools.
Running the proxy server
Section titled “Running the proxy server”The proxy server accepts memtomem-stm, memtomem-stm-proxy, or a bare mms command over piped stdio. You normally do not launch it by hand: a registered MCP client spawns it. A bare interactive mms invocation displays CLI help instead.
--json failure documents
Section titled “--json failure documents”Many --json commands, such as add, remove, prune, eject, list, status, health, tune, gateway and project route, report an operational failure as one JSON document on stdout, while the human-readable error still goes to stderr. The upstream CLI documentation lists exactly which commands and failure paths use it.
{"action": "add", "ok": false, "error": "<code>", "message": "...", "path": "..."}error holds a stable identifier, and some commands add fields such as path or stores. An operational failure exits 1; a refused consent (confirmation_required, project_config_ack_required) exits 2.
| Family | Codes | When |
|---|---|---|
| Config read | config_unreadable, config_invalid | The file cannot be read / it is not UTF-8, JSON, or a JSON object, or fails validation |
| Config write | config_lock_timeout, config_lock_unavailable, config_write_failed | The write lock timed out / the lock file cannot be created or opened / the pre-apply backup or atomic replace failed (that write leaves the file as it was, but a command that saves more than once may already have applied an earlier save) |
~/.mms state (mms host, mms project, mms import) | mms_lock_timeout, mms_lock_unavailable, mms_state_write_failed, mms_schema_mismatch, mms_state_invalid | The state lock timed out or is unavailable / a write failed / the schema version does not match / a state file is corrupt |
Metrics store (mms tune) | store_invalid | SQLite cannot open or read the metrics or feedback database file (listed in stores) |
For the command-specific codes of add, gateway explain, project route, selection feedback and others, see the upstream CLI documentation.
These cases do not use the envelope:
- A malformed invocation (unknown flag, missing argument) prints Click’s usage error on stderr, exits 2, and leaves stdout empty. The config write lock is taken before the command runs, so under contention a mutating command can report the exit-1 lock error first.
mms doctor --jsonandmms config validate --jsonprint their own result documents (statuswithchecks, andstatuswitherrors), also on failure.mms list,mms statusandmms healthprint only{"error": "config_not_found", "path": ...}when the config file is missing, and exit 0.mms tune --jsonis preview-only and keeps config-lock failures as plain text.mms initandmms registerprint a result document withconfig_path,serversandclient; when setup itself fails, itserrorholdssetup_failedor a write-failure code.mms inittakes the config write lock before setup starts, so a lock failure there (config_lock_timeout,config_lock_unavailable) uses the standard envelope instead.mms stats --jsonreports store errors in thecompression.errorandsurfacing.errorfields described undermms stats.
Example Workflow
Section titled “Example Workflow”# 1. First-time setup — registers one upstream + your MCP client in one gomms init --demo --client auto
# 2. Add more upstreams (manually, or bulk-import from existing client configs)mms add filesystem --command filesystem-server --prefix fs --validatemms add --from-clients
# 3. Verify connectivitymms statusmms health
# 4. (Optional) turn off surfacing for one upstreammms surfacing filesystem off
# 5. (Optional) back out — restore an upstream to its original host configmms eject filesystem
# 6. (Optional) re-register with Claude Code after reinstalling the clientmms register --client claudeYour MCP client now connects to memtomem-stm instead of each individual upstream. All upstream tools are available through the proxy, with automatic memory surfacing, response compression, and progressive delivery.
See Installation for setup details, and Proactive Surfacing for how surfacing works.
Complete option index by command
Section titled “Complete option index by command”Public long options from the pinned source. Short aliases and the common --help flag are omitted. Use each command’s --help for arguments, defaults, and constraints.
| Command | Options |
|---|---|
mms | --version |
mms add | --all, --allow-project-configs, --args, --command, --compression, --config, --env, --from-clients, --header, --import, --json, --max-chars, --prefix, --prune, --save-unverified, --select, --timeout, --transport, --url, --validate |
mms config | — |
mms config validate | --config, --json |
mms daemon | — |
mms daemon restart | — |
mms daemon run | --detached, --foreground |
mms daemon start | — |
mms daemon status | --json |
mms daemon stop | --all |
mms doctor | --config, --json, --measure-ltm, --timeout |
mms eject | --accept-schema-loss, --allow-argv-secrets, --config, --dry-run, --force, --json, --keep, --to, --yes |
mms gateway | — |
mms gateway explain | --config, --json |
mms gateway mode | --apply, --bundle, --config, --dry-run |
mms gateway status | --config, --json |
mms health | --config, --json, --names, --timeout |
mms hook | --daemon-timeout-seconds, --host, --no-daemon, --no-persist-query-text, --persist-query-text, --surfacing-timeout-seconds, --use-daemon |
mms hook install | --apply, --daemon, --host, --inherit-runtime-env, --no-daemon, --surfacing-timeout |
mms hook uninstall | --apply, --host |
mms host | — |
mms host scan | --from, --json |
mms host status | --json |
mms host sync | --allow-project-configs, --apply, --force, --json, --plan, --yes |
mms import | --allow-project-configs, --apply, --from, --plan, --show-imported |
mms init | --allow-project-configs, --client, --config, --demo, --freshness, --json, --lang, --mcp, --no-validate, --prune-originals, --replace-registration, --resume, --save-unverified |
mms list | --config, --json |
mms project | — |
mms project disable | --project |
mms project enable | --project |
mms project init | --force, --name |
mms project list | --json, --prune |
mms project route | --apply, --config, --json, --project |
mms project show | --json |
mms prune | --all, --config, --dry-run, --json, --yes |
mms register | --client, --config, --json, --mcp, --replace-registration |
mms remove | --config, --json, --yes |
mms selection | — |
mms selection feedback | --active-only, --config, --json, --last, --log, --no-operator-override, --no-user-corrected, --operator-override, --selection-id, --server, --tool, --user-corrected, --yes |
mms selection replay | --active-only, --config, --dataset, --json, --log, --no-telemetry, --output-dir |
mms stats | --all-time, --config, --json, --source, --tool |
mms status | --config, --json |
mms surfacing | --config |
mms tune | --apply, --config, --json, --since-hours, --tool, --yes |
mms version | — |