From c6443db8d381541553508940905c14abf7a07f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=B1=D0=BE=D1=82?= Date: Wed, 18 Nov 2026 18:08:35 +0100 Subject: [PATCH] feat: every MCP server we build has two doors, search and execute (0.33.0) The operator's rule of 2026-11-18: an MCP server we build or run lists only search and execute; at most three measured exceptions; old tool names alias for one release. New agent-interop reference mcp-two-doors.md, Rule one, pointers in agent-harness tools.md, mcp.md and agent-surface.md, regression test. Co-Authored-By: Claude Opus 5.5 (1M context) --- .claude-plugin/marketplace.json | 2 +- CHANGELOG.md | 28 +++ SKILL-CARD.md | 2 +- docs/HANDOFF.md | 17 ++ package.json | 2 +- .../agent-stack/.claude-plugin/plugin.json | 2 +- .../skills/agent-harness/references/tools.md | 5 + .../agent-stack/skills/agent-interop/SKILL.md | 11 ++ .../agent-interop/references/agent-surface.md | 15 +- .../agent-interop/references/mcp-two-doors.md | 168 ++++++++++++++++++ .../skills/agent-interop/references/mcp.md | 2 +- .../ai-native-agent-surface.py | 6 +- test/audit_regressions/mcp-two-doors.py | 92 ++++++++++ 13 files changed, 337 insertions(+), 15 deletions(-) create mode 100644 plugins/agent-stack/skills/agent-interop/references/mcp-two-doors.md create mode 100644 test/audit_regressions/mcp-two-doors.py diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 0012f8a..c5011f0 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -12,7 +12,7 @@ "displayName": "Agent Stack", "source": "./plugins/agent-stack", "description": "Four skills: agent-orchestrator — tool-calling loops, pipelines with checkpoints, provider routing with fallback, memory architecture, plus the wallet side of reselling LLM access; agent-evals — run/trace/thread evals, LLM judges, and fixtures grown from production; agent-interop — MCP servers and clients, A2A agent cards, the MCP Registry, and gateways; agent-harness — system prompts, tool shaping, workflow-vs-agent, and auditing an agent system.", - "version": "0.32.1", + "version": "0.33.0", "author": { "name": "ssheleg", "url": "https://x.com/sshlg93" diff --git a/CHANGELOG.md b/CHANGELOG.md index 374a269..25be829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +## v0.33.0: every MCP server we build has two doors, `search` and `execute` + +The operator's rule of 2026-11-18 (fabric-agents-database session b590fc74): an MCP server we +build or run lists only `search` and `execute`, best practice for every MCP design, data rooms +first. + +- **agent-interop `references/mcp-two-doors.md`** (new): the rule and its scope; why (context, + selection, one gated path, a stable surface); the `search` catalogue (operation name, + `purpose`, `inputSchema`, `effect`, `gate`, `example`, deprecation; paged, ranked, filtered + by the caller's scope); `execute` (one path through the interface's gate, idempotency key + for effects, typed refusals `unknown-operation`, `invalid-arguments`, + `idempotency-required`, `idempotency-conflict`, AN-7 gates; not a shell or code mode); at + most three direct tools, each with a recorded measurement, protocol-required tools such as + the Fabric kit's `fabric.job.get` counted among them; moving an existing server (inventory, + both doors, one release of aliases for the old names, callers moved); the contract + snapshot (the whole catalogue); conformance tests; traps. +- **agent-interop SKILL.md** gains "Rule one" with the rule in short, a dispatch row and the + index row. +- **agent-surface.md**: AN-3's capability owes an operation in the catalogue; the MCP snapshot + of a two-door server includes the whole `search` catalogue. Its `tools.md` citations moved + by five lines with the new paragraph there (anchors in + `test/audit_regressions/ai-native-agent-surface.py` updated). +- **agent-harness `references/tools.md`**: "Fewer tools than you think" points at the two + doors; its advice now applies to each operation. +- **mcp.md**: the tools paragraph points at the rule (same line, no citation moved). +- **`test/audit_regressions/mcp-two-doors.py`** holds the contract parts, the pointers and + the no-em-dash rule. + ## v0.32.1: the host's model map, a pinned interop revision, fresh source dates Family audit of 2026-11-11 (findings A1, A2, A4, A5; A3 filed as board row B-162). diff --git a/SKILL-CARD.md b/SKILL-CARD.md index 2307666..6a27d3c 100644 --- a/SKILL-CARD.md +++ b/SKILL-CARD.md @@ -5,7 +5,7 @@ | Field | Value | |---|---| | Pack | `agent-stack` | -| Version | `0.32.1` | +| Version | `0.33.0` | | Skills | `agent-orchestrator`, `agent-evals`, `agent-interop`, `agent-harness` | | License | MIT | | Source | https://github.com/ssheleg/agent-stack | diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 70c54b5..5954df0 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -1,3 +1,20 @@ +## v0.33.0: two doors for every MCP server we build (2026-11-18) + +- **Objective.** The operator's order of 2026-11-18 in the sshlg-skills session: «чтобы везде, + когда мы строим MCP, всегда было только два endpoints ... Search и Execute ... глобально для + всех»; make it the family's doctrine and tell every MCP owner on the board. +- **Done.** `agent-interop/references/mcp-two-doors.md`, Rule one in agent-interop, pointers in + agent-harness `tools.md`, `mcp.md` and `agent-surface.md` (AN-3 and the snapshot), + `test/audit_regressions/mcp-two-doors.py`, version 0.33.0. +- **Decisions.** The cap of three measured exceptions and one release of aliases follow the + operator's rule as recorded in the host's global instructions (2026-11-18). Tools a protocol + requires by name (Fabric's `fabric.job.get`, `fabric.job.cancel`) count among the three until + the protocol folds them into `execute`: the agents base raised the same case + (intake in-20261118-6b4cd4), and counting them keeps the cap honest. +- **Checks run.** `npm test` (all green, the new regression included). +- **Next task.** After release: the sshlg-skills pin bump; the board announcement to every + project that serves MCP (sent from sshlg-skills). + ## v0.32.1: family audit fixes (2026-11-11) - **Objective.** Findings A1 to A5 of the family audit ordered in the sshlg-skills session on diff --git a/package.json b/package.json index 929c6f3..46a0a3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ssheleg/agent-stack", - "version": "0.32.1", + "version": "0.33.0", "scripts": { "test": "python3 test/validate.py && python3 test/family_gate.py && python3 test/family_gate.py --self-test && python3 test/plant_guard_test.py && python3 test/member_owner_gates_test.py && python3 test/reap_own_test.py && node test/installer_test.js && npm run test:audit", "test:audit": "for t in test/audit_regressions/*.py; do python3 \"$t\" || exit 1; done" diff --git a/plugins/agent-stack/.claude-plugin/plugin.json b/plugins/agent-stack/.claude-plugin/plugin.json index 5e2ddf7..71bec64 100644 --- a/plugins/agent-stack/.claude-plugin/plugin.json +++ b/plugins/agent-stack/.claude-plugin/plugin.json @@ -3,7 +3,7 @@ "name": "agent-stack", "displayName": "Agent Stack", "description": "Four skills: agent-orchestrator — tool-calling loops, pipelines with checkpoints, provider routing with fallback, memory architecture, plus the wallet side of reselling LLM access; agent-evals — run/trace/thread evals, LLM judges, and fixtures grown from production; agent-interop — MCP servers and clients, A2A agent cards, the MCP Registry, and gateways; agent-harness — system prompts, tool shaping, workflow-vs-agent, and auditing an agent system.", - "version": "0.32.1", + "version": "0.33.0", "author": { "name": "ssheleg", "url": "https://x.com/sshlg93" diff --git a/plugins/agent-stack/skills/agent-harness/references/tools.md b/plugins/agent-stack/skills/agent-harness/references/tools.md index 4fa905f..fad7053 100644 --- a/plugins/agent-stack/skills/agent-harness/references/tools.md +++ b/plugins/agent-stack/skills/agent-harness/references/tools.md @@ -36,6 +36,11 @@ two round trips. tool applies to a case, the model cannot either.* Ambiguity between two tools is a design defect, not a prompting problem. +**An MCP server we build lists two tools: `search` and `execute`.** The functions become +operations in a catalogue `search` returns on demand; `execute` runs one by name through one +gated path. At most three measured exceptions. Everything in this file still applies, to each +operation's name, `purpose`, schema and errors: `agent-interop/references/mcp-two-doors.md`. + ## Namespacing Group related tools under a common prefix — `asana_search`, `asana_create_task`, diff --git a/plugins/agent-stack/skills/agent-interop/SKILL.md b/plugins/agent-stack/skills/agent-interop/SKILL.md index 2a92042..9ad0ef4 100644 --- a/plugins/agent-stack/skills/agent-interop/SKILL.md +++ b/plugins/agent-stack/skills/agent-interop/SKILL.md @@ -54,6 +54,15 @@ because nothing on the page says otherwise. for and what changed; they are not a substitute for the document. Read the pinned revision, then check whether a newer one exists. Every entry in the link map below is fetchable. +## Rule one: every MCP server we build has two doors, `search` and `execute` + +`tools/list` of a server the estate builds or runs answers `search` (find operations by +words, each with its schema, effect and gate) and `execute` (run one by name through the same +gate, idempotency and audit as the interface). Nothing else, unless a measured case needs a +call to skip `search`: at most three such tools, each recorded with its measurement. Old tool +names keep working for one release while callers move. Data rooms first. Contract, migration +and tests: `references/mcp-two-doors.md`. + --- ## Which protocol answers which question @@ -61,6 +70,7 @@ then check whether a newer one exists. Every entry in the link map below is fetc | The question you actually have | The answer | Where | |---|---|---| | I want to give a model a capability against a live system | **MCP server** | `references/mcp.md` | +| What tools does my server list? | **`search` and `execute`** | `references/mcp-two-doors.md` | | My server is written and the client cannot connect to it | mounting and transports | `references/mcp-ship.md` | | I want my application to consume other people's tool servers | **MCP client** | `references/mcp.md`, then `references/mcp-scale.md` | | I have more servers than fit in a context window | client scaling patterns | `references/mcp-scale.md` | @@ -111,6 +121,7 @@ an index; the trigger lives in the file, so the two cannot drift apart. | File | Read it when | |---|---| | [`references/mcp.md`](references/mcp.md) | you are **building or calling an MCP server** — the layers, per-request `_meta`, `server/discover`, the three server primitives and the one surviving client primitive, notifications, caching, transports, and the full deprecation register | +| [`references/mcp-two-doors.md`](references/mcp-two-doors.md) | you **build, adapt or review a server we run**: the two doors `search` and `execute`, the operation catalogue, the gated path, at most three measured exceptions, moving an existing server, the snapshot and conformance tests | | [`references/mcp-ship.md`](references/mcp-ship.md) | the server is written and **cannot be reached** — mounting inside an existing web app, transport-level auth, client config, and the 404 that is really a double path | | [`references/mcp-scale.md`](references/mcp-scale.md) | the host has **more servers and tools than context** — progressive discovery, programmatic tool calling, cache interaction, and the security surface each one opens | | [`references/a2a.md`](references/a2a.md) | the other side is **another agent, not a tool** — agent cards and discovery, the task lifecycle and its terminal states, three protocol bindings, streaming versus push | diff --git a/plugins/agent-stack/skills/agent-interop/references/agent-surface.md b/plugins/agent-stack/skills/agent-interop/references/agent-surface.md index 1660460..043924f 100644 --- a/plugins/agent-stack/skills/agent-interop/references/agent-surface.md +++ b/plugins/agent-stack/skills/agent-interop/references/agent-surface.md @@ -69,7 +69,8 @@ surface, or each extra one is marked `internal` with a reason. definition: `internal: `. Accepted reasons: a sync transport (offline replication), a render-only endpoint (thumbnails, layout data), a session-plumbing call (token refresh). - [ ] A marker whose reason is a user action is not accepted: that action is a capability and - owes a tool. + owes an operation (on a server we build, an operation in the `search` catalogue behind the + two doors, `mcp-two-doors.md`). ## The contract source, its snapshot, and the diff that classifies a change @@ -81,7 +82,7 @@ the source or is generated from it. | Surface | Snapshot | |---|---| -| MCP | the `tools/list` result (plus `resources/templates/list` and `prompts/list` where used) from a local stdio build, sorted by name, caching fields (`ttlMs`, `cacheScope`) removed | +| MCP | the `tools/list` result (plus `resources/templates/list` and `prompts/list` where used) from a local stdio build, sorted by name, caching fields (`ttlMs`, `cacheScope`) removed; for a two-door server also the whole `search` catalogue, sorted by operation name (`mcp-two-doors.md`) | | HTTP | the served OpenAPI document | | CLI | ` --help --json` for every command | @@ -94,7 +95,7 @@ the source or is generated from it. | `breaking` | a tool removed or renamed; input narrowed (a new required field, an enum value removed, a type tightened); an output field removed or its meaning changed; an effect class widened; an auth scope or effect ceiling changed; an error code renamed | a new contract version and the deprecation path in AN-8; risk and stage gates are task-pipeline's (`references/agent-surface.md`) | A description or an agent-facing error body that changed is a contract change too: agents read -it (`tools.md:48-76`). The diff names it `additive` unless it changes what a call means. +it (`tools.md:53-81`). The diff names it `additive` unless it changes what a call means. ## AN-7: the gate protocol @@ -140,14 +141,14 @@ continues. Gates and their evidence come from the capability row (AN-4). - [ ] `human_steps[].url` opens the exact step, not a dashboard; the text a person reads goes through the product's copywriting route. - [ ] `digest` binds the approval to the exact arguments (`gateway.md:240-249`); changed - arguments need a new approval (`tools.md:130-133`). + arguments need a new approval (`tools.md:135-138`). - [ ] The agent continues by polling the named read or receiving the `Emits` event, then repeats the original call with the same idempotency key; the server consumes the approval once. - [ ] **How the server knows the approval is genuine:** it reads its own approval record, written by the authenticated approver through the human surface, bound to digest, principal, callee and expiry. Nothing the agent sends proves an approval. `confirm: true` is a syntax - guard, never an approval (`tools.md:127-133`). + guard, never an approval (`tools.md:132-138`). - [ ] On an `internal` product, `approval` exists only with a recorded operator decision (AN-4); otherwise the delegated agent acts. @@ -163,7 +164,7 @@ continues. Gates and their evidence come from the capability row (AN-4). (`Roles` on the capability row); the server checks the principal's role on every call, not only at consent. - [ ] **Effect classes declared** in the contract (annotations and `_meta`), using the effect - vocabulary of `gateway.md:191`; annotations alone decide nothing (`tools.md:135-153`). + vocabulary of `gateway.md:191`; annotations alone decide nothing (`tools.md:140-158`). - [ ] **Idempotency key on every write.** A repeat with the same key returns the first result and causes no second effect; a repeat with the same key and other arguments is refused. - [ ] **Dry-run or sandbox** for every write: `dry_run: true` returns the planned effect @@ -174,7 +175,7 @@ continues. Gates and their evidence come from the capability row (AN-4). pseudonymised, the chain's shape is kept, and the person's agent grants are revoked. - [ ] **Untrusted content marked.** Text written by third parties sits in fields the tool description names as untrusted (for example `untrusted_text`); the lethal trifecta is a - session property (`tools.md:155-178`). + session property (`tools.md:160-183`). - [ ] **Limits name their window.** Rate and spend refusals say which window ran out (`gateway.md:231-238`). - [ ] **A tool is never renamed.** Deprecate it: mark it in the description and `_meta` with a diff --git a/plugins/agent-stack/skills/agent-interop/references/mcp-two-doors.md b/plugins/agent-stack/skills/agent-interop/references/mcp-two-doors.md new file mode 100644 index 0000000..d153eaf --- /dev/null +++ b/plugins/agent-stack/skills/agent-interop/references/mcp-two-doors.md @@ -0,0 +1,168 @@ +# Two doors: every MCP server we build exposes `search` and `execute` + +**Load this when:** you build, adapt or review an MCP server the estate builds or runs (an +agent's server, a product's agent surface, a data room, a gateway's own tools); or a +server's `tools/list` shows more than two tools. + +**Spec pinned:** MCP revision `2026-07-28` (`tools/list`, `tools/call`, `outputSchema`, `isError`); the operator's rule of 2026-11-18 (fabric-agents-database session b590fc74: «два входа только поиски и экзекьюция ... best practice всегда для проектирования mcp ... особенно на датарумы») · read 2026-11-18 + +## Contents + +- The rule +- Why two doors +- `search`: the catalogue of operations +- `execute`: one gated path for every operation +- Exceptions: at most three direct tools, each measured +- Moving an existing server to two doors +- The contract snapshot and its diff +- Conformance tests +- Traps + +## The rule + +**`tools/list` of a server we build or run answers exactly two tools: `search` and +`execute`.** Every function the server offers is an *operation*: `search` finds operations +by words and returns each with its schema; `execute` runs one by name with the same gate, +idempotency and audit the interface uses. No other tool, unless a measured case shows a call +that must skip `search` (below, at most three). Data rooms move first. + +Scope: servers the estate builds or runs, whatever their transport (stdio, Streamable HTTP, +behind a gateway). A third-party server we only consume is not ours to reshape; its scale is +the host's problem (`mcp-scale.md`). A Fabric service's descriptor, auth and job contract are +the Fabric adapter's (`fabric-agent-adapter:building-fabric-services`); this file owns the +tool shape they serve. + +## Why two doors + +- **Context.** A host passes every tool definition to the model on every turn. Forty + definitions cost thousands of tokens before the first call; two cost a few hundred, and the + catalogue is read only when needed, only the operations that match. +- **Selection.** Choosing among many similar tools degrades with the size of the set + (`agent-harness/references/tools.md`, "Fewer tools than you think"). Choosing between + "find" and "do" does not. +- **One path.** Every operation crosses the same gate, validation, idempotency check, audit + row and spend check in `execute`. Forty tools are forty places to forget one. +- **Stable surface.** Adding an operation changes the catalogue, not `tools/list`: clients + that cache tool lists, prompts and evals naming the two tools keep working. + +## `search`: the catalogue of operations + +Read-only (`annotations.readOnlyHint: true`). Input: + +```jsonc +{ "query": "string, optional: words of the task, any language; empty lists everything", + "names": ["optional: exact operation names, to fetch their schemas"], + "limit": 10, // default 10, at most 50 + "cursor": "optional, from nextCursor" } +``` + +Output (`structuredContent`, with an `outputSchema`): + +```jsonc +{ "operations": [ { + "name": "invoice.refund", // stable, namespaced, never renamed (AN-8) + "purpose": "When and why to use it, and the neighbour it is confused with", + "inputSchema": { /* JSON Schema, the same one execute validates */ }, + "outputSchema": { /* optional */ }, + "effect": "read | write | money | delete | publish", + "gate": "none | relayed | human", // AN-7; the capability row's gate + "idempotent": true, + "example": { "arguments": { /* valid against inputSchema */ } }, + "deprecated": { "replacedBy": "name", "sunset": "YYYY-MM-DD" } // only when deprecated + } ], + "total": 37, "nextCursor": "…", "degraded": [] } +``` + +- Match on the operation's name, purpose and argument names, in Russian and English word + forms where the server's users write both. Rank, then page; never return the whole + catalogue unasked. +- Filter by the caller's scope: an operation the credential cannot run is not listed (it + answers `unknown-operation` from `execute` too), so the catalogue never advertises what the + caller is refused. +- `purpose` is a tool description and follows `agent-harness/references/tools.md` ("The + description is the product"): when, why, cost, and the confusable neighbour. + +## `execute`: one gated path for every operation + +Input: + +```jsonc +{ "operation": "invoice.refund", + "arguments": { /* validated against the operation's inputSchema */ }, + "idempotencyKey": "required for effect write, money, delete, publish", + "dryRun": false } // where the operation supports it (AN-8) +``` + +- Answers the operation's own result as `structuredContent`; a long operation answers a task + (`io.modelcontextprotocol/tasks` where negotiated) or a job handle (`mcp.md`, Tasks). + Polling and cancelling a job are operations too (`job.get`, `job.cancel`). +- Typed refusals (`isError: true`), never prose alone: + `unknown-operation` (with up to three nearest names and "call search first"), + `invalid-arguments` (with the JSON Schema path that failed), `idempotency-required`, + `idempotency-conflict`, and the gate refusal of AN-7 (`agent-surface.md`, "AN-7: the gate + protocol") with `human_steps`, or MCP `input_required` for a value the caller can supply. +- The gate, limits, audit row and spend check are the same functions the interface's button + calls (AN-3). `execute` never runs anything that is not a catalogued operation: it is not a + shell, an `eval`, or code mode (`mcp-scale.md`, "Programmatic tool calling"). +- The `execute` description says: "Run an operation that `search` returned. Never guess a + name; call `search` first unless the name came from it in this conversation." + +## Exceptions: at most three direct tools, each measured + +A direct tool beside the two doors is allowed only when a measured case shows a call that +must skip `search`, and never more than three. Record each in the server's contract source +beside the tool: its name, the call that cannot afford the round trip, the measurement +(calls per session, tokens or latency saved, the date and how it was measured), and who +decided. No measurement, no exception: "it is used a lot" is a reason to measure, not one. + +Tools that a protocol outside the server requires by name (for example the Fabric kit's +`fabric.job.get` and `fabric.job.cancel` under `fabric-interop/0.1`) count against the three, +with that contract recorded as the reason, until the contract lets them fold into `execute`. + +## Moving an existing server to two doors + +1. **Inventory.** Every tool becomes an operation with the same name, schema and gate; the + inventory is the catalogue. Add the interface's actions missing from it (AN-3). +2. **Serve both doors** from that catalogue; `tools/list` answers only `search`, `execute` + and recorded exceptions. +3. **One release of aliases.** A `tools/call` by an old tool name still runs its operation + through `execute`'s path and marks the result deprecated (`_meta` and a `deprecated` + field naming `execute` and the sunset date). The next release removes the aliases. +4. **Move the callers.** Grep skills, prompts, docs, evals and other agents' code for the old + tool names; change them in the same release or file a row with each owner. +5. **Snapshot and tests** below; the change is `breaking` for `tools/list` and `none` for the + operations when names and schemas are kept. + +## The contract snapshot and its diff + +For a two-door server the contract snapshot (`agent-surface.md`, "The contract source, its +snapshot, and the diff that classifies a change") is `tools/list` plus the whole `search` +catalogue (every page, empty query, a credential holding every scope), sorted by operation +name. The diff classes apply to operations exactly as they applied to tools: an operation +removed or renamed is `breaking`, a new one is `additive`, and a changed `purpose` is a +contract change. + +## Conformance tests + +In the server's own suite, against a real client over the shipped transport: + +- [ ] `tools/list` names equal `{search, execute}` plus the recorded exceptions, at most three. +- [ ] Every catalogued operation has `purpose`, `inputSchema`, `effect`, `gate` and an + `example` whose arguments validate; each example runs through `execute` in a sandbox. +- [ ] `search` pages (`limit`, `nextCursor`) and hides operations outside the caller's scope. +- [ ] `execute` answers `unknown-operation`, `invalid-arguments` and `idempotency-required` + typed; a gated operation refuses with the same gate the interface shows. +- [ ] In the migration release, every old tool name still runs and is marked deprecated. + +## Traps + +- **The catalogue as one blob.** A `search` that returns all operations with full schemas on + every call moves the context cost instead of removing it. Page and rank. +- **`execute` as an escape hatch.** Arguments it does not validate, or an operation that runs + arbitrary code, turn the second door into an unguarded one. +- **A gate only in the interface.** A refusal the button applies and `execute` skips is a + bypass, not parity. +- **Renaming while migrating.** Keep names and schemas; change the shape of the surface and + the vocabulary in two different releases. +- **Exceptions that grow.** A fourth "just this one" direct tool, or one without its + measurement, is the drift the rule exists to stop. diff --git a/plugins/agent-stack/skills/agent-interop/references/mcp.md b/plugins/agent-stack/skills/agent-interop/references/mcp.md index 6d9e829..64e2593 100644 --- a/plugins/agent-stack/skills/agent-interop/references/mcp.md +++ b/plugins/agent-stack/skills/agent-interop/references/mcp.md @@ -103,7 +103,7 @@ is supposed to decide about is a **tool**. **Tools.** `name` (unique within the server; prefer `calculator_arithmetic` over `calculate`), `title` (human-readable), `description`, `inputSchema` (JSON Schema), and an optional **`outputSchema`** — which is worth providing, because it is what lets a host -generate typed stubs for programmatic calling (`mcp-scale.md`). +generate typed stubs for programmatic calling (`mcp-scale.md`). A server we build lists only two tools, `search` and `execute` (`mcp-two-doors.md`). **Tool errors do not arrive as transport failures.** A failed tool returns a *successful* JSON-RPC response carrying `isError: true`. Client code that only catches transport diff --git a/test/audit_regressions/ai-native-agent-surface.py b/test/audit_regressions/ai-native-agent-surface.py index e27082a..7f8d87e 100644 --- a/test/audit_regressions/ai-native-agent-surface.py +++ b/test/audit_regressions/ai-native-agent-surface.py @@ -109,9 +109,9 @@ def t_citations_resolve(): ("agent-interop/references/mcp.md", 108, 110, "isError"), ("agent-interop/references/mcp.md", 166, 191, "subscriptions/listen"), ("agent-interop/references/mcp.md", 216, 249, "Tasks"), - ("agent-harness/references/tools.md", 127, 133, "confirm: true"), - ("agent-harness/references/tools.md", 135, 153, "readOnlyHint"), - ("agent-harness/references/tools.md", 155, 178, "lethal trifecta"), + ("agent-harness/references/tools.md", 132, 138, "confirm: true"), + ("agent-harness/references/tools.md", 140, 158, "readOnlyHint"), + ("agent-harness/references/tools.md", 160, 183, "lethal trifecta"), ("agent-orchestrator/references/governance.md", 115, 131, "The audit row"), ) diff --git a/test/audit_regressions/mcp-two-doors.py b/test/audit_regressions/mcp-two-doors.py new file mode 100644 index 0000000..5ce05a5 --- /dev/null +++ b/test/audit_regressions/mcp-two-doors.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +"""The two-door rule for MCP servers we build (operator, 2026-11-18). + +`agent-interop/references/mcp-two-doors.md` owns the rule: `tools/list` of a server the +estate builds or runs answers `search` and `execute`, at most three measured exceptions, +old tool names alias for one release. What this file holds the pack to: + + * the reference exists, carries its load line and pin, and states the contract parts + (the two tool names, the catalogue fields, the typed refusals, the exception cap, the + migration release, the snapshot, the conformance list); + * agent-interop's body states the rule and indexes the reference; agent-harness's tool + advice and the agent-surface snapshot row point at it, so no other file teaches a + many-tool server as the default; + * no em dash in the new prose. + +Stdlib only. +""" +import os +import re +import sys + +sys.dont_write_bytecode = True + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(os.path.dirname(HERE)) +SKILLS = os.path.join(ROOT, "plugins", "agent-stack", "skills") +DOORS = os.path.join(SKILLS, "agent-interop", "references", "mcp-two-doors.md") +INTEROP = os.path.join(SKILLS, "agent-interop", "SKILL.md") +SURFACE = os.path.join(SKILLS, "agent-interop", "references", "agent-surface.md") +MCP = os.path.join(SKILLS, "agent-interop", "references", "mcp.md") +TOOLS = os.path.join(SKILLS, "agent-harness", "references", "tools.md") +EM_DASH = chr(0x2014) + +failures = [] + + +def case(name, fn): + try: + fn() + print(f" ok {name}") + except AssertionError as e: + failures.append(f"{name}: {e}") + print(f"FAIL {name}: {e}") + + +def read(path): + with open(path, encoding="utf-8") as fh: + return fh.read() + + +def t_reference_states_the_contract(): + text = read(DOORS) + assert text.startswith("# Two doors"), "title" + assert "**Load this when:**" in text, "no load line" + assert re.search(r"^\*\*Spec pinned:\*\*.+· read \d{4}-\d{2}-\d{2}\s*$", text, re.M), "no pin" + for part in ("`search`", "`execute`", '"inputSchema"', '"gate"', '"effect"', '"example"', + "`unknown-operation`", "`invalid-arguments`", "`idempotency-required`", + "at most three", "One release of aliases", "## The contract snapshot", + "## Conformance tests", "fabric.job.get"): + assert part in text, f"missing {part}" + + +def t_interop_states_and_indexes_the_rule(): + text = read(INTEROP) + assert "## Rule one: every MCP server we build has two doors" in text, "no rule one" + assert "[`references/mcp-two-doors.md`](references/mcp-two-doors.md)" in text, "not indexed" + assert "| What tools does my server list? |" in text, "no dispatch row" + + +def t_neighbours_point_at_the_rule(): + assert "mcp-two-doors.md" in read(TOOLS), "agent-harness tools.md does not point at it" + assert "mcp-two-doors.md" in read(MCP), "mcp.md does not point at it" + surface = read(SURFACE) + assert "the whole `search` catalogue" in surface, "snapshot row lacks the catalogue" + assert "owes a tool." not in surface, "AN-3 still says a capability owes a tool" + + +def t_no_em_dash_in_new_prose(): + assert EM_DASH not in read(DOORS), "em dash in mcp-two-doors.md" + block = read(INTEROP).split("## Rule one:", 1)[1].split("\n---\n", 1)[0] + assert EM_DASH not in block, "em dash in rule one" + + +case("reference states the contract", t_reference_states_the_contract) +case("agent-interop states and indexes the rule", t_interop_states_and_indexes_the_rule) +case("neighbours point at the rule", t_neighbours_point_at_the_rule) +case("no em dash in the new prose", t_no_em_dash_in_new_prose) + +if failures: + print(f"\n{len(failures)} failure(s)") + sys.exit(1) +print("\nmcp-two-doors: all cases pass")