specgate/docs v1.8.0

The MCP server#

At the end of this page an MCP client (Claude Desktop, Cursor, Claude Code, Antigravity) can run the same loop the terminal has: what is open, opening a change, the gate, and delivering a requirement. MCP, the Model Context Protocol, is how these clients call outside tools.

You need: a project where specgate init has run, and Node.js 22 or later on the machine that runs the client. The server ships inside the Specgate package; there is nothing else to install.

The MCP server: an agent's tools, grouped by what they do, and what is never a tool An MCP client — Claude Desktop, Cursor, Claude Code, Antigravity — sends a tool call to the MCP server, specgate mcp serve over stdio, and gets back the command's JSON with its status. The server runs the Specgate CLI in the project's folder, projectDir: spec.md, docs/specs/, features/ and the tests. Its tools fall into three groups. Read the state: specgate_status, plan, read_spec, list_requirements, validate_project, specgate_check, specgate_verify, and specgate_change_show, list, status and instructions. Write the work: specgate_change_new, which is propose and opens a change; specgate_new, the specgate_req_ tools and specgate_fix; mark_requirement_done, which is apply and runs the gate first; and specgate_change_archive, which is archive. Tools that write the specification are refused while no change is open. Configure: specgate_config_get with a key, specgate_config_set with a key and a value, specgate_config_list and keys; specgate_agents_init, which takes only the project and installs every agent's commands; and specgate_harness_init. Never a tool: approving a change, since specgate change approve is a person's act at a terminal; and switching the guard off, since config set agent_guard off with no terminal fails with guard_needs_person. THE TOOLS — EACH RUNS THE CLI IN projectDir MCP client Claude Desktop · Cursor Claude Code · Antigravity MCP server specgate mcp serve over stdio Your project spec.md · docs/specs/ features/ · tests Read the state specgate_status · plan · read_spec · list_requirements validate_project · specgate_check · specgate_verify specgate_change_show · _list · _status · _instructions Write the work spec writes refused while no change is open specgate_change_new — propose: opens a change specgate_new · specgate_req_* · specgate_fix mark_requirement_done — apply: the gate first specgate_change_archive — archive Configure specgate_config_get key · _set key value · _list · _keys specgate_agents_init — every agent; no tool to pick specgate_harness_init Never a tool Approving a change — specgate change approve is a person's act, at a terminal. Switching the guard off — config set agent_guard off with no terminal fails: guard_needs_person. tool call ⇄ JSON + status runs the CLI offers
Over MCP an agent reads the state, writes its work and configures the project; approving a change and switching the guard off stay a person's acts at a terminal.

Install it#

bash
specgate mcp install --client claude     # Claude Desktop
specgate mcp install --client cursor     # Cursor (~/.cursor/mcp.json)
specgate mcp install --client opencode   # OpenCode: the project's opencode.json
specgate mcp install --client codex      # Codex: runs `codex mcp add`, your own Codex configuration

It merges a spec-driven entry into the client's config and leaves the rest of the file alone. Restart the client and the tools appear.

By hand, the entry is:

json
{
  "mcpServers": {
    "spec-driven": {
      "command": "npx",
      "args": ["-y", "@rsaglobaltech/specgate@latest", "mcp", "serve"]
    }
  }
}
ClientConfig file
Claude Desktop (macOS)~/Library/Application Support/Claude/claude_desktop_config.json
Claude Desktop (Windows)%APPDATA%\Claude\claude_desktop_config.json
Cursor~/.cursor/mcp.json
Claude Codethe Specgate plugin's .mcp.json — see Install the Claude Code plugin
Antigravity.agents/mcp_config.json — written by specgate agents init --tool antigravity
OpenCodethe project's opencode.json
Codexyour own Codex configuration, through codex mcp add

specgate mcp serve is what every one of those configs starts: the server, over stdio, calling the CLI that serves it. You never run it yourself.

The tools#

Every command is a tool named specgate_<command> — specgate_status, specgate_ci_init, specgate_change_new, … A tool whose command takes a positional argument declares it in its input schema — title for specgate_new, requirement for mark_requirement_done and req_*, id for specgate_change_*. Commands driven by flags (specops add, pack init, …) are better run from a terminal. The ones an agent uses every day:

ToolDoesArguments
specgate_statusWhat is open, and the next command to run.projectDir
specgate_newA requirement with its tagged scenario.projectDir, title
specgate_checkThe gate, then the tests when a test command is configured.projectDir
specgate_verifyFor an OpenSpec project: every scenario an archived change claims must be named by a test (ADR-0030). Accepts a directory with openspec/ and no spec.md.projectDir
mark_requirement_doneRuns the gate for the requirement, then marks it Implemented.projectDir, requirement
planThe pending queue, with what each requirement still needs.projectDir
validate_projectvalidate --strict, parsed.projectDir
read_specspec.md, and the list of every docs/specs/*.md.projectDir
list_requirementsEvery REQ-NNN with its title, file and line.projectDir

The tools that configure the project take only what their schema declares — anything else the client sends is dropped:

ToolDoesArguments
specgate_config_getOne setting's value, and the file it lives in.projectDir, key
specgate_config_setSets one setting (test_cmd, arch_cmd, …). agent_guard off is refused with no terminal (guard_needs_person).projectDir, key, value
specgate_config_list · specgate_config_keysEvery setting, and every key there is.projectDir
specgate_agents_initInstalls the /specgate:* commands and rules for every agent it knows — there is no argument to pick one; for one tool, run specgate agents init --tool <name> in a terminal.projectDir

Seven short names (read_spec, list_requirements, update_traceability, lint_pack, validate_project, plan and mark_requirement_done) predate the generated specgate_* names and keep working.

The terminal's four commands do not have tools under their own names yet. Over MCP the same loop is:

TerminalMCP tool
specgate propose <id>specgate_change_new, with id
specgate apply <REQ>mark_requirement_done, with requirement
specgate statusspecgate_status
specgate archive <id>specgate_change_archive, with id

specgate_change_archive refuses, as the terminal does, while a requirement the change adds or modifies is not Implemented.

Every tool answers with the command's JSON document: a payload plus status, a list of diagnostics with a stable code and a fix. Branch on code, never on the message. → The agent contract

The guard: an agent may not rewrite its own exam#

Tools that write the specification — specgate_new, mark_requirement_done, specgate_req_*, specgate_fix, specgate_expand, specgate_specops_*, specgate_init, specgate_update, specgate_harness_run — refuse unless a change is open:

text
specgate_new writes files the specification contract protects, and no change
is open. …

Open a change first: specgate propose <id> in a terminal, or the specgate_change_new tool. An agent that cannot make a scenario pass could otherwise relax the scenario, and the gate would approve. A change is the way to edit a spec on purpose, and it leaves a trail a person reviews.

When the team wants the agent to drive the daily loop directly, allow it in the repository, where the decision is reviewed like any other — in .specgate/config.json:

json
{ "mcpAllowContractEdits": true }

specgate_change_* tools are never guarded: they are how a change is opened.

A session#

With the server configured, ask in plain words:

Add a requirement for downloading invoices as PDF, implement it, and close it when the gate is green.

  1. The client calls specgate_change_new (id: add-invoice-pdf). The change is open, with a delta to write and REQ ids reserved.
  2. It writes the requirement and its scenario in the change's delta. Then it stops: a person reads the delta and approves the change, in a terminal (specgate change approve add-invoice-pdf) or in the studio's Review.
  3. It writes a test that mentions the new REQ-NNN, and the code.
  4. It calls mark_requirement_done with that id. It wraps specgate apply: the gate runs first. If nobody approved the change (change_not_approved), the scenario still has template steps, or no test mentions the requirement, the call comes back with the reason (exactly what the terminal would say) and nothing is written.
  5. Once the requirement is Implemented, it calls specgate_change_archive (id: add-invoice-pdf), and the change merges into the specs.

There is no tool that approves a change, by design: approving is a person's act. A client that calls mark_requirement_done on an unapproved change is refused until a person approves it at a terminal.

You review the branch and open the pull request as usual.

When it does not work#

SymptomCauseFix
No tools appearThe client was not restarted, or npx is not on its PATHRestart; on macOS GUI apps, point command at the absolute path of npx
Every writing tool refusesThe guard, workingOpen a change, or set mcpAllowContractEdits
specgate_check says tests not configuredNo test commandspecgate config set test_cmd "npm test"
An old config runs @specgate/mcp-serverThat package was never publishedRe-run specgate mcp install or specgate agents init

Next#

  • Agents: slash commands and instruction files for your agent tools
  • The harness: the same loop, unattended