feat(attachment): upload from a server-side file path #16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/attachment-file-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
create_issue_attachment/create_comment_attachmentonly acceptedcontentas a base64 string, which has to travel through the model's context window. A 68 KiB zip is ~91k base64 characters (~86k tokens) — no tool call carries that, andRead/Bashcap far below it. Anything beyond a few KiB was effectively un-uploadable from an agent.The download side already solved the mirror problem (
download_*_attachmentstreams files over the inline cap to disk and returns only thepath,operation/attachment/attachment.godownloadResultFor). This PR adds the counterpart for upload.What
file_path(absolute path on the MCP server's host) on both create tools;contentbecomes optional. Exactly one of the two must be given, otherwise a clear error.filenamedefaults to the basename offile_path;mime_typeis inferred from the extension when omitted (the param description always claimed this — now it is true for both modes).operation/attachment/upload.go:resolveUploadSource/uploadAttachment) replaces the duplicated decode+multipart code in both handlers.GET /settings/attachment(max_size, MiB) and rejects oversized files naming the real limit; if the endpoint is unavailable, a documented 50 MiB fallback (FallbackMaxUploadBytes) applies.README.md,demos/issue-attachments.md,docs/plans/issue-attachments.md,operation/params/params.go,extension/manifest.json.Tests
operation/attachment/upload_test.go: helper unit tests (input selection, defaults, overrides, MIME inference, every error case, instance limit vs fallback) plus handler-level tests for issue and comment scope asserting the multipart part carries the file bytes, basename andapplication/zip.TestCreateIssueAttachmentFn_DecodesBase64AndUsesMultipartadjusted to pick the POST record instead of assuming order (the settings preflight now precedes it).test/e2e/attachments.sh: new step 2b uploads viafile_path, checks name defaulted to basename, size, and sha256 of the downloaded bytes; plus a rejection case forcontent+file_pathtogether.go vet ./...clean,go test ./...green for every package exceptoperation/actions—TestDispatchWorkflowFn_LegacyFallbackOn204fails identically on pristinemain(b98a5e8) and this PR does not touch that package.Output bounding
Response shape is unchanged (a single
AttachmentJSON); no data-dependent size introduced.Note on transports
file_pathassumes the MCP server shares a filesystem with the agent (stdio, or a local proxy such as mcp-hub). Over remote SSE/HTTP the base64 mode remains the only option — documented in the demo.🤖 Generated with Claude Code