Docs / Guides
MCP server for Proto designs (Labs)
OpenFini can expose your Proto Studio designs to coding agents such as Claude Code, Cursor, VS Code (Copilot) or Codex through the Model Context Protocol (specification 2025-11-25). An agent that implements a screen can read the design's outline, layers, tokens and components, look at screenshots, lint it and generate code; if you allow it, it can also build and change the design. Design: concept §8 and §14.3, ADR 0034 (decision 7).
The server is off by default. There are two ways to run it:
| Where | Transport | How a client connects |
|---|---|---|
| Desktop app | Streamable HTTP on 127.0.0.1:<port>/mcp | Settings ▸ Artificial intelligence ▸ MCP server: turn it on, allow the client, copy its configuration |
| Terminal, app running | stdio: ofini mcp relays to the app | claude mcp add openfini -- ofini mcp |
| Terminal, no app | stdio: ofini mcp --file design.ofini [--write] | claude mcp add openfini -- ofini mcp --file design.ofini (CI, scripts, a saved file) |
| Browser / PWA | none: a web page cannot open a port | use the CLI on a saved design, or the in-app assistant |
In the desktop app#
-
Turn on Settings ▸ Artificial intelligence ▸ MCP server ▸ Run the MCP server. The server listens on the loopback address only:
127.0.0.1, and[::1]on the same port when the system has IPv6 (so a client that resolveslocalhostto::1first connects at once). The port is random the first time and then kept (set your own under Port); a 256-bit token is created once (New token… replaces it). While it runs, an MCP button in the status bar shows the number of connected clients and opens the settings; turning the switch off drops every session at once. -
Copy a configuration into your agent:
# Claude Code over HTTP (the token is in the copied command) claude mcp add --transport http openfini http://127.0.0.1:<port>/mcp --header "Authorization: Bearer <token>" # Claude Code through the ofini command (reads address and token from the app, survives a new token) claude mcp add openfini -- ofini mcpCursor (
.cursor/mcp.json) and VS Code (.vscode/mcp.json) snippets are on the same page. Keep these files out of version control: they contain the token. -
Approval is per design. When a client connects, OpenFini asks about the active design, naming it: Deny, Allow reading or Allow reading and changes. A client sees only the open designs it was allowed, plus the active design while you have not decided about it yet (
access: "ask"inproto_list_documents); using that design asks you again, naming it. A denied design is hidden from the client. The answers are remembered per client name and design (by the document id saved in the.ofinifile, so copies of a file share it) until you change them in the settings: per design (Read only, Read and change, Denied, or Revoke: it asks again), Block (refused for every design without asking; disconnects it) or Revoke all (forgets the client and disconnects it). Until you allow changes on at least one design, the client sees only the read tools; a write on a design it may only read is refused.Grants from OpenFini 1.3.0 (one answer per client for every design) become grants for the designs open when the server first starts in this version; other designs ask. A denied 1.3.0 client stays blocked.
Labs ▸ Proto Studio must be on. Each tool takes an optional document (an id from proto_list_documents); without
it the active design is used.
Accountability. Every change an agent makes is one undo step named after the client (MCP · Claude Code:
Create layers), so Edit ▸ Undo takes it back, and collaboration partners see it like any edit. Comment replies are
comments, which are never undo steps in OpenFini: they are written by MCP · Claude Code with the AI badge and
can be deleted in the thread like any comment. Every tool call is
recorded in the AI log (Settings ▸ Artificial intelligence ▸ Logging and actions) with source mcp, the client name,
the tool, its argument names, the time and whether it failed (metadata only).
In a terminal#
ofini mcp (cli.md) speaks MCP over stdio: standard output carries only JSON-RPC messages,
notes go to standard error.
- Relay: without
--fileit reads the endpoint file the app writes while its server runs (mcp-endpoint.jsonin the app's data folder:%APPDATA%\io.github.philppplik.openfinion Windows,~/Library/Application Support/io.github.philppplik.openfinion macOS,$XDG_DATA_HOMEor~/.local/share/io.github.philppplik.openfinion Linux;OFINI_MCP_ENDPOINToverrides it) and forwards every message to the app. The approval prompt names the agent (itsclientInfo), notofini. If the app's server is not running, it says so on standard error and exits with code 4. - Headless:
--file design.ofiniserves one design (an.ofinifile, adocument.jsonor a bare model) with the same tools. It is read-only unless you add--write; then every successful write call is validated and written back at once: to a new temporary file next to the design (created exclusively), renamed over the original. A design with validation errors or from a newer OpenFini is refused with--write. Screenshots are SVG renders of the layout solver (approximate) instead of PNG.
Tools#
Read tools (always listed):
| Tool | Result |
|---|---|
proto_list_documents | The designs this client may use: id, title, pages, active, writable |
proto_get_tree | Outline of a page or subtree, one line per layer (the assistant's proto_describe format) |
proto_get_node | Stored or resolved JSON of layers |
proto_get_selection | The layers selected in the app (desktop app only) |
proto_get_geometry | Boxes of layers: exact in the app while the design is on screen, else from the layout solver (approximate) |
proto_screenshot | PNG of a layer or frame (app; approximate render of the layout solver) or an SVG render (headless) |
proto_get_tokens | Variables and styles as DTCG JSON, CSS custom properties, Tailwind v4 @theme or Swift |
proto_get_variables | Collections, modes and variables with their values per mode |
proto_get_components | Components and sets: variant axes, properties, code links, instance counts |
proto_generate_code | Code for layers or a page: html, react, react-tailwind, tailwind, swiftui |
proto_lint | Design lint: contrast, touch targets, unbound tokens, spacing, naming, overflow… |
proto_search | Layers by name, text, type, component, variable or unbound values |
proto_responsive | Overflow and cut-off text at several widths |
proto_get_comments | Comment threads (status: open, resolved or all; layer: one layer's threads) with every message and the resolved target: layer id, name and type, or a point on a page |
Write tools (only with Allow reading and changes, or --write): proto_create (nested specs with auto layout,
variables and instances), proto_write_html (HTML + CSS → layers), proto_write_svg (SVG → layers), proto_update,
proto_move, proto_delete, proto_duplicate, proto_component, proto_variables, proto_styles,
proto_interaction, proto_set_tokens (import DTCG), proto_fix (lint fixes), proto_content, proto_rename,
proto_apply_ops (raw engine operations as one batch, the format of ofini proto apply) and proto_reply_comment
(thread_id, text: a reply by MCP · <client>, marked AI; replying to a resolved thread reopens it).
proto_reply_comment follows the comment rules: in a shared room the reply is shared with it, and it is refused when
your role there does not allow comments. Headless, comments are those of an .ofini file (saved with the design after
a reply, like any write); a bare model JSON has none. They are the in-app
assistant's tools (proto-studio.md ▸ Assistant) bound to the chosen design, so both work
the same way; every operation goes through the one operation layer (engine/proto/ops.js) and its validation.
Failed calls return a result with isError: true and a readable message; nothing changes. Unknown tools and missing
permissions are JSON-RPC errors.
Resources and prompts#
Resources (with resources/subscribe: a notifications/resources/updated within about half a second after the design
changes): ofini-proto://<document>/tree, …/page/<id>, …/tokens.json, …/components, and the templates
…/node/<id> and …/code/<id>/<target>.
Prompts: implement_frame (frame, target), sync_tokens (format) and review_design (page).
Limits#
Requests up to 4 MiB; at most 2,000 layers per create call; 60 write calls per minute per client; 30 s per answer (including the time the approval prompt waits; a call that is still waiting for your answer after 20 s fails and can be repeated); 64 connections; 100 subscriptions per session.
Security#
- Loopback only: the desktop server binds
127.0.0.1and, when available,[::1](the same port); never a wildcard address, and a connection from any other address is closed. Nothing on your network can reach it. The endpoint file andofini mcpaccept only127.0.0.1,localhostor[::1]URLs. - Token: every request needs
Authorization: Bearer <token>(256 bits fromcrypto.getRandomValues, compared in constant time). It is stored in the app's key store with your AI provider keys (sealed with them when they have a passphrase) and in the endpoint file, which is created anew with user-only permissions (0600 on macOS and Linux; on Windows the folder is in your user profile) and removed when the server stops or the app quits. - DNS rebinding: the
Hostheader must be exactly127.0.0.1:<port>,localhost:<port>or[::1]:<port>(no other spelling of the IPv6 loopback), so a web page whose domain points at 127.0.0.1 or ::1 is refused. The token andOriginrules are the same on both addresses. - Web pages (CSRF): requests with an
Originheader are refused unless it is the app's own origin; the body must beapplication/json, which a page cannot send across origins without a preflight that fails here. - Approval and scope: each client is approved by you for each design; write tools exist only after you allow changes, and a write needs the change grant of that design. The server reaches only the open Proto designs the client was allowed: no files, no other studios, no settings, no network. The headless server reaches only the one file you named; no tool takes a path.
- Only the main window may start, stop or answer the server (
src-tauri/capabilities/mcp-server.jsonand a label check insrc-tauri/src/mcp_server.rs). - Prompt injection: layer names, texts and comments are written by people and are untrusted for the receiving
agent too. Results carry document text only inside JSON data, and the server's instructions tell agents that design
text is never an instruction. OpenFini cannot stop an agent from following text it reads: review what an agent
changes, and undo it if needed. Comment text (
proto_get_comments) is the same kind of data.
See also security.md ▸ MCP server.
Not yet#
Manual connection checks from Cursor and Codex.
Edit on GitHub → docs/mcp-server.md