Skip to content

feat(mcp): read_artifact + preview_patch + patch_artifact MCP tools — G2c (closes #61)#93

Merged
PowerCreek merged 1 commit into
mainfrom
artifact-tools-g2c-61
May 25, 2026
Merged

feat(mcp): read_artifact + preview_patch + patch_artifact MCP tools — G2c (closes #61)#93
PowerCreek merged 1 commit into
mainfrom
artifact-tools-g2c-61

Conversation

@PowerCreek

Copy link
Copy Markdown

Summary

Closes #61 (G2c sub-issue of #56). Three new devagentic-mutations MCP tools, shipped together because patch_artifact is unworkable without preview_patch outside dev-scoped contexts (the confirm_token gate makes them a unit).

Tools registered

Tool Wraps Notes
read_artifact(path, ctx_id?, strategy?="raw") readArtifact mutation 32K cap, or 256K when ctx_id is dev-scoped
preview_patch(path, find, replace) previewPatch query field Returns {confirm_token, diff, ...}; read-only
patch_artifact(path, find, replace, confirm_token?, ctx_id?) patchArtifact mutation Requires confirm_token outside dev-scoped/sandbox-backend ctx

Scope-expansion note

#61's body nominally scopes 2 tools (read_artifact + patch_artifact). Field-checking the devagentic resolver showed that patchArtifact requires confirm_token from a prior previewPatch call unless the ctx is dev-scoped or a sandbox-backend is active. Shipping the trio is the only way the patch tool is usable from a normal worker session.

Devagentic-side resolver verification

Schemas read directly from devagentic api.py via gh api:

  • readArtifact(path, ctx_id?, strategy?, strategy_args?) -> JSON
  • previewPatch(path, find, replace) -> JSON
  • patchArtifact(path, find, replace, confirm_token?, ctx_id?) -> JSON

Arg-name camelCase conversion (ctx_idctxId, confirm_tokenconfirmToken) matches strawberry's default snake-to-camel behavior.

Test plan

  • 12 new client-level tests in tests/plugins/devagentic-mutations/test_client.py pass (4 per tool: empty-arg fail-soft, happy-path with arg threading, in-band error / strategy / ctx_id / confirm_token threading, non-dict response fail-soft)
  • Contract test in test_mcp_defensive_registrars.py extended: read_artifact / preview_patch / patch_artifact added to required-G2 set
  • 190 total green across affected suites (mutations + MCP + canvas + docs + subset-filter + autowire) — no regression
  • After merge + container rebuild + devbox HTTP up: tools reachable from polynomial-explorer worker session

Tracking

… G2c (closes #61)

Three new devagentic-mutations MCP tools, shipped together because
``patch_artifact`` is unworkable without ``preview_patch`` outside
dev-scoped contexts (the confirm_token gate makes them a unit).

## Tools registered

| Tool | Wraps | Notes |
|---|---|---|
| ``read_artifact(path, ctx_id?, strategy?="raw")`` | ``readArtifact`` mutation | 32K cap, or 256K when ctx_id is dev-scoped |
| ``preview_patch(path, find, replace)`` | ``previewPatch`` query field | Returns ``{confirm_token, diff, ...}``; read-only |
| ``patch_artifact(path, find, replace, confirm_token?, ctx_id?)`` | ``patchArtifact`` mutation | Requires ``confirm_token`` outside dev-scoped/sandbox-backend ctx |

#61's scope was nominally 2 tools (read + patch). Reality: the
confirm_token gate makes ``patch_artifact`` unusable without
``preview_patch`` — so the three are shipped as the natural unit.
``previewPatch`` is a strawberry field on Query (not Mutation);
client + wrapper handle that distinction transparently.

## Devagentic-side resolver verification

Schemas read directly from the devagentic api.py via gh api:
- ``readArtifact(path, ctx_id?, strategy?, strategy_args?) -> JSON``
- ``previewPatch(path, find, replace) -> JSON``
- ``patchArtifact(path, find, replace, confirm_token?, ctx_id?) -> JSON``

The arg-name camelCase conversion (ctx_id → ctxId, confirm_token →
confirmToken) matches strawberry's default snake-to-camel behavior.

## Tests

- 12 new client-level tests (4 per tool) in
  ``tests/plugins/devagentic-mutations/test_client.py``: empty-arg
  fail-soft, happy-path round-trip with arg threading, strategy /
  ctx_id / confirm_token threading, in-band errors, non-dict
  response fail-soft.
- Contract test in ``test_mcp_defensive_registrars.py`` extended:
  ``read_artifact`` / ``preview_patch`` / ``patch_artifact`` added
  to the required-G2 tool set.
- 190 total green across affected suites (mutations + MCP + canvas
  + docs + subset-filter + autowire). No regression.

## Tracking
- Closes #61 (G2c).
- G2d (#62 fetchUrl) remains open as the last G2 sub-issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

G2c: patchArtifact / readArtifact MCP tools (sub-issue of #56)

1 participant