feat(protocol-builder): add Protocol Builder screen for session-type protocols#1281
Open
chrisbartoloburlo wants to merge 1 commit intomodelcontextprotocol:v2/mainfrom
Open
Conversation
…protocols (modelcontextprotocol#1280) Add a new "Protocol Builder" screen that lets users design session-type interaction protocols against the connected MCP server's tools. The screen exports the protocol as a runtime-checkable DSL string and a Python integration snippet for the `llmsessioncontract` runtime monitor. The screen is split into a dumb screen + three group components: - `ProtocolPaletteSidebar` — tool list, construct buttons, insert-target banner - `ProtocolStepList` — recursive renderer for paired actions, choices, branches, recursion scopes, and rec references - `ProtocolOutputPanel` — syntax-highlighted DSL, FSM state-machine preview, copy-pasteable Python snippet, downloadable .py file Pure logic (DSL serialization, FSM derivation, tree-update helpers) lives in `protocol.ts` so it is unit-tested independently from the UI. Adds nine `--inspector-protocol-*` design tokens (send/receive/recursion text, bg, border + insert-target colors) to App.css, in light and dark schemes. Extends the Paper `code` variant with `whiteSpace: pre-wrap` so the DSL output panel wraps long lines without an inline style. Wires the screen into `InspectorView`'s `ALL_TABS` as "Protocol Builder". All Mantine, no inline styles, no `any`. Coverage on every new file exceeds the 90/85/80/50 per-file gate. Closes modelcontextprotocol#1280 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
|
Could a maintainer add the |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Protocol Builder screen to the v2 web Inspector that lets users design session-type interaction protocols against the connected MCP server's tools, then exports the result as a runtime-checkable DSL string and a Python integration snippet.
This is the v2 port of the v1 Protocol Builder PR #1224, rewritten in Mantine following the v2 dumb-component architecture and per-file 90/85/80/50 coverage gate.
Closes #1280.
What you get
A new Protocol Builder tab in
InspectorView's tab list (visible once a server is connected), with three columns:!Tool.?ToolResultto the sequence. Protocol-construct buttons add!?pairs, internal/external choices, recursion scopes, and loop-back references. An "insert target" button on each branch lets palette clicks add into a specific branch.Selectwhen options exist,TextInputwhen free-form), choice cards with collapsible branches, recursion scopes, rec-ref cards, and a one-click "convert pair → choice" shortcut.llmsessioncontractruntime monitor, and a download button for aprotocol.pyfile.Architecture
clients/web/src/components/screens/ProtocolBuilderScreen/protocol.ts— DSL serialization, FSM derivation, tree-update helpers, types — and is unit-tested independently from the UI.steps,insertTarget,copied) and orchestrates the three groups.ProtocolPaletteSidebar,ProtocolStepList(recursive),ProtocolOutputPanel. Each is a dumb component (props + callbacks).V2 conformance
Box/Group/Stack/Flexfor layout, no rawdiv)--inspector-*CSS custom properties--inspector-protocol-*tokens toApp.css :root(light + dark) for send/receive/recursion text/bg/border surfacescodevariant withwhiteSpace: pre-wrapso the DSL output panel wraps long lines without an inline styleanyrenderWithMantine+@testing-library/user-event, every new file passes the per-file gateTest plan
npm run validatepasses (format, lint, build, test:coverage with the per-file 90/85/80/50 gate)npm run test— 707 tests pass across 72 filesprotocol.ts— 97.2% statements / 100% functions / 97.9% linesProtocolBuilderScreen.tsx— 100% across the boardProtocolPaletteSidebar.tsx— 100% across the boardProtocolStepList.tsx— 92% statements / 83.7% functions / 95.5% linesProtocolOutputPanel.tsx— 98.7% statements / 100% functions / 98.5% linesBackground
Session types are a formal model for describing interaction protocols between two parties — exactly the shape of an LLM ↔ MCP-server conversation. The
llmsessioncontractruntime monitor catches protocol violations the moment they happen.The Python runtime: llmsessioncontract on PyPI · llmcontract.dev · GitHub.