The MCP server
groundrule mcp runs a Model Context Protocol server for your coding agent. It gives the agent three tools: list_standards reads the rules in effect in the repository, check checks the agent’s changes against them, and propose_rule sends a rule to your team’s inbox for review. This page shows how to set it up in each agent, what each tool takes and returns, and how to fix common problems.
What MCP is
Section titled “What MCP is”The Model Context Protocol (MCP) is a standard way for a coding agent to call tools outside itself. The agent starts the tool as a local program and exchanges JSON messages with it over standard input and output. Claude Code, Cursor, VS Code and many other agents support it.
Groundrule’s server is part of the CLI. It runs on your computer, in your repository, and needs no extra install:
npx -y @groundrule/cli mcpYou don’t run this yourself. You tell your agent to start it, and the agent talks to it.
Set it up
Section titled “Set it up”The agent must start the server from inside the repository. The server reads .groundrule/config.yaml from its working folder, the same way the CLI does.
In your repository, run:
claude mcp add groundrule -- npx -y @groundrule/cli mcpTo share the server with everyone who works in the repository, add it to .mcp.json at the repository root and commit it:
{ "mcpServers": { "groundrule": { "command": "npx", "args": ["-y", "@groundrule/cli", "mcp"] } }}Create .cursor/mcp.json in the repository:
{ "mcpServers": { "groundrule": { "command": "npx", "args": ["-y", "@groundrule/cli", "mcp"] } }}Cursor shows the server and its two tools in its MCP settings. Turn it on there if Cursor asks.
Create .vscode/mcp.json in the repository. VS Code calls the list servers:
{ "servers": { "groundrule": { "type": "stdio", "command": "npx", "args": ["-y", "@groundrule/cli", "mcp"] } }}Start the server from the file, or from the MCP server list, and allow it in agent mode.
Any MCP client that can start a local (stdio) server works. Give it:
| Setting | Value |
|---|---|
| Command | npx |
| Arguments | -y, @groundrule/cli, mcp |
| Transport | stdio |
| Working folder | The repository root |
If the client can’t set a working folder, pass the repository with the CLI’s global -C option: npx -y @groundrule/cli -C /path/to/repo mcp.
You should see a server named groundrule with the tools list_standards and propose_rule. Ask your agent “Which Groundrule standards apply here?”. It should call list_standards and answer from the result.
If the agent shows the server as failed, see Troubleshooting below.
What you need
Section titled “What you need”| To use | You need |
|---|---|
list_standards, offline mode |
A .groundrule/config.yaml with extends (no platform). Nothing leaves your computer. |
list_standards, connected workspace |
A config with platform: and a valid sign-in: groundrule login, or GROUNDRULE_TOKEN in the agent’s environment. The server reads the rulebook from Groundrule, the same way sync does. |
rules_for |
The same as list_standards. Nothing is sent anywhere. |
check |
The same as list_standards. Checks run on your computer. In a connected workspace the counts per rule are reported to it (see What the workspace learns); offline, nothing leaves your computer. |
propose_rule |
A config with platform: (or GROUNDRULE_TOKEN set), and a sign-in whose token can propose rules. groundrule login gives that permission. A token from Settings → API tokens needs Propose rules ticked. |
Node.js 22 or later must be on the agent’s PATH, because the agent runs npx. See Install the CLI.
The hosted server
Section titled “The hosted server”Groundrule also runs the server for you at https://mcp.groundrule.dev/mcp. Nothing to install, and agents always get the workspace’s latest rules. It’s useful where the CLI can’t run, such as cloud agents and web IDEs.
Local (groundrule mcp) |
Hosted (mcp.groundrule.dev) |
|
|---|---|---|
| Install | Node.js and the CLI | Nothing |
| Sign-in | groundrule login |
Sign in in the browser, or an API token in the Authorization header |
| Tools | list_standards, check, propose_rule |
list_standards, get_standard, propose_rule |
| Which rules | The repository’s, from its config, filtered by its languages | The workspace’s, or a repository’s when the agent passes repository (owner/name) |
| Your code | Checked on your computer | Never sent; there is no hosted check |
The hosted server never receives source code, so it has no check tool. Keep the stop hooks, or the local server, for checking.
Connect an agent
Section titled “Connect an agent”Add the server by its address, then sign in in the browser. In Claude Code:
claude mcp add --transport http groundrule https://mcp.groundrule.dev/mcpThen, in Claude Code, run /mcp, choose groundrule and Authenticate. Other agents (Cursor, VS Code and others): add an HTTP (streamable) MCP server with the URL https://mcp.groundrule.dev/mcp; they offer to sign in the first time they connect.
Your browser opens Groundrule’s consent page (sign in first if you aren’t):

- Check the agent’s name and where it Returns to. A name marked Unverified name is what the agent calls itself. Allow it only if you just connected Groundrule in that agent.
- Choose the workspace.
- Untick Propose rules for review if the agent should only read rules.
- Choose Allow.
You should see “Returning to your agent”, and the agent shows the server connected with three tools. Ask, for example, “List the Groundrule standards for acme/payments-api”.
The agent keeps access by renewing its sign-in every hour, until you sign it out. To sign an agent out, open Settings → API tokens → Agents signed in and choose Sign out. Admins see everyone’s agents and can sign out any of them. Leaving the workspace signs your agents out too.
For agents that can’t open a browser (CI, cloud agents), use an API token instead. Create one in Settings → API tokens with Propose rules ticked, and send it as a header:
claude mcp add --transport http groundrule https://mcp.groundrule.dev/mcp --header "Authorization: Bearer grt_your_token"Keep the token out of files you commit.
Hosted tools
Section titled “Hosted tools”list_standards:repository(owner/name, so its team’s settings apply) andquery, both optional. Each rule lists its languages and paths, because the server can’t see your files.get_standard:id, and optionallyrepository. One rule in full: requirement, why, how to fix, and examples.rules_for:files(repository-relative paths) and optionallyrepository. The same answer as the local tool: the rules that name those files, by path or language, with the rest counted.propose_rule: the same as the local tool, plusrepository. The proposal is recorded as yours, with the agent’s name. It needs a token with Propose rules; otherwise the agent is told so.
If it goes wrong
Section titled “If it goes wrong”| What you see | What to do |
|---|---|
| The agent says it needs to authenticate, or gets 401 | Sign in again from the agent (in Claude Code, /mcp → Authenticate). With an API token: the header is missing, or the token expired or was revoked |
| The consent page says “This agent isn’t registered, or its registration couldn’t be read.” | Remove the server from the agent and add it again, so it registers afresh |
| The consent page says “The redirect address doesn’t match the agent’s registration.” | The sign-in didn’t come from the agent that registered. Start it again from the agent |
| “Not proposed: this token can’t propose rules.” | Create a token with Propose rules |
| “Too many requests. Wait a minute and try again.” | Over 300 requests a minute for one token, or 3,000 for the workspace |
| 403, “Browser requests aren’t accepted here.” | The server is for agents, not web pages |
What the server tells the agent
Section titled “What the server tells the agent”When an agent connects, the server sends these instructions. Agents use them to decide when to call each tool:
Groundrule holds this team’s engineering standards. Call list_standards to see the rules in effect before writing or reviewing code, and follow them. Before you edit a file, call rules_for with its path: it returns the rules that name that file, which the full list buries. Before you finish a change, call check and fix every blocking finding it reports. When the developer corrects you about how code in this codebase should be written and says, or confirms when you ask, that it should apply to everyone from now on, call propose_rule so the team can adopt it. Never propose one-off preferences, rules that already exist, or anything the developer didn’t ask for or agree to.
In practice: the agent asks for the rules of a file before changing it, checks its work before it finishes, and proposes a rule only when you’ve said, or confirmed, that it should apply to everyone.
list_standards
Section titled “list_standards”Lists the standards in effect in this repository. It is read-only.
| Field | Type | Required | What it does |
|---|---|---|---|
query |
string | No | Only standards whose ID, title, or requirement contain these words. Every word must match, in any order, ignoring case. |
What it includes
Section titled “What it includes”- Standards whose status is
activeand that no config override disables. - Only standards that apply to this repository (its languages, frameworks, tags and name).
- For a connected workspace: the organization’s rules at Teach, Advise and Enforce, plus your repository’s own standards in
.groundrule/standards/. Observe rules and drafts aren’t included.
Rules are sorted by severity (blocker first), then by ID.
Output
Section titled “Output”The agent receives one line per standard:
ACME-004 (blocker · advise: findings warn, never fail · checked automatically) Route all Stripe calls through the gateway: Never import stripe outside src/payments/gateway.ts. Call the gateway's functions, such as createPaymentIntent, instead. [applies to src/**]SEC-003 (blocker · enforce · checked automatically) No access tokens in code: Never hard-code cloud keys or API tokens (AWS, GitHub, Slack, Stripe live keys). Read them from the environment or a secret manager.Each line has:
- the ID;
- in parentheses, the severity, for an organization rule its stage note, and
checked automaticallywhen a deterministic or static-analysis check runs on it at its current stage (Advise, Enforce, or a rule without a stage). Agents can tell which rules a check will catch and which only they can keep; - the title, then the rule’s
agent.summaryif it has one, otherwise its requirement; [applies to …]when the rule haspaths.
The stage notes are:
| Stage | Note | What groundrule check does with findings |
|---|---|---|
| Teach | teach: guidance only |
Doesn’t check it. |
| Advise | advise: findings warn, never fail |
Shows them as warnings. |
| Enforce | enforce |
Counts them at the rule’s severity. |
Standards from offline packs and your own .groundrule/standards/ files have no stage, so the parentheses only hold the severity, for example ACME-004 (blocker).
When nothing matches, the text is No standards match "<query>"., or No standards are in effect in this repository. without a query.
Clients that read structured results also get the same data as JSON:
{ "standards": [ { "id": "ACME-004", "title": "Route all Stripe calls through the gateway", "severity": "blocker", "stage": "advise", "requirement": "Never import stripe outside src/payments/gateway.ts. Call the gateway's functions, such as createPaymentIntent, instead.", "paths": ["src/**"] } ]}stage appears only for organization rules, and paths only when the rule has them.
rules_for
Section titled “rules_for”The rules that name the files the agent is about to create or edit (CLI 0.17.0 and later). It is read-only, and nothing is sent anywhere. Claude Code gets the same answer without asking, through the before-edit hook.
| Field | Type | Required | What it does |
|---|---|---|---|
files |
array of strings | Yes | Repository-relative paths, 1 to 50, for example src/payments/refund.ts. |
What it includes
Section titled “What it includes”Only rules with a path scope (scope.paths or scope.exclude) are listed, matched against each file; a rule’s languages are matched by the file’s extension. Rules that apply everywhere are in the agent file already, so they are counted, not repeated. Rules at Teach and above are included, like list_standards.
Output
Section titled “Output”Groundrule rules for src/payments/refund.ts (follow these; 41 repository-wide rules are in the agent file):- ACME-004 (blocker · advise: findings warn, never fail · checked automatically) Route all Stripe calls through the gateway: Never import stripe outside src/payments/gateway.ts. Fix: Call the gateway's functions, such as createPaymentIntent, instead.Blocking severities come first. With several files, each line ends with the files it applies to in brackets. At most 25 rules, within 4,000 characters; after that: …and N more; call list_standards for the full list. When no rule names the files: No rule names src/app.ts specifically. 41 repository-wide rules apply everywhere; they are in the agent file (AGENTS.md or CLAUDE.md).
Structured results carry rules (each with id, title, severity, stage for organization rules, requirement, fix, checked, and files), unscoped and more.
Runs the same checks as groundrule check on the agent’s changes, so it can fix findings before it finishes. It is read-only. In a repository connected to its workspace, it reports the counts per rule after answering the agent; see What the workspace learns.
| Field | Type | Required | What it does |
|---|---|---|---|
base |
string | No | Check everything changed since this git ref, such as origin/main for the whole branch, uncommitted work included. Without it, only uncommitted changes (staged, unstaged and new files) are checked. |
all |
boolean | No | Check every file, not only changes. Slower, and reports existing problems too. |
A base that isn’t a git ref comes back as an error, for example "--output=x" isn't a git ref, such as origin/main.
Output
Section titled “Output”Only findings the change introduced are listed, not legacy findings or ones covered by an exception, blocking first, at most 30:
Groundrule check failed on uncommitted changes: 1 blocking finding. Fix it before you finish, then check again.- SEC-003 No access tokens in code (blocker) at src/config.ts:4: Access token or key found in code. Fix: Revoke the token now, then read it from the environment or your secret manager.For the reasoning and examples behind a rule, run `npx @groundrule/cli explain <ID>`.When nothing fails: Groundrule check passed on uncommitted changes. Warnings follow under “Warnings (they don’t fail the check; fix the ones in code you wrote)”. AI findings are marked AI.
The structured result holds failed and findings, each with standardId, title, severity, blocking, source, file, line, message and fix.
To run the check every time the agent finishes, whether or not it calls the tool, add hooks.
propose_rule
Section titled “propose_rule”Sends one rule to your organization’s inbox. Nothing changes in the rulebook until a reviewer accepts it. See The review inbox.
| Field | Type | Required | Rules |
|---|---|---|---|
rule |
string | Yes | The rule as one clear sentence: what to do or never do. 10 to 1,000 characters after trimming. |
why |
string | No | Why, in the developer’s words. Up to 1,000 characters. |
example |
string | No | A short code example of the right or wrong way. Up to 2,000 characters. |
file |
string | No | Where it came up, as a path relative to the repository. Up to 400 characters. Absolute paths and .. are refused. |
line |
integer | No | A line in that file, 1 or more. |
No other fields are accepted. A rule that is too short comes back as Not proposed: rule: Say the rule in a sentence.
What is sent
Section titled “What is sent”Only what the proposal contains leaves your computer:
- the five fields above;
- the repository name, from
platform.repositoryin your config or from theorigingit remote; - the agent’s name, as its MCP client reports it (lowercased, for example
claude-code).
No file contents are sent. Groundrule removes secrets from the text before storing it. The proposal is recorded as yours: it shows your name and the agent that sent it.
Results
Section titled “Results”| Result text | What happened |
|---|---|
Proposed to <workspace>. A reviewer will accept or reject it in the Groundrule inbox (<url>). |
A new proposal is in the inbox. |
Already proposed in <workspace>; this was added to it. A reviewer decides. |
The same rule was proposed before. Yours counts as a vote. |
Not proposed: reviewers in <workspace> already rejected this rule. Tell the developer; they can ask a reviewer to reopen it. |
A reviewer rejected this rule earlier. |
… Similar existing rules: ACME-004, SEC-003. |
Added to any of the above when the rulebook has rules with similar wording. |
Not proposed: <reason> |
Nothing was sent, or the platform refused it. The reason says why (see below). |
The structured result holds the proposal’s id, status (open, accepted or rejected), duplicate, similar (IDs with a score), the inbox url, and the org.
The same feature is available to people as groundrule propose. See the Command reference.
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Proposals per person | 30 per hour |
| Proposals per organization | 500 per day |
Over a limit, the result is Not proposed: Too many proposals. Wait a while and try again.
Troubleshooting
Section titled “Troubleshooting”| What you see | What to do |
|---|---|
This repository has no Groundrule configuration, or it couldn't be loaded. Run `groundrule doctor`. |
The server didn’t find .groundrule/config.yaml, or the config has errors. Check that the agent starts the server in the repository (or pass -C <repo>), and run npx @groundrule/cli doctor there. |
Not proposed: This repository isn't connected to Groundrule. Run `groundrule init --org <your-org>`, or pass --org. |
The config has no platform: section. Connect the repository with npx @groundrule/cli init --org acme-payments --force, or add platform: { org: acme-payments } to the config. |
Not proposed: Not signed in to acme-payments on https://app.groundrule.dev. Run `groundrule login` first. |
Run npx @groundrule/cli login in a terminal. The server reads the same saved login. |
Not proposed: This sign-in can't propose rules yet. Run groundrule login again to refresh it. |
The token lacks the propose permission. Run login again, or create a token with Propose rules. |
list_standards returns the “no Groundrule configuration” message in a connected repository |
Loading the rulebook failed. The exact reason, such as Not signed in to acme-payments on https://app.groundrule.dev. Run `groundrule login` (or set GROUNDRULE_TOKEN in CI)., is in the agent’s MCP log. Run npx @groundrule/cli doctor in the repository to see it in a terminal. |
doctor or the MCP log says Your sign-in to acme-payments has expired or was revoked. Run `groundrule login` again. |
Run login again. Tokens from login last 90 days, and an admin can revoke them in Settings → API tokens. |
| The agent shows the server as failed to start | Run npx -y @groundrule/cli mcp in a terminal. It should wait silently for input (press Ctrl-C to stop). If npx isn’t found, the agent can’t see Node.js: start the agent from a shell where node --version prints 22 or later. |
✕ groundrule mcp needs standard input; run it from your coding agent's MCP settings. |
The server was started without standard input. Start it from the agent’s MCP settings. |
| The agent never calls the tools | Ask it directly, for example “Check the Groundrule standards before you change this”. Some agents need the server turned on per chat or per workspace. |
The server writes the protocol to standard output and its own messages to standard error, so diagnostics show up in your agent’s MCP log.
Related
Section titled “Related”- Agent instruction files
- Check when the agent finishes
- Command reference
- Environment and files:
GROUNDRULE_TOKEN,GROUNDRULE_URLand where logins are saved.