~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Every method as an MCP tool and a CLI command, from its lexicon

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:commands

Every method the server serves is now also an MCP tool on its /mcp endpoint and a command of a pds CLI, made from its lexicon (spec/COMMANDS.md). com.atproto.repo.createRecord is the tool repo_create_record and the command pds repo create-record: the same arguments, as tool arguments or --flags, and the same answer. A method added to the server is a tool and a command at once.

  • One binary, pds: pds serve runs the server; pds <group> <command> calls a running server (PDS_URL, PDS_TOKEN). pds-server is now a library.
  • New crates:
    • pds-lexicon: the lexicons, embedded at build time, as data: arguments, tool and command names, input schemas, annotations;
    • pds-cli;
    • pds, the binary.
  • MCP: revision 2026-07-28, stateless, tools only. Every method with a JSON answer has a tool (getRepo, which answers a CAR file, is CLI-only). Queries are readOnlyHint; deleteRecord, putRecord and applyWrites are destructiveHint, and the other procedures explicitly aren't. A tool passes its token to the method as XRPC does.
  • CLI: string, integer and boolean flags, JSON for everything else, and - reads standard input. It prints one line of JSON; exit status 1 for an error the method answers ({status, error, message}), 2 for a usage error, 3 when the server can't be reached.
  • The account: repo and did may be left out, for the account's DID.

Harness. compare.mjs --commands sends 40% of its requests through the method's tool or command, held to the reference as the rest are, including during crashes and for getRepo's CAR bytes. First it checks:

  • server/discover and tools/list;
  • every tool's schema against the lexicons: properties, types, bounds, required, descriptions, annotations;
  • -32602 for an unknown tool and for a malformed call;
  • the CLI's help at each level, and usage errors.

Every MCP message is validated against MCP's schema.json. conformance.mjs runs MCP's conformance suite against the endpoint again; the 7 excused checks and their reasons are in conformance.yaml.

Planted bugs:

  • the CLI taking - literally instead of reading standard input: seeds 31, 32 and 33 fail at steps 84, 38 and 8;
  • a tool not filling in a left-out repo: they fail at steps 9, 2 and 9;
  • annotations missing on procedures, which the first build had: fails at step 0.

Checked: just gates: all 15 harness runs and 16 crate tests, in 167s. The first full run lost a run to a harness bug, EPIPE writing standard input to a command that had already exited, which only shows under load; it's fixed in the last commit.

🤖 Generated with Claude Code

Approved

This pull makes every method with a JSON answer an MCP tool on /mcp, and every method except subscribeRepos a pds CLI command. Both are built from the lexicons at build time, and the server, the CLI and the lexicon crate are now three crates behind one pds binary. I found nothing that has to change.

  • Spec: spec/COMMANDS.md covers names, argument typing, which methods get a tool or command, answers, exit codes, and auth. It is linked from SLICE.md, AGENTS.md and review.md. The README says what is built, not how. The endpoint's header checks, Origin rejection and notification handling come from spec/mcp through COMMANDS.md's reference to the transport. COMMANDS.md could say so in a line.
  • Harness: The new checks only add strictness. A tool schema is compared with the lexicon on properties, types, bounds, required, descriptions and annotations. Tool and CLI answers are compared with the reference's. Every MCP message is validated against schema.json. The tool path maps an unknown error name to status 0, which makes it differ from the reference, so nothing is loosened. EPIPE on stdin is ignored only when the command exits early. The viaCommand harness drops arguments that are null and arguments the lexicon doesn't list. COMMANDS.md says why null can't be a flag. No check relies on the other.
  • Server: The new crates add no atproto or MCP crates. reqwest is used only by the CLI.
  • Not checked: I could not verify the reasons in conformance.yaml against the conformance suite's source, which is under node_modules. The two groups of excuses (the suite's own diagnostic tools, and the unserved list methods) are plausible given the server's capabilities.
Approved

Since my approval, the only change is in spec/COMMANDS.md. It now says that the endpoint's header, Origin and protocol-version checks come from the transport and mcp/basic/versioning.md. That is the line I suggested last round. It only documents existing behaviour, so my approval stands.

Merged as 5d29450