affinity-mcp
Provides tools for interacting with Affinity 3 through its local MCP connector, enabling document management (listing, creating, opening documents; reading and updating document settings), content creation (adding shapes, text, and images), exporting designs, and invoking Affinity SDK scripts and documentation tools. It can launch Affinity if needed and manages the upstream session.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@affinity-mcp list my open Affinity documents"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
affinity-mcp
affinity-mcp is a small stdio MCP adapter for Affinity 3's local legacy SSE MCP connector. It exposes the connector's tools with stable affinity_ names and manages the upstream session for you: it connects on first use, reads the required SDK preamble, and reconnects (re-reading the preamble) if Affinity quits.
MCP host <-> stdio <-> affinity-mcp <-> legacy SSE <-> Affinity 3The adapter always starts, whether or not Affinity is running. Any Affinity tool call opens Affinity if needed: it first tries to reconnect (in case Affinity is running but the session dropped), and only then launches it with macOS open -g -b com.canva.affinity in the background without stealing focus, waiting for the connector at http://localhost:6767/sse. If Affinity still cannot be reached, the tool returns AFFINITY_UNAVAILABLE with the reason. Nothing else activates, focuses, or scripts the application.
Install
Requires Node.js 22 or newer.
npm install
npm run check
npm linkRelated MCP server: figma-local-bridge
Configuration
AFFINITY_MCP_URL: Affinity SSE endpoint. Default:http://localhost:6767/sse.AFFINITY_SCRIPT_TIMEOUT_MS: upstream call timeout in milliseconds. Default:300000.AFFINITY_BUNDLE_ID: macOS bundle identifieraffinity_openlaunches. Default:com.canva.affinity.AFFINITY_LAUNCH_TIMEOUT_MS: how longaffinity_openwaits for the connector after launching. Default:120000.
Generic stdio MCP configuration for OpenCode, Claude Desktop, or another MCP host:
{
"mcpServers": {
"affinity": {
"command": "affinity-mcp",
"env": {
"AFFINITY_MCP_URL": "http://localhost:6767/sse",
"AFFINITY_SCRIPT_TIMEOUT_MS": "300000"
}
}
}
}Without npm link, use the absolute built executable:
{
"mcpServers": {
"affinity": {
"command": "node",
"args": ["/absolute/path/to/affinity-mcp/dist/index.js"]
}
}
}Tools
Adapter lifecycle:
affinity_status: connection state (disconnectedwith a reason,connecting, orconnected). Never launches Affinity.affinity_open: launches Affinity if needed, waits for the connector, and connects. Every other tool does this implicitly; use it to warm Affinity up ahead of a long session.
Document management (implemented as SDK scripts over the connector's execute_script; each opens Affinity first if needed):
affinity_list_documents: open documents withsession_uuid,title,path,is_dirty,is_current.affinity_new_document: create from a preset name ({ "preset": "A4" }) or explicit size ({ "width": 1080, "height": 1080, "units": "Pixel", "dpi": 72 }), optionally saving tosave_as. An unknown preset fails with the list of available names.affinity_open_document: open a file by absolute path, or return it if already open. Paths outside Affinity's permitted folders (Desktop by default) fail withPERMISSION_DENIED.affinity_get_document_settings: read pixel dimensions, dpi, units, colour format and profile, mask format, layer and artboard counts, fonts, and dirty/undo state. Defaults to the current document; passsession_uuidto target another.affinity_set_document_settings: changeunits,dpi,width_pixels/height_pixels, andtransparent_background, returning the updated settings. Units use a dedicated command; dpi, size, and transparency rewrite document setup (other settings are preserved, but background transparency resets to opaque unlesstransparent_backgroundis given).
Content and output (also SDK scripts over execute_script; each opens Affinity first if needed):
affinity_export: export to an absolutepathaspng,jpeg,tiff,pdf,svg,webp, orgif.areaiswhole_document(default),current_spread,current_page, orselection. Writing outside Affinity's permitted folders (Desktop by default) fails withPERMISSION_DENIED.affinity_add_shape: add arectangleorellipseat pixelx,y,width,heightwith an optional#RRGGBB/#RRGGBBAAfill.affinity_add_text: add a text frame withtextat pixelx,y,width,height, using the document's default text style.affinity_place_image: place an image file; givex,y,width,heightto fit a rectangle or omit them for natural size. Reading outside permitted folders fails withPERMISSION_DENIED.
Content tools return the target session_uuid and the document's new layer_count. Script failures from all script-backed tools are reported as AFFINITY_SCRIPT_ERROR.
Affinity connector tools (unchanged upstream semantics; each opens Affinity first if it is not running):
affinity_add_sdk_hintaffinity_execute_scriptaffinity_list_library_scriptsaffinity_list_sdk_documentationaffinity_read_library_scriptaffinity_read_sdk_documentation_topicaffinity_render_selectionaffinity_render_spreadaffinity_report_sdk_issueaffinity_save_script_to_libraryaffinity_search_sdk_hints
Security
affinity_execute_script runs JavaScript inside Affinity and can modify open documents. Depending on Affinity's settings, scripts may also use AI, networking, or limited filesystem capabilities. Review generated scripts and keep Affinity's permissions restricted to what the task requires.
The only process the adapter starts is open -g -b <bundle id>, run only when Affinity is not reachable and only on macOS. It never uses osascript or asks Affinity to become the active application.
Architecture
src/affinity-client.tsowns the lazy upstream SSE session: connect on demand, preamble read per session, timeout, dropping the session when the event stream errors or a send fails, and error normalization.src/affinity-launcher.tslaunches Affinity and waits (bounded) for the connector.src/script-runtime.tsbuilds each generated script (a marker-line success/failure protocol, since Affinity reports uncaught script exceptions as plain text withisError: false) and decodes the result.src/documents.ts,src/document-settings.ts,src/export.ts, andsrc/primitives.tsbuild the document, setup, export, and content scripts on that runtime and define their result schemas.src/server.tsdefines the typed stdio-facing tools and delegates calls without changing upstream text, image content, orisError.src/index.tsserves stdio immediately, attempts an opportunistic upstream connection, and closes both sides during shutdown. Diagnostics use stderr only.
Available Tools
22 toolsaffinity_add_sdk_hintC
Add a verified SDK hint to Affinity's preamble for future sessions.
Inputs: hint (required).
affinity_add_shapeA
Add a rectangle or ellipse at pixel coordinates (x, y, width, height) with an optional #RRGGBB or #RRGGBBAA fill. Defaults to the current document; pass session_uuid to target another.
Inputs: x (required), y (required), kind (required), width (required), +3 more.
affinity_add_textA
Add a text frame containing text at pixel coordinates (x, y, width, height), using the document's default text style. Defaults to the current document; pass session_uuid to target another.
Inputs: x (required), y (required), text (required), width (required), +2 more.
affinity_execute_scriptCDestructive
Execute JavaScript in Affinity. This can modify documents and access capabilities allowed by Affinity settings.
Inputs: script (required).
affinity_exportA
Export a document to an absolute path as png, jpeg, tiff, pdf, svg, webp, or gif. area is whole_document (default), current_spread, current_page, or selection. Affinity's filesystem setting limits where files can be written; the Desktop is allowed by default. Defaults to the current document.
Inputs: path (required), format (required), area, session_uuid.
affinity_get_document_settingsARead-onlyIdempotent
Read a document's setup: pixel dimensions, dpi, units, colour format and profile, layer and artboard counts, fonts, and dirty/undo state. Defaults to the current document; pass session_uuid to target a specific one.
Inputs: session_uuid.
affinity_list_documentsARead-onlyIdempotent
List the documents currently open in Affinity with their session UUIDs, titles, paths, and dirty state.
Inputs: no named parameters.
affinity_list_library_scriptsBRead-onlyIdempotent
List scripts in Affinity's script library.
Inputs: no named parameters.
affinity_list_sdk_documentationBRead-onlyIdempotent
List available Affinity SDK documentation topics.
Inputs: no named parameters.
affinity_new_documentA
Create a new Affinity document, either from a named preset (for example 'A4', 'IG Post', 'Icon') or from explicit width, height, and units. Optionally save it straight to save_as. Returns the document's session UUID for later tools.
affinity_openAIdempotent
Launch Affinity if it is not running, wait for its local MCP connector, and connect. Other tools do this automatically; use this to warm Affinity up ahead of time.
Inputs: no named parameters.
affinity_open_documentA
Open an existing document from an absolute path (or return it if it is already open). Affinity's filesystem setting limits which folders are readable; the Desktop is allowed by default.
Inputs: path (required).
affinity_place_imageA
Place an image file into the document. Give x, y, width, height to fit it to a rectangle, or omit them for the image's natural size. Affinity's filesystem setting limits which folders are readable; the Desktop is allowed by default. Defaults to the current document.
Inputs: image_path (required), x, y, width, +2 more.
affinity_read_library_scriptCRead-onlyIdempotent
Read a named script from Affinity's script library.
Inputs: title (required).
affinity_read_sdk_documentation_topicCRead-onlyIdempotent
Read an Affinity SDK documentation topic by filename.
Inputs: filename (required).
affinity_render_selectionCRead-onlyIdempotent
Render the selected nodes in a document session as a JPEG.
Inputs: document_session_uuid (required).
affinity_render_spreadCRead-onlyIdempotent
Render a zero-based spread in a document session as a JPEG.
Inputs: spread_index (required), document_session_uuid (required).
affinity_report_sdk_issueB
Report a confirmed Affinity SDK issue with optional reproduction code.
Inputs: description (required), code.
affinity_save_script_to_libraryCDestructive
Save a completed JavaScript script to Affinity's script library.
Inputs: code (required), title (required), description (required).
affinity_search_sdk_hintsCRead-onlyIdempotent
Search shared Affinity SDK hints for an existing solution.
Inputs: prompt (required).
affinity_set_document_settingsADestructive
Change a document's setup and return the updated settings. Supports units, dpi, pixel width/height, and transparent_background. Changing dpi, size, or transparency rewrites document setup; other settings are preserved, but background transparency resets to opaque unless transparent_background is given. Defaults to the current document; pass session_uuid to target a specific one.
Inputs: dpi, units, session_uuid, width_pixels, +2 more.
affinity_statusARead-onlyIdempotent
Report whether the adapter is connected to Affinity's local MCP connector. Does not launch Affinity.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 22 tools
Most tools have clearly distinct resource/action targets, such as document lifecycle, settings, export, and rendering. The main overlap is in the SDK/scripting cluster, where add_sdk_hint, search_sdk_hints, read_sdk_documentation_topic, report_sdk_issue, save_script_to_library, and execute_script require careful reading to distinguish.
All tools use the affinity_ prefix with snake_case, giving a predictable namespace and mostly verb_noun naming. A few standalone operations like affinity_status and affinity_open are minor deviations but remain readable.
The 22-tool surface is broad but feels heavy for the core purpose. While each tool has a plausible role, the scripting and SDK documentation tools push the count into a crowded range.
The set covers connection, document creation/open/listing, settings, export, basic shape/text/image insertion, rendering, and scripting/SDK support. Gaps remain around closing/deleting documents and deeper layer/selection editing, but execute_script provides a workaround.
Maintenance
Related MCP Connectors
MCP server for the PDFGate API. Generate PDFs, manage documents and handle e-signatures.
Generate and manage Storydoc presentations from any MCP-compatible client.
Global CAD/BIM, industrial engineering (FEM, CFD) and property tools via one MCP endpoint.
Headless CAD engine & MCP server for 2D/3D drafting, solids, DXF/SVG export, and automation.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables querying PCB and schematic data and driving DelphiScript automation in Altium Designer via MCP.1310MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to read and modify the currently open Figma design file through a paired local Figma plugin, supporting operations like creating nodes, editing properties, and exporting PNG/SVG.2MIT
- AlicenseCqualityBmaintenanceEnables MCP clients to inspect and modify SketchUp models through a local authenticated bridge, covering entity creation and editing, geometry, materials, tags, cameras, scenes, transactions, snapshots, and file or view export. It also offers an optional full SketchUp Ruby API execution channel and batch operations for furniture, architectural, and analysis tasks.371MIT
- AlicenseNot gradedqualityBmaintenanceEnables local MCP-capable assistants to connect to Figma Desktop to read documents, pages, and selections, edit native layers and components, and export PNG/SVG across multiple files without Figma API keys.2MIT