Skip to content

About

Unofficial, opinionated Linear MCP server: whole ticket reads, the description as state, rules enforced in the server

Topics

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

linear-strict

Unofficial and opinionated. This is an independent project, not affiliated with or endorsed by Linear. It enforces one team's way of keeping tickets current, and it refuses writes that other Linear servers would make. For Linear's own MCP server, see linear.app/docs/mcp.

An MCP server for Linear for teams where agents keep tickets up to date. It reads a ticket whole and treats the description as the ticket's current state. The rules are enforced in the server, so a prompt that goes unread or a client hook that stops matching can't switch them off.

It has one runtime dependency, the MCP SDK. It began as a fork of tacticlaunch/mcp-linear (MIT), whose OAuth login it keeps.

The problem it addresses

Linear keeps full history, yet agents working from it drift:

  • State ends up in comments. A comment answers the ticket's open question and the description still says it is open. Nothing marks which claim is current.
  • Reads are lossy without saying so. Listings cut descriptions short, comment APIs default to newest first, and summaries read like the whole ticket.
  • Tickets change after they are read. An agent works from a snapshot, acceptance criteria are added later, and the work ships without them.
  • Rules in client hooks go dark when a server is renamed and the matcher no longer fires.

How it works

  • Description is state, comments are the log. The description has named sections: Observed, Cause, Fix, Done when, Open questions. It changes only through validated section patches. An Observed line must read YYYY-MM-DD · source · result (a time after the date is fine), and Done when lines must be checklist items.
  • A reconciled marker is the description's HEAD. It records the last comment the description accounts for, when that was checked, and the hash of the description it was checked against. It lives in one attachment on the ticket, titled "linear-strict: description reconciled through …", so the description stays clean. Every read reports comments after it, comments edited since the check, and edits to the description made outside this server, as drift.
  • Repair on read. Not everyone on a team will use this server. get_issue reports format findings and drift on tickets written from any client, and tells the agent to fold them into the description.
  • Whole reads. Every comment, oldest first, across all pages. list_issues and the workspace lists (teams, cycles, projects, initiatives) walk every page too, so an agent never holds a cursor it can stop following. Anything not fetched is listed in omitted; a gap is never silent.
  • Typed comments. evidence, correction, ask, answer and closed_by. A correction must carry the description patch that makes it true. An answer flips its question row. closed_by also sets the Linear relation.
  • Writes name what they were written against. get_issue returns a hash of the description, description_sha. A patch passes it as base and is refused, with what changed, if the description moved since that read. Linear has no conditional update, so this is how a patch shows it was built from the current text.
  • Claim, then a Done gate. claim records the description as it stands. Moving to a completed state needs a Done when section with every item ticked and cited (- [x] item · <SHA, PR, file:line, link, CI run, Observed 2, or a command and its result>), any cited PR that is linked to the ticket merged, and your claim, and is refused with a diff if the description changed since then. Priority or label changes don't count. Dropping an unticked item needs a reason and a yes from the person at the client, or from a model judge in unattended sessions.
  • Shipped-state facts. A ticket marked Done or Merged with no linked pull request, or with PRs merged only into a non-main branch, gets a finding. The facts come from Linear's GitHub attachment metadata.
  • A release-note label and line on every ticket. Where the workspace has the labels release-note and release-note-none, create_issue needs release_note (yes, none, or selfhost where release-note-selfhost exists) and records it as one of them, and get_issue flags a ticket that carries none of them. The agents' own team defaults to none. Whoever writes the ticket decides once whether a visitor will notice it, the way Kubernetes' release-note-none works, instead of a model ranking every shipped ticket at release time. set_fields changes it with release_note. What the note says is the ticket's ## Release note section, one line written when the work ships: <Added|Changed|Fixed|Removed|Security> · <Alpha|Gap Map|AI Potluck|Self-host> · <sentence> · flag: <key|none>, or NONE, which moves the ticket to release-note-none in the same write. Moving a release-note or release-note-selfhost ticket to Merged, Verify or a completed state without a line that parses returns a release_note_missing warning; with LINEAR_STRICT_RELEASE_NOTE_GATE=block, set_status refuses the move.
  • A hands-off label. A ticket labelled no-agents (configurable) is people-only: every write through this server is refused, and reads still work.
  • Authorship. An agent (app) token writes as the agent. A personal key writes comments headed 🤖 <agent> via <person>. Each comment on a read is marked agent or person, with the basis for that call.

Related work

  • Linear's agent best practices warn that "Comments may not be reliable to read from, as they are editable and may have changed since your agent’s last run." Their answer, Agent Activities, covers agents running in Linear's Agent Sessions. Here, drift lists comments edited after the description accounted for them.
  • Linear's agent team found it "more effective to encode constraints into the design of Linear Agent’s tools than to spell them out in a prompt", which is the approach this server takes. claim follows their delegation model: a person stays the assignee, accountable for the result, and the agent is the delegate.
  • Linear keeps version history and text attribution for documents. description_history reads the same snapshots for an issue's description.
  • OpenAI's Symphony keeps an agent's progress in one persistent comment per ticket and tells the agent to leave Backlog tickets alone. This server keeps that state in the description, which Linear versions and every client shows first, and enforces the hands-off label in the server rather than in the prompt.
  • Cyrus has each sub-issue's agent hand back verification commands for the parent to run, and openclaw-linear-plugin has a separate auditor so the worker "cannot self-certify". The Done gate here asks for cited evidence but still lets the agent that did the work supply it.
  • Staleness in the wild: herdr-factory#97 shipped work against a ticket snapshot that lacked acceptance criteria added later, trac-mcp#57 had an agent stop trusting an MCP server after silent data loss, and beads#3708 and catalyst-otel#68 had Linear mirrors go stale without saying so.

Install

Quickstart (Claude Code)

  1. Get a Linear credential. A personal API key (Linear → Settings → Security & access → Personal API keys) writes as you. An agent (app) token, an OAuth token for a Linear app with actor=app starting with lin_oauth_, writes under the agent's own identity and can be set as a ticket's delegate.

  2. Add the server and the sign-off hooks:

    npm install -g https://github.com/justinstimatze/linear-strict/releases/download/v0.2.0/linear-strict-0.2.0.tgz
    claude mcp add linear-strict -e LINEAR_API_TOKEN=<token> -- linear-strict
    linear-strict install
  3. Reconnect with /mcp, then ask the agent to read a ticket.

You need Node 22 or later. Each GitHub release carries the built package; it is not on npm. To upgrade, npm install -g the newer release's .tgz, then run linear-strict install again and reconnect.

To work on it, run it from a checkout instead:

git clone https://github.com/justinstimatze/linear-strict.git
cd linear-strict && npm ci && npm run build
claude mcp add linear-strict -e LINEAR_API_TOKEN=<token> -- node "$PWD/dist/index.js"
node dist/index.js install

After a git pull, run npm run build again and reconnect the server.

Pin the version, and give the server its own name, linear-strict. Tool names such as get_issue also exist on Linear's official server, so the server name is what tells an agent and any hook matcher which rules apply. To sign in through the browser instead of pasting a token, see OAuth login.

The two hook installers

  • linear-strict install adds the sign-off hooks to ~/.claude/settings.json, once per machine. install --status says whether they are installed and whether they can still run; install --uninstall removes them and nothing else. Installed through npx, the hooks run the same pinned version through npx, since npm prunes the cache npx runs from. After upgrading, run install again so the hooks match the server; until then the server asks through the form.
  • examples/claude-code-hooks/install.sh is optional and per project: it refuses ticket writes through other Linear servers and runs a project's own Linear checks on strict writes (Blocking writes through other Linear servers). Its hooks run its scripts by path, so run it from a checkout or the global install above, not through npx.

The two write different entries and can both be installed.

Other clients

Claude Desktop, in claude_desktop_config.json, after the global install above:

{
  "mcpServers": {
    "linear-strict": {
      "command": "linear-strict",
      "env": { "LINEAR_API_TOKEN": "<token>" }
    }
  }
}

Everything except sign-off works the same in any MCP client. Sign-off depends on what the client offers:

Client How a descope is approved
Claude Code with linear-strict install AskUserQuestion, with the whole change in its preview box
Claude Code without the hooks An elicitation form, with rows of about 100 characters
Other clients that support MCP elicitation That client's elicitation form
Clients without elicitation, Claude Desktop included as far as its docs say Refused; a person makes the edit in Linear, or run with LINEAR_STRICT_SIGN_OFF=judge

Hooks are a Claude Code feature, so no other client gets the preview route.

Sign-off

Dropping or rewording an unticked Done when item removes a check that has not passed, so someone other than the agent approves it. LINEAR_STRICT_SIGN_OFF picks who:

  • person (the default): the person at the client. In Claude Code with the sign-off hooks installed, set_state hands the agent an AskUserQuestion to put to them, and the change is shown in full in its preview box. A hook refuses the question if the agent changes a word of it, another hook records the answer, and the retry is approved from that record, never from what the agent says. Elsewhere, and in Claude Code without the hooks, the server asks through an MCP elicitation form, which Claude Code shows as rows of about 100 characters.
  • judge: a model with no stake in the ticket decides, so an unattended session never waits for someone who isn't there. It reads the ticket's description, the change, the reason and the risk, approves only when the description backs the reason, and the descope comment names the model and gives its reason for a person to review later. It needs an Anthropic API key: linear-strict auth judge-key set saves one from a hidden prompt to $XDG_CONFIG_HOME/linear-strict/anthropic-api-key (mode 600), next to the auth login credentials, or set ANTHROPIC_API_KEY in the server's environment, which wins. A key of its own, in a workspace with a spend limit, keeps the judge's cost on its own line. LINEAR_STRICT_JUDGE_MODEL overrides the model (default claude-opus-5-5). Each verdict is one API call of about 2 seconds, roughly 900 input tokens (most of them the cached brief) and 90 output tokens, well under a cent at Opus 5.5's rates (measured 2026-09-27). If the call fails (no credit, an outage, a refusal), the descope is refused with the error and nothing changes. MCP sampling would let the judge run on the client's own model with no key, but Claude Code doesn't offer it to servers (2.1.283 declares elicitation and roots only).

The hooks only guard against an agent cutting corners. An agent with a shell could still write an answer record by hand; a third hook refuses tool calls that name the records' directory, which closes the obvious route.

Blocking writes through other Linear servers

The server can only enforce its rules on writes that go through it. If Linear's official server is also connected, an agent can still edit a ticket there. examples/claude-code-hooks has Claude Code hooks that refuse ticket writes through other Linear servers and run a project's own Linear checks on strict writes. They are optional, and they are the only part of this setup that lives in the client.

OAuth login

linear-strict auth login signs in through the browser and stores a refreshing token, which the server uses when no token is set in its environment. It needs a Linear OAuth application of your own: create one at https://linear.app/settings/api/applications/new with the redirect URI http://localhost:8734/callback, then:

linear-strict auth login --client-id <client id>        # global install
node dist/index.js auth login --client-id <client id>   # from a checkout

The flow uses PKCE, so a client secret is optional. auth status shows whether you're signed in and when the token expires. auth logout revokes the token and deletes it. Credentials live in $XDG_CONFIG_HOME/linear-strict/credentials.json, readable only by you.

Configuration

Variable Default Purpose
LINEAR_API_TOKEN — Personal API key, or a lin_oauth_ token (sent as Bearer); --token on the command line also works
LINEAR_OAUTH_ACCESS_TOKEN — Any OAuth access token, sent as Bearer
LINEAR_STRICT_MAIN_BRANCH main Branch a PR must merge into for Done to count as shipped
LINEAR_STRICT_PRODUCTION_ENV production Environment named in posthog-<env>: flag labels that counts as live
LINEAR_STRICT_RELEASE_NOTE_LABELS release-note,release-note-none,release-note-selfhost The labels release_note writes: yes, none, then the optional self-host one; off turns it off. It takes effect only on a team where the yes and none labels exist
LINEAR_STRICT_RELEASE_NOTE_GATE warn What set_status does when a release-note or release-note-selfhost ticket moves to Merged, Verify or a completed state without a well-formed ## Release note line: warn moves it and returns release_note_missing; block refuses the move. Start on warn while open tickets gain their lines
LINEAR_STRICT_HANDS_OFF_LABELS no-agents Comma-separated labels that make a ticket people-only: every write through this server is refused, reads still work
LINEAR_STRICT_TEAMS unset: every team Comma-separated team keys this server serves. Set, a ticket on any other team can't be read or written, and nothing is filed, searched for overlaps, listed or moved there: for a server that acts for one team whose token sees more
LINEAR_STRICT_SIGN_OFF person Who approves dropping an unticked Done when item: person or judge (Sign-off)
LINEAR_STRICT_JUDGE_MODEL claude-opus-5-5 The model that decides when LINEAR_STRICT_SIGN_OFF=judge
ANTHROPIC_API_KEY — The judge's key, if not saved with auth judge-key set
LINEAR_STRICT_MODEL_API anthropic Where the judge and the team router send their calls: anthropic (the Messages API with the judge key) or openai, any OpenAI-compatible chat/completions endpoint, such as a self-hosted router, Mistral or vLLM. Each call asks for a strict JSON schema, so the endpoint and model must support structured output
LINEAR_STRICT_MODEL_BASE_URL — With openai, the endpoint up to and including its version (https://router.example/v1); with anthropic, a Messages-compatible host in place of https://api.anthropic.com
LINEAR_STRICT_MODEL_API_KEY — The key for LINEAR_STRICT_MODEL_API=openai, sent as a Bearer token
LINEAR_STRICT_MODEL — The model every role uses unless its own variable names one. Required with openai, since the Claude defaults mean nothing there
LINEAR_STRICT_ROUTE_MODEL claude-sonnet-5-5 The model that reads noticed_by when team routing is on
LINEAR_STRICT_CHECKS_TEAMS — Comma-separated team keys whose tickets may carry a ## Checks section of checks with permanent ids. Set with LINEAR_STRICT_CHECKS_RULEBOOK, or neither
LINEAR_STRICT_CHECKS_RULEBOOK — Path to the project's checks rulebook, a JSON file (below). Read once at startup, with its sha256 logged to stderr, so a change takes effect on restart. Setting only one of the two variables, or a rulebook that is missing, unreadable, not JSON or lacks a required field, leaves ## Checks off for every team and logs one line saying why
LINEAR_STRICT_STATE_DIR $XDG_STATE_HOME/linear-strict Where claim records and pending sign-offs are kept
LINEAR_STRICT_CONFIG_DIR $XDG_CONFIG_HOME/linear-strict Where auth login stores credentials
LINEAR_STRICT_SINGLE_INSTANCE 1 0 turns off the check that lets a replaced server exit (below)
LINEAR_STRICT_DEBUG — 1 logs startup detail to stderr

Claim records live on the machine running the server. A Done check from a machine with no claim on record is refused.

Checks rulebook

## Checks rules are data. The server reads them from the rulebook and runs its own interpreter (src/checks.ts); it never loads project code. The file is either the checks block itself or a JSON object with a checks key. Required fields:

Field Type Meaning
section string The exact heading line, e.g. ## Checks
line string, regex, 6 groups A check line: box ( , x or X), id, kind, target, claim, and the optional <!-- … --> body
provenance.pattern string, regex What a provenance comment's body must match
provenance.quote_pattern string, regex, 1 group Each Impact quote in a provenance comment, matched globally, e.g. impact "([^"]+)"
kinds.<kind>.target string The target's shape, quoted in refusals
kinds.<kind>.target_pattern string, regex What a target of that kind must match
coverage.stopwords string[] Words that never need an Impact quote
coverage.min_word_length integer Shorter words never need one either

Patterns are JavaScript regular expressions with no flags. They must run in linear time (no nested quantifiers such as (a+)+, no overlapping alternatives under a repeat): the server runs them on every write, on one thread, so a pattern that backtracks on a long line stalls every tool call. Coverage normalises text by lower-casing it and turning each run of characters that are not letters or digits into one space. An Impact whose first word is none claims only what follows its first colon, or nothing without one, unless the next word is of: none of the visitors can sign in is a claim like any other, as is a first word that only starts with none, such as nonetheless.

On a listed team, a check is graded only by the project's grader, which reads each check's evidence and writes Linear itself, not through this server. So a write that ticks a check, adds one ticked, or rewords one and keeps its tick is refused (unticking is allowed), and set_status to a completed state is refused on any ticket with a ## Checks section: the grader closes it once every check has its evidence. A ticket without the section is gated on Done when as before. A ticket on a listed team holds Done when or ## Checks, never both: a write whose result has both is refused, so adding ## Checks to a ticket with Done when must remove Done when in the same write (a migration, where every dropped item moves into a check or goes to sign-off), and any write to a ticket that already has both must remove Done when. Moving a ticket to Canceled is not a close and is not gated. The section is found by the same reader as every other section (a heading at column 0, outside a code fence; a ### inside it belongs to it, as it does inside Done when), and its heading must be exactly the rulebook's section; a body line that is that heading behind leading whitespace is refused in every section. Impact coverage reads the Impact and every quote without default-ignorable code points (soft hyphen, zero-width space and the rest), and an Impact whose first word is none, unless of follows it, exempts its opening clause; the text after its first colon is still a claim. A Done when item moves into ## Checks with no sign-off only as the whole claim of one new, unticked check of kind walk whose target ends in /visitor (a rulebook with no such kind gets no exemption); any other kind or target is a choice someone approves. A write that adds an id is refused when Linear returns no document history for the ticket, or one with no versions in it, since a retired id could not be ruled out.

src/__tests__/fixtures/checks-conformance.json holds cases with expected readings, for any other implementation of the same rules to test itself against. LINEAR_STRICT_CHECKS_RULEBOOK_TEST=<path> npm run test:unit runs them against another rulebook.

One server per connection

Claude Code's /mcp reconnect starts a new server and leaves the old one running with its pipes open, so the old one never sees its input close. Each server records its pid under LINEAR_STRICT_STATE_DIR/instances, keyed by its parent process and launch settings. When a newer server has replaced it and it has served no tool call for a minute since, the older one exits. A server whose parent exits, or whose input closes, exits too.

Reconciled marker

Each ticket this server has reconciled carries one attachment titled "linear-strict: description reconciled through date". It records the last comment the description accounts for, when that was checked, and a hash of the description at the time, so the next agent to read the ticket knows which comments are new and whether the description was edited elsewhere since. Deleting it does no harm: agents then check the whole thread again, and the next reconcile puts it back. It is written by whoever runs this server, not by Linear.

Tools

Tool What it does
get_issue Whole ticket, plus findings, drift, pull_requests, releases, claim and omitted
description_history Past versions of the description with who made each and a diff; blame names the version behind every current line
list_issues Every matching ticket in one call, paged to the end by the server: identifier, title, state, assignee, delegate and updatedAt, filterable by team, state, open, cycle and project; no description excerpts
claim Take a ticket and snapshot its description; refuses one another agent holds
check_claim Whether the description changed since your claim, with a diff
set_state Patch description sections and/or move the reconciled marker
comment Typed comment: evidence, correction, ask, answer, closed_by
link_slack_thread Link a Slack thread to the ticket (comment sync only with sync: true); the same thread twice finds the first link
attach_file Upload an image from the attach directory (LINEAR_STRICT_ATTACH_DIRS) and attach it to the ticket; the same image twice finds the first
set_status Move to a workflow state; completed states pass the Done gate
set_fields Priority, owner, labels, cycle, project, milestone, parent, dates, relations, linked PRs, watchers and team; never the description or state
create_issue New ticket with validated sections, under a parent or in a project, placed against the closest open tickets
find_overlaps The open tickets closest to a piece of text, before filing: the search create_issue runs
list_teams Teams with their workflow states in board order
list_cycles Cycles, active and next by default; pair a number with list_issues
list_projects, list_initiatives Open projects and initiatives with status, owner and dates
notifications Your inbox as pointers (ticket, type, actor, time), no excerpt text, paginated
get_principal_notifications The same, for the human this identity acts for, on their own credential — needs LINEAR_PRINCIPAL_TOKEN/LINEAR_PRINCIPAL_ID configured
mark_principal_notifications_read Mark the principal's notifications read: ones get_principal_notifications returned, by id or every one an agent caused
mark_notifications_read Mark handled notifications read
whoami The user or app behind the token, which is who claims and _is_me filters mean

The server also returns these rules as MCP instructions on initialize, so an agent learns the workflow when it connects. TOOLS.md has each tool's arguments, and docs/design.md the reasoning behind the rules, their limits, and what is still open.

From a script

A program that files tickets, such as a CI job turning test findings into tickets, can go through the same rules without an agent in between:

import { StrictLinear, OverlapRefusal, linearGql, memoryClaimStore } from 'linear-strict/library';

const strict = new StrictLinear({ gql: linearGql({ token }), claims: memoryClaimStore() });
try {
  await strict.createIssue({ team: 'ENG', title, sections, project_id });
} catch (error) {
  if (!(error instanceof OverlapRefusal)) throw error;
  // error.candidates: the closest open tickets. Comment on the one this repeats,
  // file under one with parent, or retry with new_because and distinct_from.
}

Citation audit

Tickets cite code by path:line and by commit hash, and nothing checks either once the ticket is written. The audit does, offline, in two steps:

linear-strict audit export --team ENG --out eng.jsonl
linear-strict audit check --export eng.jsonl --repo ~/src/app

export writes each ticket's description, every saved version of it, and its comments, open tickets first. That is about three API calls per ticket, spaced one ticket every --pace seconds (20 by default, about a fifth of a key's hourly quota), so a long export doesn't crowd out the key's other users. It saves every 25 tickets. A rerun with the same --out fetches only tickets updated since, and carries on where --max-fetch (500 by default), a rate limit or an interruption stopped the last run.

check reads that file and a git checkout and makes no network calls. Each citation is dated by the description version or comment it first appears in, then compared with the cited branch (--ref, default origin/main; a repo that lands work on a branch such as develop before main passes that) as it was on that date and as it is now:

Verdict Meaning
holds The cited lines read the same today
moved The same lines are elsewhere in the file now; the finding gives the new line
changed The cited lines say something else now; the finding gives both
file_gone The file is no longer on the branch
trivial_line The cited line is a brace or blank, so it can't anchor anything
line_missing_when_cited, not_in_tree_when_cited The branch didn't have that line or file on the day it was cited, so it was cited from somewhere else
ambiguous_path More than one file ends with the cited path

A commit-shaped hex string is on_main, off_main (--main, default origin/main), or not_a_commit_here, which is often a different kind of id: a comment, a request, a deployment. --json prints every finding; --issue narrows to named tickets.

Development

npm test         # typecheck, lint, format and unused-code checks, unit tests, MCP smoke test, and the sign-off routes end to end
npm run build
node scripts/e2e/sign-off.mjs --live-judge  # the same, with the judge on the real API (one call, well under a cent)
npm run test:live  # against a real workspace: creates temporary tickets on LIVE_TEAM and deletes them
npm run eval       # a model works tickets in the fake Linear through the strict tools; graded on final state
npm run format     # Prettier; `npm test` fails on unformatted code

git config core.hooksPath hooks once, after cloning, turns on the tracked pre-commit hook: a non-blocking CodeScene delta check on staged changes when cs is on PATH. It warns and never blocks the commit.

npm run test:live needs LINEAR_API_TOKEN and LIVE_TEAM (a team key). It writes to that workspace. npm run eval needs ANTHROPIC_API_KEY; evals/README.md covers cases, caching and results.

License

MIT. See LICENSE.md; the OAuth login code is from tacticlaunch/mcp-linear and keeps its notice.

About

Unofficial, opinionated Linear MCP server: whole ticket reads, the description as state, rules enforced in the server

Topics

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages