Skip to content

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.

For a deterministic first success, create the bundled read-only demo, register a detected client, and run the end-to-end diagnostic:

Terminal window
mms init --demo --client auto
mms doctor

With 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.

OptionDescription
--config PATHProxy config path (default ~/.memtomem/stm_proxy.json)
--no-validateSkip the optional connectivity probe
--client auto|claude|codex|json|skipSelect current client registration flow
--mcp claude|json|skipCompatibility spelling for the older registration flow
--resumeContinue client registration when the proxy config already exists
--demoConfigure the bundled deterministic read-only server
--freshness live|balanced|reuseResponse-cache freshness preset (default balanced)
--allow-project-configsAcknowledge discovery of project-local MCP configs
--replace-registrationReplace an existing selected-client registration
--save-unverifiedSave when an optional connection probe fails
--jsonEmit one JSON result document
--prune-originalsRemove imported direct host registrations after successful setup
--lang en|koToken-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.

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.

Terminal window
mms register --client auto # detected supported client
mms register --client claude # Claude Code
mms register --client codex # Codex
mms register --client json # write .mcp.json in cwd
mms register --client skip # print manual registration hints

The 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).

Register an upstream MCP server to proxy through STM.

Terminal window
mms add filesystem --command filesystem-server --prefix fs
mms add github --command github-mcp --args "--token $GH_TOKEN" --prefix gh
mms add remote-api --transport streamable_http --url https://example/mcp --prefix api
mms add filesystem --command filesystem-server --prefix fs --validate
FlagDescription
--commandExecutable command (stdio transport)
--argsSpace-separated arguments
--prefixTool namespace (required unless --from-clients); tools appear as {prefix}__{tool}
--transportstdio (default), sse, or streamable_http
--urlEndpoint URL for sse / streamable_http
--env KEY=VALUEEnvironment variable to forward to the upstream process (repeatable)
--header KEY=VALUEPlaintext header for sse / streamable_http (repeatable; config file is mode 0600)
--compressionauto (default), none, truncate, selective, hybrid
--max-charsPer-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
--validateProbe the server (MCP initialize + list-tools) before saving
--timeoutProbe timeout in seconds when --validate is set (default 10)
--jsonEmit one JSON result document

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.)

Terminal window
mms add --from-clients # interactive bulk import
mms add --import # alias
mms add --from-clients --prune # also remove the direct registration from each source client

After 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.

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 claude is on PATH, they run claude plugin list --json in the current directory and list each MCP server an enabled plugin registers, as /mcp shows it (plugin:<plugin>:<server>). STM does not proxy those servers. To route one through STM, add it with mms add … --validate and then disable the plugin’s copy. --json carries the rows in plugin_bypass, and plugin_bypass_disables_unread says why servers disabled in /mcp could not be checked ("no_key", "no_config", or null when no reason was recorded).
  • Codex registrations outside the command’s discovery, by name only (--json: codex_extra_servers, null when 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.

List all registered upstream servers — the per-server view.

Terminal window
mms list # human-readable
mms list --json # scriptable JSON

The 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.

Answer “is the proxy set up and pointed at the right config?” — a config summary, not the per-server view.

Terminal window
mms status
mms status --json # scriptable JSON

As 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.

Remove a registered upstream server.

Terminal window
mms remove filesystem # confirmation prompt
mms remove filesystem -y # skip confirmation

Removing an imported server emits a hint pointing at mms eject, so the original host registration can be restored rather than lost.

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.

Terminal window
mms prune --all # every dual-registered upstream
mms prune filesystem github # specific names
mms prune --all --dry-run # show what would be pruned, no writes
mms 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.

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.

Terminal window
mms eject filesystem # restore to host config, then remove the STM entry
mms eject filesystem github # several at once
mms eject filesystem --dry-run # preview what would be restored
mms eject filesystem --keep # restore to host but keep the STM entry (dual registration)
mms eject filesystem --yes # non-interactive — skip the confirm prompt

It 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.

FlagDescription
--to TARGETRestore target for entries without a recorded origin (claude-user / claude-project[:PATH] / mcp-json[:PATH] / claude-desktop). Entries with a recorded origin ignore this
--keepRestore to the host but keep the STM entry (dual registration)
--forceOverwrite a same-name host entry whose identity differs
--allow-argv-secretsPermit 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-lossProceed 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-runPrint the plan; no writes
--yes / -ySkip the confirm prompt (scripts / CI / non-TTY)

Toggle proactive memory surfacing for a single upstream server. Omit the state argument to print the current value.

Terminal window
mms surfacing filesystem # show current state
mms surfacing filesystem off # disable surfacing for this upstream
mms surfacing filesystem on # re-enable

surfacing_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.

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.

OptionDescription
--host HOSTHost 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-daemonOverride daemon routing for this invocation
--surfacing-timeout-seconds NOverride the cold-path surfacing timeout
--daemon-timeout-seconds NOverride hook-to-daemon round-trip timeout
--persist-query-text / --no-persist-query-textOverride 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.

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.

Terminal window
mms daemon status # show whether the warm daemon is running
mms daemon status --json # scriptable status
mms daemon start # start it explicitly
mms daemon stop # stop the daemon for this config
mms daemon stop --all # also stop daemons under other config fingerprints
mms daemon restart # stop this config, then start it once
mms daemon run # foreground long-lived server loop

The 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.

Probe every registered upstream server and report MCP connectivity status. Output is pretty-printed to match status / list.

Terminal window
mms health # human-readable
mms health --json # scriptable JSON
mms 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 to mms add --validate and 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.args holds one <REDACTED> per argument, so scripts can still count them; read MEMTOMEM_STM_SURFACING__LTM_MCP_ARGS directly for the values.

--json also carries surfacing.runtime_profile_checks, the same rows doctor prints.

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.

Terminal window
mms doctor
mms doctor --json --timeout 5
mms doctor --measure-ltm # five read-only searches through an already-running daemon

Options: --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.

Strictly lint the JSON file as written, without environment overlay. Missing files, parse/schema errors, and unknown keys exit non-zero.

Terminal window
mms config validate
mms config validate --config ./stm_proxy.json --json

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.

Terminal window
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_more reads.
    • When an explicit progressive response is chunked, its row records the first chunk plus footer, so saved percentages rise for those tools.
    • mms stats warns about successful MCP rows recorded before this accounting.
    • The --json summary adds initial_response_calls, unclassified_mcp_calls and a measurement description.
    • 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.
  • --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 a proxy_metrics_daily table 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 hook or mms tune) opens the metrics database; rows trimmed before that cannot be recovered, and an Incomplete before line reports when and how many. --json names the scope in compression_scope (retained or all_time). The first time a 0.7.10 or later writer opens the database, it also adds a hook_compression_status column to proxy_metrics and 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 as not recorded.
  • Resetting the history: delete the rows of both tables in one transaction, proxy_metrics first: 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 a proxy_metrics_daily row also deletes the hook status rows of the same day, server and tool through a third trigger, so the same statements reset proxy_metrics_hook_status_daily while that trigger is in place. Do not DROP either daily table while a trigger that writes to it exists: every trim then fails with no such table and rolls back the write that triggered it, and startup reconciliation fails too.
  • Per-source lines: when rows from both proxied MCP tools and mms hook are present, the compression block prints an mcp line and a hook line under the aggregate, each with its own saved ratio; a source with no text characters, such as one whose rows are all structured deliveries, shows no text ratio instead. --json carries them in compression_by_source, which is null when --source is given. Since 0.7.10 mms hook records the host in the row’s server as builtin:<host> (builtin:claude, builtin:codex, …); rows written before the upgrade stay under builtin, so one tool can show both, and a query on server = 'builtin' no longer matches new hook rows. The hook line is split by host when that adds something: a host that cannot replace output (Codex, Cursor, Kimi) is marked measured only, rows without a host are grouped as (host not recorded), and each host that can replace output gets a status: line counting its rows by the compression stage’s decision (for example compressed, below_threshold, or replacement_not_requested for a registration without --host claude). --json adds hook_by_host and hook_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 --tool but not by --source, ends with the oldest retained row, and appears in --json as progressive.
  • Invalid config file: mms stats reads 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 the Enabled / Servers lines (enabled / servers in --json) report the environment’s values.
  • Error counts: lock_timeout and internal_error rows 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 an opportunities line. Each line appears only when there is something to count.
  • Per-tool rows: the table and by_tool group 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’s calls counts every matching row and tuner_calls counts the rows the auto-tuner uses. Rows annotated as metadata bypass are dropped from the tuner’s profiles, so they are left out of tuner_calls. A database without the compression_strategy column counts every row. All-time by_tool entries have no tuner_calls.
  • Unknown values: a rating or surfacing decision outside STM’s own vocabulary is counted under other.
  • --json errors: a SQLite error in compression.error or surfacing.error reads as its type, e.g. DatabaseError (SQLITE_CORRUPT).

Preview or apply per-tool compression recommendations derived from the existing metrics and feedback stores.

Terminal window
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.

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).

Terminal window
mms selection replay [--config PATH] [--log FILE] [--dataset FILE]
[--active-only] [--no-telemetry]
[--output-dir DIR] [--json]

Record an operator correction for selection telemetry; this writes feedback, not proxy configuration.

Terminal window
mms selection feedback --selection-id SELECTION_ID --operator-override --yes
mms selection feedback --last --user-corrected --yes

Filters and output options: --config, --log, --active-only, --server, --tool, --json. Explicit negative flags are --no-operator-override and --no-user-corrected.

.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.

Create <path>/.mms/project.toml and add it to the projects index. Defaults to cwd.

Terminal window
mms project init # create .mms/project.toml in cwd
mms project init ~/work/billing # create in another directory
mms project init --name acme # override directory-basename name
mms project init --force # overwrite an existing marker

Show the detected (or named) project’s enabled MCP list and marker path.

Terminal window
mms project show
mms project show acme
mms project show --json

List indexed projects. The current cwd’s project is marked with *.

Terminal window
mms project list
mms project list --json
mms project list --prune # drop entries with missing markers or non-directory roots

If any indexed project’s config is corrupt, --prune aborts and leaves the index unchanged.

Add or remove MCP names from a project’s mcp.enabled list. Target is auto-detected from cwd; pass --project <name> to override.

Terminal window
mms project enable filesystem github
mms project disable github
mms project enable filesystem --project acme

enable only accepts MCPs that are already in the registry — it errors clearly when the registry is empty. disable works regardless of registry state.

Preview or add the detected project’s enabled registry MCPs to the STM config.

Terminal window
mms project route
mms project route --project acme --config ~/.memtomem/stm_proxy.json --apply
mms project route --json

Options are --project, --config, --apply, and --json. Routing is additive: existing entries remain, conflicts are reported and skipped, and source host configs are never pruned.

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.

Terminal window
mms import --plan # default: show what would be imported (secrets redacted)
mms import --apply # write to the registry
mms 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.

Inspect and configure the optional Toolgraph policy source.

Terminal window
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.

Inspect and reconcile the host MCP configurations that feed the project registry.

Terminal window
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.

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.

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.

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.

FamilyCodesWhen
Config readconfig_unreadable, config_invalidThe file cannot be read / it is not UTF-8, JSON, or a JSON object, or fails validation
Config writeconfig_lock_timeout, config_lock_unavailable, config_write_failedThe 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_invalidThe 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_invalidSQLite 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 --json and mms config validate --json print their own result documents (status with checks, and status with errors), also on failure.
  • mms list, mms status and mms health print only {"error": "config_not_found", "path": ...} when the config file is missing, and exit 0.
  • mms tune --json is preview-only and keeps config-lock failures as plain text.
  • mms init and mms register print a result document with config_path, servers and client; when setup itself fails, its error holds setup_failed or a write-failure code. mms init takes 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 --json reports store errors in the compression.error and surfacing.error fields described under mms stats.
Terminal window
# 1. First-time setup — registers one upstream + your MCP client in one go
mms init --demo --client auto
# 2. Add more upstreams (manually, or bulk-import from existing client configs)
mms add filesystem --command filesystem-server --prefix fs --validate
mms add --from-clients
# 3. Verify connectivity
mms status
mms health
# 4. (Optional) turn off surfacing for one upstream
mms surfacing filesystem off
# 5. (Optional) back out — restore an upstream to its original host config
mms eject filesystem
# 6. (Optional) re-register with Claude Code after reinstalling the client
mms register --client claude

Your 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.

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.

CommandOptions
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—