OpenFini

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:

WhereTransportHow a client connects
Desktop appStreamable HTTP on 127.0.0.1:<port>/mcpSettings ▸ Artificial intelligence ▸ MCP server: turn it on, allow the client, copy its configuration
Terminal, app runningstdio: ofini mcp relays to the appclaude mcp add openfini -- ofini mcp
Terminal, no appstdio: ofini mcp --file design.ofini [--write]claude mcp add openfini -- ofini mcp --file design.ofini (CI, scripts, a saved file)
Browser / PWAnone: a web page cannot open a portuse the CLI on a saved design, or the in-app assistant

In the desktop app#

  1. 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 resolves localhost to ::1 first 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.

  2. 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 mcp
    

    Cursor (.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.

  3. 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" in proto_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 .ofini file, 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 --file it reads the endpoint file the app writes while its server runs (mcp-endpoint.json in the app's data folder: %APPDATA%\io.github.philppplik.openfini on Windows, ~/Library/Application Support/io.github.philppplik.openfini on macOS, $XDG_DATA_HOME or ~/.local/share/io.github.philppplik.openfini on Linux; OFINI_MCP_ENDPOINT overrides it) and forwards every message to the app. The approval prompt names the agent (its clientInfo), not ofini. If the app's server is not running, it says so on standard error and exits with code 4.
  • Headless: --file design.ofini serves one design (an .ofini file, a document.json or 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):

ToolResult
proto_list_documentsThe designs this client may use: id, title, pages, active, writable
proto_get_treeOutline of a page or subtree, one line per layer (the assistant's proto_describe format)
proto_get_nodeStored or resolved JSON of layers
proto_get_selectionThe layers selected in the app (desktop app only)
proto_get_geometryBoxes of layers: exact in the app while the design is on screen, else from the layout solver (approximate)
proto_screenshotPNG of a layer or frame (app; approximate render of the layout solver) or an SVG render (headless)
proto_get_tokensVariables and styles as DTCG JSON, CSS custom properties, Tailwind v4 @theme or Swift
proto_get_variablesCollections, modes and variables with their values per mode
proto_get_componentsComponents and sets: variant axes, properties, code links, instance counts
proto_generate_codeCode for layers or a page: html, react, react-tailwind, tailwind, swiftui
proto_lintDesign lint: contrast, touch targets, unbound tokens, spacing, naming, overflow…
proto_searchLayers by name, text, type, component, variable or unbound values
proto_responsiveOverflow and cut-off text at several widths
proto_get_commentsComment 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.1 and, 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 and ofini mcp accept only 127.0.0.1, localhost or [::1] URLs.
  • Token: every request needs Authorization: Bearer <token> (256 bits from crypto.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 Host header must be exactly 127.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 and Origin rules are the same on both addresses.
  • Web pages (CSRF): requests with an Origin header are refused unless it is the app's own origin; the body must be application/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.json and a label check in src-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