Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Attachment handling can accept non-MP4 containers as MP4, reject valid line-wrapped base64 uploads, and hide GitHub failure details from callers and middleware.
3 open issues
What changed in this PR
Adds upload_attachment to the GitHub MCP Server so issue and pull request workflows can embed native GitHub.com media URLs.
Changes:
- Accepts base64 PNG, JPEG, GIF, and MP4 uploads up to 3.75 MB.
- Adds upload authentication, validation, and response handling.
- Updates tool registration, tests, schemas, and authoring guidance.
| File | Description |
|---|---|
| README.md | Documents the new tool and inputs. |
| pkg/skills/catalog/tools.go | Adds optional attachment support to authoring skills. |
| pkg/skills/catalog/skills/pull-request-authoring/SKILL.md | Explains media uploads and embedding in PR descriptions. |
| pkg/skills/catalog/skills/issue-authoring/SKILL.md | Explains media uploads and embedding in issue bodies. |
| pkg/http/transport/bearer.go | Uses token authentication for the native upload endpoint. |
| pkg/github/tools.go | Registers the attachment tool. |
| pkg/github/attachments.go | Implements upload validation, repository checks, and URL handling. |
| pkg/github/attachments_test.go | Tests uploads, invalid inputs, permissions, and rejected responses. |
| pkg/github/__toolsnaps__/upload_attachment.snap | Records the new tool schema. |
Review effort: Max (adaptive)
Comment on lines
+103
to
+105
| if len(encoded) > base64.StdEncoding.EncodedLen(maxAttachmentBytes) { | ||
| return nil, "", errors.New("attachments are limited to 3.75 MB") | ||
| } |
Comment on lines
+114
to
+115
| if mediaType == "video/mp4" && len(content) >= 12 && string(content[4:8]) == "ftyp" { | ||
| detected = "video/mp4" |
Comment on lines
+126
to
+142
| if err != nil { | ||
| return nil, errors.New("could not prepare the GitHub upload") | ||
| } | ||
| req.Header.Set("X-GitHub-Api-Version", "2022-11-28") | ||
| uploadClient := client.Client() | ||
| uploadClient.CheckRedirect = func(_ *http.Request, _ []*http.Request) error { return http.ErrUseLastResponse } | ||
| resp, err := uploadClient.Do(req) | ||
| if err != nil { | ||
| return nil, errors.New("could not send the file to GitHub") | ||
| } | ||
| defer resp.Body.Close() | ||
| if resp.StatusCode == http.StatusNotFound { | ||
| return nil, errors.New("GitHub refused the attachment (HTTP 404). Verify repository write access and credential support") | ||
| } | ||
| if resp.StatusCode != http.StatusCreated { | ||
| return nil, fmt.Errorf("GitHub returned HTTP %d for the attachment upload", resp.StatusCode) | ||
| } |
Contributor
AI Assessment: Missing DetailsThanks for the contribution. Please edit the description to fill in these
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Add
upload_attachmentto upload media to a GitHub.com repository and return a native attachment URL for issue and pull request descriptions and comments.Why
Agents need to attach screenshots and videos as evidence from remote environments. A reusable URL lets existing issue, pull request and comment tools embed the evidence. A hosted fork verified a fresh 3.75 MB MP4 upload and inline playback using the binary endpoint used by GitHub CLI.
Refs #738.
What changed
MCP impact
upload_attachmentis available in the issues toolset.Prompts tested
demo.mp4to this repository and return its attachment URL for the PR description. The new tool call was tested with a mocked GitHub endpoint. The hosted fork verified the underlying upload and playback with a real synthetic MP4.Security / limits
Tool renaming
Lint & tests
golangci-lint runandgo test ./....Docs
Skills