Plan Code
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Why Plan Code
AI agents edit fast and explain later. Plan Code flips the order. The agent proposes every file it wants to create, modify or delete, each with a reason, a risk level and a reuse check. You approve what you agree with in a local web viewer. Anything you did not approve cannot be written.
Plan first. See the whole file tree and the reason for each file before any edit.
Real enforcement. A hook blocks edits to files outside the approved plan. It is a gate, not a suggestion.
Live build view. While the agent works, the viewer shows the real file, what changed, and why.
Local and private. Everything runs on
localhostwith a per-run token. No account, no cloud, no dependencies.
Related MCP server: Overture
Quick start
You need Node.js 18 or newer. Plan Code is a local MCP server (dist/bin/mcp.js), so it works in any MCP host.
Let your AI install it (copy this prompt)
Paste this into Claude Code, Codex, Gemini CLI or any agent that can run shell commands. It installs Plan Code in a fixed place, so every project shares one copy.
Install Plan Code (https://github.com/NAMANIND/plan-code) on this machine, then stop.
1. Check that Node.js 18 or newer is installed (`node -v`). If not, tell me and stop.
2. Save it in ~/.plan-code/app. If that folder exists, run `git -C ~/.plan-code/app pull`; otherwise run
`git clone https://github.com/NAMANIND/plan-code.git ~/.plan-code/app`.
3. Register the MCP server for my whole user account, not just this project:
- Claude Code: `claude mcp add --scope user plan-code -- node ~/.plan-code/app/dist/bin/mcp.js`
- Another host: add {"mcpServers":{"plan-code":{"command":"node","args":["<absolute path to ~/.plan-code/app>/dist/bin/mcp.js"]}}} to that host's MCP config.
4. For Claude Code, also install the plugin so the hooks and /plancode exist:
`claude plugin install plan-code --marketplace NAMANIND/plan-code`
5. Do not turn the gate on and do not edit any project files. Tell me to restart the session, then run `/plancode status`.Plan Code keeps its settings (such as your theme) in ~/.plan-code/settings.json, next to the app folder.
Or do it by hand: as an MCP server (any host)
git clone https://github.com/NAMANIND/plan-code.git
claude mcp add plan-code -- node /path/to/plan-code/dist/bin/mcp.jsOr add it to your host's MCP config by hand:
{
"mcpServers": {
"plan-code": { "command": "node", "args": ["/path/to/plan-code/dist/bin/mcp.js"] }
}
}This gives the agent propose_plan, wait_for_approval and the other plan tools, and starts the viewer at http://localhost:1234/. An MCP server alone cannot block an edit, so on its own the plan is a request the agent follows. For a hard gate, add the hooks below.
The icon. There is nothing to set in the config above: the server sends its own logo when the host connects, in the serverInfo of its reply, so a host that shows MCP server icons shows the Plan Code logo, with the name "Plan Code" and a link to this repo. A host without icon support ignores it.
"serverInfo": {
"name": "plan-code",
"title": "Plan Code",
"version": "0.1.0",
"websiteUrl": "https://github.com/NAMANIND/plan-code",
"icons": [{ "src": "https://raw.githubusercontent.com/NAMANIND/plan-code/main/assets/logo.svg", "mimeType": "image/svg+xml", "sizes": ["any"] }]
}The logo is assets/logo.svg, loaded by the host from this public repo. That needs the host to be online and the repo to stay public; if the link can't be loaded, the host just shows no icon.
Or by hand: as a Claude Code plugin (MCP server + hooks + /plancode)
/plugin install plan-code --marketplace NAMANIND/plan-codeOr from a shell: claude plugin install plan-code --marketplace NAMANIND/plan-code. To try it from a clone without installing: claude --plugin-dir /path/to/plan-code.
Then run /plancode in a session, or ask the agent to plan a change. The hooks are what make the gate real: they block edits to files outside the approved plan.
How it works
Run
/plancode, or ask for a change. The agent callspropose_planand the gate turns on.Tick the files that look right and press Approve in the viewer, or type
Approved, goin the chat. Nothing else counts as approval.propose_planwaits for your answer and returns the approved files, so the agent carries on in the same turn. After about 90 seconds it says "still waiting" and the agent callswait_for_approvalagain.Each file gets a one-line reason before it is edited and a plain sentence about what changed afterwards.
/plancode offor the viewer's Plan mode switch turns the gate off. The settings menu has a Quit Plan Code button (same as/plancode quit). Your theme choice is saved./plancode statustells you where it stands. A plan proposed later never turns the gate back on; only/plancodeor the Gate button does.
Commands
Command | What it does |
| Turn the gate on and open the viewer |
| Say whether the gate is on, and give the viewer address |
| Turn the gate off for this chat |
| Gate off in every chat, and stop the viewer so port 1234 is free |
Features
Risk floor. Database, schema, migration, auth, payment, dependency,
.envand CI paths are at least high, and a delete is at least medium. The rule only raises a risk. Test files are never raised.Duplicate check. A new file is compared with existing names, and names declared in its signatures are searched for in the repo.
Dependencies. A file can wait for another file in the plan to be written first.
Runs and re-asks. Every file you approve in one click is one run. Later asks are queued, and further changes to a written file show as v2.
Many chats, one viewer. The Chats sidebar lists running chats and 7 days of earlier ones (read-only). Each chat has its own title.
Typed approval.
Approved, goin the chat works exactly like the Approve button.
What the dots mean
Dot | Meaning |
○ | Waiting for your review |
● orange, pulsing | In this run: every file you approved in one click |
clock icon | Waiting for a file it depends on |
Queued (label) | In a later run, or a further ask on a file being written |
v2 tag | Another change to a file already written |
✓ | Written |
⊘ | Blocked: the agent tried to edit a file that is not in the plan |
How an approval reaches the agent
The viewer cannot start an agent turn, so the agent waits for it.
While the agent is waiting in
propose_planorwait_for_approval, your click is returned straight away.While it is working, a click or a message typed in the viewer is delivered at its next stop or at your next prompt.
If the agent has stopped completely, a click cannot wake it. Send any short message, or type
Approved, go, and it carries on.If the agent stops with approved files still unwritten, it is asked once to finish them. If it stops again, those files go back to waiting so Approve shows again.
Architecture
src/core/state.ts the plan rules (merge, approve, runs, history) shared by everyone
src/core/gate.ts allow or deny one tool call shared by everyone
src/core/store.ts the chat's files, locks, the viewer's clicks shared by everyone
src/bin/mcp.ts MCP server: propose_plan, wait_for_approval, ... works in any MCP host
src/bin/hook.ts the gate and the typed approval one small adapter per host
src/viewer/ the local web page (server.ts, app.ts, index.html)The source is TypeScript in src/. The compiled JavaScript in dist/ is committed, so running Plan Code needs only Node, no build. To change it: npm install, edit src/, then npm test (builds, then runs the tests). npm run typecheck checks types without building.
An MCP server alone cannot stop an edit, because tools are things the model chooses to call. The hook is what makes the gate real, and it is the only part that differs between hosts. This version ships the Claude Code adapter.
Other providers
Codex CLI, Gemini CLI and Antigravity all have hooks that can block a tool call and all speak MCP. For each one the work is:
A hook config that calls
dist/bin/hook.json that host's events.A
claudeCall-style function insrc/core/gate.tsthat turns the host's tool call into{ kind: 'edit', files }. For Codex, edits arrive asapply_patch, so the paths come from the patch headers.A transcript reader (
src/core/transcript.ts) for that host's chat file, so the viewer's chat panel and title work.A check that the host allows a tool call to wait long enough for
propose_plan, and that its hook sees the session id.
Hosts with no blocking hook can still use the MCP tools and the viewer, but cannot enforce the gate.
Good to know
The gate is a pattern match, not a sandbox: the shell guard blocks redirects and in-place edits only.
A hook that fails lets the call through, so a bug never locks you out of your own project.
Only files inside the project folder are gated.
State lives in the temp folder (
/tmp, orPLAN_CODE_TMP), one folder per chat.Plan Code shares its port, registry and viewer with the older Plan Gate plugin. Do not load both in the same chat, because both offer a
propose_plantool and the agent may pick the wrong one. Chat ids here arepc-<session id>, so the two never share state.If the shared viewer does not start by itself:
node dist/viewer/server.js --registry /tmp/plan-gate-registry --port 1234.
Development
npm testThe rules and hints are tested directly, the gate has its own tests, and one end-to-end test runs a real MCP server and real hook processes through propose, approve, edit, done, typed approval, a viewer message and gate off.
Status: early (0.1.0). Checked with unit tests, the end-to-end test, and live runs of claude -p in scratch folders. Only the Claude Code adapter exists so far.
License
MIT.
Example: the Claude Code plugin
Plan Code is a standard Claude Code plugin. These are the three files that wire it up, as they ship in this repo.
.claude-plugin/plugin.json: the plugin's identity.
{
"name": "plan-code",
"version": "0.1.0",
"description": "Review the file-tree plan before an AI agent writes code: approve files, block unplanned edits, watch the build live. Local MCP server plus hooks, no dependencies.",
"author": { "name": "NAMANIND", "url": "https://github.com/NAMANIND" },
"license": "MIT"
}.mcp.json: starts the MCP server that provides propose_plan, wait_for_approval and plancode.
{
"mcpServers": {
"plan-code": {
"command": "node",
"args": ["${CLAUDE_PLUGIN_ROOT}/dist/bin/mcp.js"]
}
}
}hooks/hooks.json: the gate. PreToolUse blocks unapproved edits; the other events carry typed approval and chat state.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write|MultiEdit|NotebookEdit|Bash|mcp__plugin_plan-code_plan-code__.*|mcp__plan-code__.*",
"hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/bin/hook.js\"", "timeout": 15 }]
}
],
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/bin/hook.js\"", "timeout": 15 }] }],
"Stop": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/bin/hook.js\"", "timeout": 15 }] }],
"SessionStart": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/bin/hook.js\"", "timeout": 15 }] }],
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/bin/hook.js\"", "timeout": 15 }] }]
}
}commands/plancode.md: the /plancode slash command, which calls the plancode tool with on, off or status.
---
description: Plan Code: review the file tree before AI edits (/plancode off to stop, /plancode status to check)
argument-hint: "[off | status]"
allowed-tools: mcp__plan-code__plancode, mcp__plugin_plan-code_plan-code__plancode
---
Call the `plancode` tool of the plan-code MCP server (`mcp__plan-code__plancode`).
- If the argument is `off`, call it with `action` set to `off`.
- If the argument is `status`, call it with `action` set to `status`.
- Otherwise call it with `action` set to `on`.
Argument: $ARGUMENTSTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Preventive human-approval write-gate for AI agents: writes commit only after a human approves.
Verify an AI agent action before it runs: approve, review or block, with a hash-chained audit log.
Pre-execution governance for AI agents. Deterministic PASS/FAIL/REVIEW verdicts, replayable proof.
Approval gateway for AI agents: they ask you before they send, share or delete.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceControls coding agents by enforcing structured implementation plans with PRs and commits as work units, requiring user review at each commit checkpoint to prevent agents from going off track. Includes a visualization dashboard for tracking progress in real-time.1MIT
- AlicenseNot gradedqualityDmaintenanceProvides interactive visual plans for AI coding agents, allowing users to review, approve, and monitor execution in real-time.643MIT
- AlicenseNot gradedqualityDmaintenanceProvides a human-in-the-loop security layer for AI agents by intercepting file operations, explaining them with a local LLM, and enforcing a deterministic policy that requires user approval for risky actions.MIT
- FlicenseAqualityCmaintenanceEnables coding agents to perform workspace-confined file operations, read-only Git inspection, and structured shell commands, while requiring out-of-band human approval for mutations and external executions and maintaining an audit trail.143-