2026-03-02 10:57:03 +00:00
# MCP Server
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tools — Claude Code, Cursor, Windsurf, etc. — read and modify `.fig` files headlessly.
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
Two transports: **stdio** for MCP clients, **HTTP** for everything else.
2026-02-28 08:38:27 +00:00
2026-03-02 11:28:56 +00:00
## Install
```sh
bun add -g @open -pencil/mcp
```
2026-03-02 10:57:03 +00:00
## Stdio (Claude Code, Cursor, etc.)
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
Add to your MCP config (e.g. `~/.claude/settings.json` or `.cursor/mcp.json` ):
2026-02-28 08:38:27 +00:00
2026-03-02 11:28:56 +00:00
```json
{
"mcpServers": {
"open-pencil": {
"command": "openpencil-mcp"
}
}
}
```
Or run from source without installing:
2026-03-02 10:57:03 +00:00
::: code-group
```json [Bun]
{
"mcpServers": {
"open-pencil": {
"command": "bun",
"args": ["/path/to/open-pencil/packages/mcp/src/index.ts"]
}
}
}
```
```json [Node.js]
{
"mcpServers": {
"open-pencil": {
"command": "npx",
"args": ["tsx", "/path/to/open-pencil/packages/mcp/src/index.ts"]
}
}
}
```
:::
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
## HTTP
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
For browser extensions, scripts, CI, or any HTTP client:
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
```sh
2026-03-02 11:28:56 +00:00
openpencil-mcp-http
2026-03-02 10:57:03 +00:00
```
2026-02-28 08:38:27 +00:00
2026-03-02 11:28:56 +00:00
Or from source: `bun packages/mcp/src/http.ts` / `npx tsx packages/mcp/src/http.ts`
2026-03-02 10:57:03 +00:00
Starts on port 3100 (override with `PORT` env var). Endpoints:
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
- `GET /health` — server status
- `POST /mcp` — MCP Streamable HTTP (SSE). Sessions via `mcp-session-id` header.
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
## Workflow
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
1. **Open** — `open_file` to load an existing `.fig` , or `new_document` for a blank canvas
2. **Read** — `get_page_tree` , `find_nodes` , `get_node` , `list_pages`
3. **Create** — `create_shape` , `render` (JSX)
4. **Modify** — `set_fill` , `set_stroke` , `set_layout` , `update_node` , `set_effects`
5. **Structure** — `reparent_node` , `group_nodes` , `clone_node` , `delete_node`
6. **Save** — `save_file` to write back to `.fig`
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
## Tools (29)
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
### Document
2026-02-28 08:38:27 +00:00
| Tool | Description |
|------|-------------|
2026-03-02 10:57:03 +00:00
| `open_file` | Open a `.fig` file for editing |
| `save_file` | Save the current document to a `.fig` file |
| `new_document` | Create a new empty document |
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
### Read
2026-02-28 08:38:27 +00:00
| Tool | Description |
|------|-------------|
2026-03-02 10:57:03 +00:00
| `get_selection` | Get currently selected nodes |
| `get_page_tree` | Get the full node tree of the current page |
| `get_node` | Get detailed properties of a node by ID |
| `find_nodes` | Find nodes by name pattern and/or type |
| `list_pages` | List all pages |
| `list_variables` | List design variables |
| `list_collections` | List variable collections |
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
### Create
2026-02-28 08:38:27 +00:00
| Tool | Description |
|------|-------------|
2026-03-02 10:57:03 +00:00
| `create_shape` | Create a shape (FRAME, RECTANGLE, ELLIPSE, TEXT, LINE, STAR, POLYGON, SECTION) |
| `render` | Render JSX to design nodes — create entire component trees in one call |
| `create_component` | Convert a frame/group into a component |
| `create_instance` | Create an instance of a component |
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
### Modify
2026-02-28 08:38:27 +00:00
| Tool | Description |
|------|-------------|
2026-03-02 10:57:03 +00:00
| `set_fill` | Set fill color (hex) |
| `set_stroke` | Set stroke color, weight, alignment |
| `set_effects` | Add shadow or blur effects |
| `update_node` | Update position, size, opacity, corner radius, text, font |
| `set_layout` | Set auto-layout (flexbox) — direction, spacing, padding, alignment |
| `set_constraints` | Set resize constraints |
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
### Structure
2026-02-28 08:38:27 +00:00
| Tool | Description |
|------|-------------|
2026-03-02 10:57:03 +00:00
| `delete_node` | Delete a node |
| `clone_node` | Duplicate a node |
| `rename_node` | Rename a node |
| `reparent_node` | Move a node into a different parent |
| `select_nodes` | Select nodes by ID |
| `group_nodes` | Group nodes |
| `ungroup_node` | Ungroup a group |
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
### Navigation
2026-02-28 08:38:27 +00:00
| Tool | Description |
|------|-------------|
2026-03-02 10:57:03 +00:00
| `switch_page` | Switch to a page by name or ID |
2026-02-28 08:38:27 +00:00
2026-03-02 10:57:03 +00:00
### Escape Hatch
2026-02-28 08:38:27 +00:00
| Tool | Description |
|------|-------------|
2026-03-02 10:57:03 +00:00
| `eval` | Execute JavaScript with full Figma Plugin API access |