Expand description
Plain Mode — temporarily disable MCP servers by renaming .mcp.json
files to .mcp.json.suspect and (optionally) writing an empty stub in
their place.
§When to use it
User suspects a newly-installed MCP server is malicious and wants to
start a clean Agent session right now, without manually editing
configs. agentsec plain enable renames targets to .suspect; the
Agent then starts with an empty MCP world. agentsec plain restore
puts everything back.
§What gets renamed
Plain Mode only touches standalone .mcp.json files. It never
edits .claude.json directly, because that file mixes MCP server
config with hooks / permissions / per-project state that we don’t
want to wipe.
Default target: <cwd>/.mcp.json. Callers can pass additional
absolute paths (typically per-project .mcp.json discovered from a
scan).
§Ledger
PLAIN_LEDGER_FILENAME under crate::Paths::home tracks which
files were renamed so restore can put them back. The ledger
existing with non-empty entries is the canonical signal that Plain
Mode is active.
§Invariants
enableis idempotent within a session: if the target’s.suspectsibling already exists, enable skips that target (and reports the skip) rather than clobbering the prior backup.restoreremoves the ledger on success. Repeat calls with an absent ledger are no-ops.- Dry-run mode performs zero filesystem mutation and returns the same shape of result so callers can preview.
Structs§
- Enable
Outcome - Outcome of
enable. - Enable
Row - One row of
enable’s outcome. - Ledger
Entry - One row in the persisted ledger.
- Plain
Ledger - Full ledger persisted to
PLAIN_LEDGER_FILENAME. - Plain
Status - Resolved Plain Mode status — what the on-disk ledger says right now.
- Restore
Outcome - Outcome of
restore. - Restore
Row - One row of
restore’s outcome.
Enums§
- Enable
Action - Outcome variants for a single target.
- Restore
Action - Outcome variants for restoring a single ledger entry.
Constants§
- PLAIN_
LEDGER_ FILENAME - Filename of the ledger file under
Paths::home. - PLAIN_
STUB_ BODY - Content of the stub written at the original path while Plain Mode is active. Empty MCP world; the Agent sees zero servers configured.
- SUSPECT_
SUFFIX - Suffix appended to a renamed file (so
.mcp.jsonbecomes.mcp.json.suspect).
Functions§
- default_
targets - Default Plain Mode targets — currently just
<cwd>/.mcp.json. Callers can extend this list with their own absolute paths. - enable
- Enable Plain Mode for the given target paths.
- restore
- Restore everything in the ledger.
- status
- Read
PlainStatusfrom disk.