Skip to content

Attachments over the CLI and MCP - #7

Merged
andreasnanko merged 1 commit into
mainfrom
feat/attachments-cli-mcp
Nov 19, 2026
Merged

andreasnanko merged 1 commit into
mainfrom
feat/attachments-cli-mcp

Conversation

@andreasnanko

Copy link
Copy Markdown
Contributor

What

Attachments could only be handled in the browser. This adds them to the CLI and the MCP server, and fixes what got in the way.

CLI: completo attachment <ticket> [list|add|download|delete]

  • add takes one or more files and reads all of them before uploading any (a typo attaches nothing). The upload carries a Content-Length, so the server's early size check applies.
  • download saves under the file's own name, or to -o <dir|path|->; it refuses to overwrite without --force, keeps a stored name inside the chosen directory, and removes a partial file on failure.
  • Files are named by the 8-character ID the list prints or by file name. --json on every action.

MCP

  • list_attachments, add_attachment (content as text or base64), get_attachment (text files as text, PNG/JPEG/GIF/WebP as an image block, anything else as details and a link), delete_attachment. get_card lists a card's files.
  • All tools go through the REST handlers via event.$fetch. The in-process fetch drops a FormData body's multipart Content-Type, so the tool context encodes the FormData itself.
  • /mcp gets a body limit that fits a base64 upload at the upload limit; at the 1 MB default a file stopped at 1 MB.

Fixes found on the way

  • GET /api/cards/:id returns attachmentCount; completo get printed attachments: 0 for every card.
  • The upload handler answered a non-multipart body with a 500; now 400.
  • Every CLI command accepted a ticket with the wrong project key (card numbers are global, so AB-42 acted on card 42 of another project, including writes). fetchCard now refuses it, as the MCP loadCard already did.
  • CLI errors were printed twice around the full usage text; now once, prefixed Error:. Argument and flag mistakes still show the usage.

Docs: CHANGELOG (Unreleased), README MCP section, skills/completo/SKILL.md, OpenAPI (attachmentCount), MCP instructions.

Tests

  • pnpm lint, pnpm typecheck, pnpm test: 132 files, 2019 passed, 8 skipped. New: 11 MCP attachment tests (text, maxChars cut, image block, binary as link, a 2 MB file over /mcp, server refusal passed through, input validation, delete, no access to another card's file) and 2 upload tests (400 for non-multipart, attachmentCount).
  • gofmt, go vet, go test ./...: ref resolution, download path containment, declared content type, key check, multipart with Content-Length, error passthrough.
  • End to end: the built CLI binary against a built server, 16 checks: add two files, list and --json, download by name and by ID prefix byte-identical, overwrite refusal and --force, refused type, missing file uploads nothing, delete, wrong key refused, get count.

🤖 Generated with Claude Code

CLI: `completo attachment <ticket> [list|add|download|delete]`, with
multipart upload (sent with a Content-Length so the server's early size
check applies) and streamed download that never overwrites without
--force and keeps a stored name inside the chosen directory.

MCP: list_attachments, add_attachment (text or base64), get_attachment
(text as text, images as image blocks, other files as a link) and
delete_attachment, all through the REST handlers. The in-process fetch
drops a FormData body's multipart Content-Type, so the tool context
encodes it itself. /mcp gets a body limit that fits a base64 upload at
the upload limit instead of the 1 MB default.

Fixes found on the way:
- GET /api/cards/:id returns attachmentCount; `completo get` printed 0
  for every card.
- The upload handler answered a non-multipart body with a 500.
- Every CLI command accepted a ticket with the wrong project key and
  acted on that card number in another project; fetchCard now refuses
  it, as the MCP loadCard already did.
- CLI errors printed twice around the full usage text.
@andreasnanko
andreasnanko merged commit 8f017f7 into main Nov 19, 2026
4 checks passed
@andreasnanko
andreasnanko deleted the feat/attachments-cli-mcp branch November 19, 2026 07:48
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.

1 participant