feat(penpot-mcp): add create_file tool #88

Merged
code-lead merged 1 commit from dev/73 into main 2026-04-19 16:52:58 +00:00
Collaborator

Summary

  • Adds create_file(project_id, name, features?) to penpot_mcp/tools/canvas.py, wrapping the create-file RPC directly (not a change-op — file is initialised server-side). Returns {file_id, name, revn}.
  • features defaults to Penpot's current baseline set (components/v2, layout/grid, styles/v2, design-tokens/v1, fdata/path-data, fdata/objects-map, fdata/shape-data-type, variants/v1, plugins/runtime), derived from the claude-hooks — dashboard reference file.
  • Unit tests assert camelCase RPC payload (projectId, name, features) and return value mapping (file_id not raw id).
  • Live test (pytest -m live) creates a temp file in the Drafts project, round-trips the name via get-file, and deletes it in finally.
  • README canvas tools table updated; CHANGELOG bumped to 0.6.0; pyproject.toml version bumped to 0.6.0.

Test plan

  • pytest tests/test_canvas.py — all 18 unit tests pass (3 new for create_file)
  • pytest -m live against a live Penpot instance — test_create_file_roundtrip_in_drafts_project creates and cleans up a temp file

Closes #73

## Summary - Adds `create_file(project_id, name, features?)` to `penpot_mcp/tools/canvas.py`, wrapping the `create-file` RPC directly (not a change-op — file is initialised server-side). Returns `{file_id, name, revn}`. - `features` defaults to Penpot's current baseline set (`components/v2`, `layout/grid`, `styles/v2`, `design-tokens/v1`, `fdata/path-data`, `fdata/objects-map`, `fdata/shape-data-type`, `variants/v1`, `plugins/runtime`), derived from the `claude-hooks — dashboard` reference file. - Unit tests assert camelCase RPC payload (`projectId`, `name`, `features`) and return value mapping (`file_id` not raw `id`). - Live test (`pytest -m live`) creates a temp file in the Drafts project, round-trips the name via `get-file`, and deletes it in `finally`. - README canvas tools table updated; CHANGELOG bumped to 0.6.0; `pyproject.toml` version bumped to 0.6.0. ## Test plan - [ ] `pytest tests/test_canvas.py` — all 18 unit tests pass (3 new for `create_file`) - [ ] `pytest -m live` against a live Penpot instance — `test_create_file_roundtrip_in_drafts_project` creates and cleans up a temp file Closes #73
feat(penpot-mcp): add create_file tool (issue #73)
All checks were successful
qa / qa (pull_request) Successful in 2m35s
qa / dockerfile (pull_request) Successful in 9s
a4c8779aa2
Adds create_file(project_id, name, features?) to the canvas module,
wrapping the create-file RPC directly. Returns {file_id, name, revn}.
Features default to Penpot's current baseline set derived from the
claude-hooks dashboard reference file.

Includes unit tests asserting camelCase RPC payload and return value,
and a live test (pytest -m live) that creates a temp file in Drafts,
round-trips the name via get-file, and deletes the file in finally.

Bumps penpot-mcp-server to 0.6.0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev requested review from reviewer 2026-04-19 16:46:22 +00:00
reviewer approved these changes 2026-04-19 16:48:15 +00:00
reviewer left a comment

Review: feat(penpot-mcp): add create_file tool

CI: run #1609 (SHA a4c8779) → success

Acceptance criteria (issue #73): all met

  • create_file(project_id, name, features?) implemented in canvas.py, calling create-file RPC directly (correct — not a change-op). Returns {file_id, name, revn}.
  • _DEFAULT_FEATURES list matches the spec exactly (all 9 flags).
  • features if features is not None else _DEFAULT_FEATURES correctly passes through an explicit empty list rather than silently replacing it with the default.
  • 3 unit tests covering: correct camelCase payload, custom features override, and return-value key mapping (file_id not raw id).
  • Live test dynamically discovers the Drafts project (no hard-coded UUID), creates a temp file, round-trips the name via get-file, and deletes in finally.
  • README canvas tools table updated; CHANGELOG bumped to 0.6.0; pyproject.toml version bumped to 0.6.0.

Note on missing @pytest.mark.asyncio in test_canvas_live.py: not an issue — pyproject.toml sets asyncio_mode = "auto", so the decorator is optional project-wide.

Code is correct, tests are thorough, no safety or logic issues. LGTM.

## Review: feat(penpot-mcp): add create_file tool **CI**: run #1609 (SHA `a4c8779`) → `success` ✅ **Acceptance criteria (issue #73)**: all met ✅ - `create_file(project_id, name, features?)` implemented in `canvas.py`, calling `create-file` RPC directly (correct — not a change-op). Returns `{file_id, name, revn}`. ✅ - `_DEFAULT_FEATURES` list matches the spec exactly (all 9 flags). ✅ - `features if features is not None else _DEFAULT_FEATURES` correctly passes through an explicit empty list rather than silently replacing it with the default. ✅ - 3 unit tests covering: correct camelCase payload, custom features override, and return-value key mapping (`file_id` not raw `id`). ✅ - Live test dynamically discovers the Drafts project (no hard-coded UUID), creates a temp file, round-trips the name via `get-file`, and deletes in `finally`. ✅ - README canvas tools table updated; CHANGELOG bumped to 0.6.0; `pyproject.toml` version bumped to 0.6.0. ✅ **Note on missing `@pytest.mark.asyncio` in `test_canvas_live.py`**: not an issue — `pyproject.toml` sets `asyncio_mode = "auto"`, so the decorator is optional project-wide. Code is correct, tests are thorough, no safety or logic issues. LGTM.
code-lead deleted branch dev/73 2026-04-19 16:52:59 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!88
No description provided.