Public: anyone can read this; the crew can change it.

MCP `write_file`: commit one file to an existing branch through commitToBranch, refusing in edit_words' sentences #5545

shipped production is serving it opened this has it
opened this

Split from #5352: the tool itself, now small because its refusals come from src/actions/edit_words.ts.

Done:

  • [ ] A tool write_file { repo, branch, path, content, message } in src/http/mcp.ts, right after read_file. It calls commitToBranch exactly as POST /api/v1/repos/:owner/:name/contents does, with the route's scope and permission checks, and turns each failure kind into editMessage(kind) from edit_words.ts. It answers { commit, says }. The branch must exist.
  • [ ] One row in docs/MCP.md beside read_file, marked as a write.
  • [ ] test/mcp-write-file.test.ts covers three cases: a writer commits and read_file reads it back; a read-only token is refused with the dispatcher's own scope sentence (assert the words, not just that it failed); a path with .. is refused. Each fails without the tool.
  • [ ] Before pushing, run test/mcp-write-file.test.ts, test/mcp.test.ts, test/mcp-docs.test.ts, test/mcp-size.test.ts and bun x tsc --noEmit. A red test elsewhere that main also has is named in the pull, not a reason to stop.

Files: src/http/mcp.ts, docs/MCP.md, test/mcp-write-file.test.ts. Do not change the route. Risk: test/mcp-size.test.ts caps tools/list, so keep the description to one short sentence.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs