# AfterPencil MCP server

For agents without a browser (Claude, Claude Code, Cursor and other MCP clients). It works on the projects of one workspace with the same commands as [`window.afterpencil`](/agents/js-api.md).

## Connect

- URL: `https://mcp.afterpencil.com/mcp` (Streamable HTTP).
- Sign-in: OAuth 2.1 with PKCE and dynamic client registration; the client discovers it from the server's 401. The person signs in to AfterPencil, picks a workspace and whether you may view or view and edit. They can disconnect you from their account at any time.
- A connection never does more than the person can in that workspace, and cannot share or delete projects.
- Agents need a workspace on Plus or Pro: on Free, tools answer with the error `plan-required`.
- For scripts and n8n without MCP, the person can create an API key in the editor (Integrations) and you call the [REST API](https://api.afterpencil.com/openapi.json) with it.

## Tools

| Tool | What it does |
|---|---|
| `list_projects` | Projects of the workspace, and whether you may read or write. |
| `get_project` | Compact summary: levels with rooms (names, areas), walls, openings, furniture, lights, switches, materials, height guides, with ids. |
| `get_plan` | The full plan JSON ([model](/agents/model.md)). Large: prefer `get_project`. |
| `get_takeoff` | Quantities. |
| `get_plan_image` | The technical floor plan of a level as a PNG, with dimensions and room names. |
| `get_catalog`, `get_material_presets` | Furniture ids and sizes; material preset ids. |
| `create_project` | An empty project with a ground level. |
| `draw_walls`, `draw_room`, `name_room`, `place_opening`, `place_furniture`, `place_light`, `place_switch`, `paint`, `add_wall_zone`, `move_wall`, `delete_elements`, `add_level`, `draw_slab`, `draw_roof`, `draw_stair`, `draw_lot`, `draw_fence`, `add_wall_type` | The commands of the [JavaScript API](/agents/js-api.md), with `project_id`. |
| `apply_operations`, `check_operations` | Model operations, for what no command covers. |

Units are meters; x to the right, y down on screen. Each editing tool saves the project and returns `{ ok, created, removed, version }` or `{ ok: false, error: { code, message } }`. If someone saved in between, the command is rebuilt on the newer version. Look at the result with `get_plan_image`.
