Plan Lock MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Plan Lock MCP Create a plan to add user login, then start the first step"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Plan Lock MCP
Plan Lock MCP makes an LLM work through a markdown plan one atomic step at a time, holding a lock on the active step until it is resolved.
The Problem
Local coding models — especially the 30B class such as Qwen3-Coder — tend to emit eight to ten tool and shell calls in a single turn when asked to change code. Every call returns its output into the same conversation. The context window fills with interleaved command output, it becomes hard to tell which result belongs to which command, and a failed step is buried next to unrelated successful ones.
On the following turn the model has to re-derive "where was I" from that noisy history. On local hardware this is expensive: the KV cache is extended with tokens that describe bookkeeping rather than progress.
The result is slower and more chaotic work. Parallelism is often presented as a speedup, but for a local LLM it usually does the opposite: more output to parse, more state to reconcile, and a higher chance that one failing call invalidates the others.
Related MCP server: agent-project-mcp
The Idea
One atomic, verifiable step at a time. A step has a clear boundary: it is started, then either completed with a note or failed with a reason.
The plan lives outside the model. It is a markdown file, not a conversation history. The model re-reads it when it needs state instead of carrying the whole task history in context.
The lock is enforced by the server, not by the prompt. While a step is
[~],plan_nextrefuses to activate another one. Discipline is a property of the tool layer.Transitions are idempotent and crash-safe:
[ ]→[~]→[x]/[!]. State is on disk, so after a crash or restart the model continues from the marked step rather than guessing.
How it works
The usual loop is:
plan_create(steps)writes a fresh plan and backs up any previous one.plan_next()activates the first pending step and returns its id and text.The model does only that step, then calls
plan_done(id, note)orplan_fail(id, reason).Repeat.
plan_next()returnsPLAN_DONEwhen no pending steps remain.
flowchart LR
A["plan_create"] --> B["plan_next"]
B --> C{"lock active?"}
C -->|yes| D["error: Plan Lock active"]
C -->|no| E["next [ ] becomes [~]"]
E --> F["do only that step"]
F --> G{"result?"}
G -->|success| H["plan_done: [x] + note"]
G -->|failure| I["plan_fail: [!] + error"]
H --> B
I --> B
B -->|no pending| J["PLAN_DONE"]Tool | Parameters | Behaviour |
|
| Writes |
| none | Activates the next |
|
| Marks the active |
|
| Marks the active |
A step cannot be started twice: the server checks the active lock before activating anything else. Completed and failed steps are terminal.
Plan file
The plan is stored at .opencode/plan.md, relative to the current working directory. There is no hardcoded path and nothing is written to the home directory, so each project keeps its own independent plan.
# Plan — myproject
- created: 1732451234
- [ ] 1. Create database schema
- [~] 2. Implement API endpoints
- [x] 3. Configure authentication — note: JWT tokens configured
- [!] 4. Set up Redis cache — error: Connection timeoutThe header records the project name (basename of the working directory) and the creation time as a unix timestamp.
Marker | Meaning |
| Pending. |
| Active (locked). At most one step may have this marker. |
| Completed, with a |
| Failed, with a |
plan_create also creates or updates .opencode/.gitignore with plan.md and plan.md.bak, so neither the plan nor its backup is committed. When a new plan replaces an old one, the old content is written to .opencode/plan.md.bak first.
🏗️ Architecture
Plan Lock MCP is a thin enforcement layer around one markdown file. The model carries no plan state in memory: every tool call re-reads .opencode/plan.md, validates the requested transition, and writes the whole file back atomically. The file is the source of truth; the server is the referee.
flowchart LR
classDef client fill:#e3f2fd,stroke:#1976d2,color:#0d47a1
classDef decision fill:#fff3e0,stroke:#ef6c00,color:#e65100
classDef action fill:#e8f5e9,stroke:#2e7d32,color:#1b5e20
classDef disk fill:#f3e5f5,stroke:#6a1b9a,color:#4a148c
Agent["🧑💻 Coding agent"]:::client
Agent -->|"one tool call at a time"| Guard{"Guard checks:<br/>lock free? id valid?<br/>status = [~]?"}:::decision
Guard -->|"no"| Reject["Error response<br/>plan unchanged"]:::decision
Guard -->|"yes"| Write["_single_line + atomic write<br/>(RLock held throughout)"]:::action
Write --> Plan[(".opencode/plan.md<br/>single source of truth")]:::disk
Plan -->|"re-read on every call"| Guard
Plan -->|"step id + text / confirmation"| Agent
Reject --> AgentHow to read it:
The agent only sends requests. It never edits the plan file itself; the server writes it.
The guard is the discipline. While a step is
[~],plan_nextis rejected;plan_done/plan_failrequire a matching active id.The plan is the memory. Each call starts by reading the file, so a crash or restart loses nothing.
Writes are atomic and serialized.
tempfile.mkstemp+os.replaceunderthreading.RLockprevent partial files and double activation.
Step states
stateDiagram-v2
[*] --> Pending: plan_create
Pending --> Active: plan_next (only when no step is [~])
Active --> Completed: plan_done(id, note)
Active --> Failed: plan_fail(id, reason)
Active --> Active: plan_next → "Plan Lock active" (rejected)
Completed --> [*]
Failed --> [*]Only one step can be Active at a time. Completed and Failed are terminal: [x] carries a — note: suffix and [!] a — error: suffix. plan_create resets the cycle and backs up the previous file.
Install & Configure
Install the package, or run the single file directly:
pip install . # provides the `planlock` console script
python3 /path/to/planlock.pyRegister the server with the MCP client (for example opencode.json):
{
"mcp": {
"planlock": {
"type": "local",
"command": ["python3", "/path/to/planlock.py"],
"cwd": ".",
"enabled": true
}
}
}The cwd matters: it decides which project's .opencode/plan.md the server reads.
Add this directive to the agent's system prompt:
Plan Lock MCP is active. Call only one tool at a time.
Before starting a coding task, call plan_create.
Before each step, call plan_next and work only on the step it returns.
When the step finishes, call plan_done, or plan_fail if it failed.
Do not call other tools while a step is active.
If in doubt, read .opencode/plan.md to see the current state.The prompt is a reminder, not the enforcement. The lock itself is in the server.
Design notes
threading.RLockwith a decorator serializes each read-check-write cycle inside one server process, so two simultaneous tool calls cannot both see an unlocked plan and activate the same step.Atomic writes use
tempfile.mkstempin the target directory plusos.replace. A crash cannot leave a half-written plan, and the rename stays on the same filesystem._single_linecollapses whitespace in step text, notes, and reasons. A newline in a tool argument cannot inject a forged- [~]line and bypass the lock.No in-memory plan state. Every call re-reads the file, which keeps restarts simple and makes the on-disk plan the single source of truth.
Clean stdio. Nothing is printed to
stdout; diagnostics do not corrupt the MCP transport.The suite has 51 deterministic tests, all offline. Run
./test/test.shfor Ruff and pytest.
Limitations
The prompt does not make the model perfectly disciplined. It can still decide to skip the plan, work on a later step, or forget to release a lock. The MCP checks make this visible rather than silent: an out-of-order step is rejected instead of quietly corrupting the plan. Recovery is manual but cheap — read .opencode/plan.md, see the [~] step, and either finish it with plan_done or record the failure with plan_fail.
The lock is per server process. Two independent server processes pointed at the same working directory are not serialized against each other. There is also no validation of a plan file that was edited by hand into an invalid shape, such as duplicate ids or more than one [~] step; plan_create always writes a well-formed plan, but hand-edited files can confuse the parser.
Available Tools
4 toolsplan_createB
Create a new plan and write it to .opencode/plan.md.
Args: steps: List of step descriptions to add to the plan.
Returns: A message reporting the number of created steps on success, or an error message on failure.
Inputs: steps (required). Returns: result
plan_doneB
Mark the active [~] step as completed [x] and append a note.
Args: id: ID of the completed step. note: Short completion note to append to the step.
Returns: A success or error message.
Inputs: id (required), note (required). Returns: result
plan_failB
Mark the active [~] step as failed [!] and append a reason.
Args: id: ID of the failed step. reason: Reason for the failure.
Returns: A success or error message.
Inputs: id (required), reason (required). Returns: result
plan_nextA
Activate the next pending plan step ([~]) and return it.
Returns: The ID and text of the next step; an error message if a lock is already active or the plan file is missing; 'PLAN_DONE' when all steps are done.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a distinct action in the plan lifecycle: create the plan, activate the next step, mark the active step done, or mark it failed. There is no meaningful overlap, and the descriptions make the boundaries clear.
All tools use the same predictable pattern: `plan_` followed by a short verb (`create`, `next`, `done`, `fail`). The convention is consistent throughout.
Four tools are sufficient for this narrow plan-lock workflow, and each tool has a clear role. The surface is well-scoped rather than padded or thin.
The core lifecycle is covered: create a plan, activate the next step, and complete or fail it. However, there is no explicit tool to inspect the full plan/status, reset a stuck lock, or retry a failed step, leaving minor gaps.
Maintenance
Related MCP Connectors
The plan your AI agents work from. Project management and customer feedback for agent teams.
Deterministic runtime enforcement of step order for AI agents: ALLOW/DENY before a step runs.
Agent-native notes, tasks, dev-docs, vaults, sync & handoffs. MCP + OpenAPI dual surface.
A task list shared by you and your coding agents (Claude Code, Cursor, Codex and any MCP client). Agents plan each task into steps, report live progress to a board, and block on questions you answer from your phone.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnforces a git-tracked, code-checked finite state machine that hands control between a planning director and a local Ollama implementor, exposing tools to check phase status, transition states, and run the implementor to execute plan step files one at a time. It enables a project to be planned, implemented step by step with per-step test gating, and validated before completion.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables any MCP-capable coding agent to share one plain-Markdown project state — goals, tasks, decision logs, and session handoffs — stored in a project's .apm/ directory, with lock-safe concurrent writes and consistency checks that flag stale, blocked, or unowned work. This lets multiple agents and a human CLI resume work across interrupted sessions without a database or external service.MIT
- AlicenseNot gradedqualityAmaintenanceEnables structured multi-agent workflows by managing task claims, action logs, handoffs, and health-gated completion while keeping specifications as filesystem Markdown artifacts.29 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI coding providers to run structured multi-agent workflows by claiming tasks, logging actions, managing handoffs, and enforcing server-side health gates across explorer, consultant, builder, and reviewer roles. Specifications stay as Markdown on disk while tracked task state, acceptance evidence, and completion checks are owned by the server.29 npmMIT