Facet
DeutschInstall
Work with AI agents

Give your AI assistant your product rules over MCP, with FACET

Run FACET's MCP serverMCP is the standard way AI assistants call outside tools. FACET runs an MCP server from your project with facet mcp, so an assistant can look up records and the code anchored to them.In the glossary from your project, so your assistant can look up the rule behind a file, check what it answers for one file, and register it in any assistant that starts MCP servers from a command.

  • 5 min read
  • 4 steps
  • MCPClaude Code

You ask your AI assistant to tidy up the discount code. It suggests, again, to compare the expiry date with local midnight “to match what customers expect”. That is the exact bug the team fixed in August: codes expired a day early for customers west of UTC. You explain it, the assistant agrees, and next session it suggests the same change, because the rule is nowhere it can look.

FACET keeps a short, checkable description of each feature and its rules, called a FACET recordA FACET record is a short, checkable description of one feature, kept as a YAML file next to the code. It states why the feature exists, the behaviour it promises as scenarios, and the tests that check it.In the glossary, next to your code. By the end of this guide your assistant can ask the repository which rule governs a file and read that rule, through one MCP server that FACET runs from your project (MCP is the standard way AI assistants call outside tools): facet mcp. It works with any assistant that can start an MCP server from a command, and it serves the records your team already keeps.

The commands below use a small example shop written in TypeScript; FACET has to be set up as in One answer instead of three, with at least one record and its AnchorAn anchor is a comment in the source code, starting with @facet:, that names the record the code belongs to. FACET reads these comments to know where each feature is implemented.In the glossary. In your own project, use a file and a record you already have.

Step 1See what the server can answer

facet mcp speaks the Model Context Protocol on standard input and output. An assistant starts it as a child process and calls its tools. Before you connect a client, ask the server the two questions an assistant should ask before it edits a file: which feature does this file implement, and what does the record promise?

Save these four lines as mcp-check.jsonl in the project root. They open a session, then call the tools anchor_resolve and read_facet:

json
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"terminal","version":"1"}}}{"jsonrpc":"2.0","method":"notifications/initialized"}{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"anchor_resolve","arguments":{"path":"src/checkout/discount.ts"}}}{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"read_facet","arguments":{"id":"checkout/discounts/redeem-code","sections":["contract.scenarios"]}}}

Send them to the server and print the answers. The command needs jq:

sh
  • (cat mcp-check.jsonl; sleep 2) | npx facet mcp | jq -r '.result.content[0].text // empty | fromjson | .features // .text'
Terminal output: the server answers that src/checkout/discount.ts implements checkout/discounts/redeem-code, then prints that record's four scenarios, among them last-day-ends-in-utc: a code whose last day is today is still applied at 23:30 UTC, in any time zone.Terminal output: the server answers that src/checkout/discount.ts implements checkout/discounts/redeem-code, then prints that record's four scenarios, among them last-day-ends-in-utc: a code whose last day is today is still applied at 23:30 UTC, in any time zone.
The server names the feature a file implements and returns its ScenarioA scenario is one behaviour a feature promises, written in a record as Given/When/Then steps. Each scenario has an id that tests and other records can refer to.Read more here.

The second scenario, last-day-ends-in-utc, is the rule the assistant kept proposing to break. The two answers can arrive in either order. sleep 2 keeps the input open until the server has answered; without it the server stops at the end of the input before replying.

Step 2Register the server in your assistant

Every MCP client needs the same three facts: the server runs over stdio, the command is npx, and the arguments are facet mcp. Start it in the project root, so npx finds the facet-framework dependency and the server finds your records.

In Claude Code, run this in the project root:

sh
  • claude mcp add facet -- npx facet mcp

For a client you configure with JSON, the entry has this shape. Claude Code writes an entry of the same shape to .mcp.json when you add --scope project:

json
{  "mcpServers": {    "facet": {      "type": "stdio",      "command": "npx",      "args": ["facet", "mcp"]    }  }}

Use your client's own documentation for where that file lives. If the client starts servers outside the project directory, npx cannot find the dependency there. Give the full path instead: "command": "/path/to/project/node_modules/.bin/facet" and "args": ["mcp", "--root", "/path/to/project"].

Step 3Check that the client reaches the server

Ask the client whether the server starts. In Claude Code:

sh
  • claude mcp list
Terminal output: claude mcp add registers the stdio server facet with the command npx facet mcp in the local config; claude mcp list then shows facet: npx facet mcp, Connected.Terminal output: claude mcp add registers the stdio server facet with the command npx facet mcp in the local config; claude mcp list then shows facet: npx facet mcp, Connected.
The client starts the server from the project and connects.

Connected means the client started npx facet mcp in your project and completed the handshake. The assistant now has 15 FACET tools. The ones it needs for this problem are anchor_resolve (which feature does this file implement), feature_find (search records by words), feature_get (a whole record) and read_facet (one section of a large record).

Step 4If the server says something else

  • facet: server is closing: EOF, and nothing else: the input ended before the server answered. Keep sleep 2 in the command.
  • jq: error … (while parsing 'unknown feature id …'): the record id in mcp-check.jsonl does not exist. The message names the path where FACET looked. Copy the id: from the record.
  • [] for the file: no @facet: anchor in that file names a record. Check the path, relative to the project root, or add the anchor as in One answer instead of three.
  • The client shows the server as failed, or npm asks to install facet: the client started npx outside the project. Start the client from the project root, or use the full path and --root as in step 2.

For what changes when agents build features against written rules, read The agent built it. Who checked it?

Sources