Skip to content

Add native media attachment uploads - #4012

Open
gwomtt wants to merge 2 commits into
github:mainfrom
team-table:upstream/native-media-attachments
Open

gwomtt wants to merge 2 commits into
github:mainfrom
team-table:upstream/native-media-attachments

Conversation

@gwomtt

@gwomtt gwomtt commented Dec 2, 2026

Copy link
Copy Markdown

Summary

Add upload_attachment to 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

  • Accept PNG, JPEG, GIF and MP4 files up to 3.75 MB, supplied as standard base64.
  • Return the permanent attachment URL and document how issue and pull request workflows can embed it.
  • Add tests for attachment creation, invalid inputs, repository permissions, rejected credentials and redirects.

MCP impact

  • New tool added. upload_attachment is available in the issues toolset.

Prompts tested

  • Upload demo.mp4 to 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

  • Auth / permissions considered. The tool uses the caller's GitHub credential and requires repository write access.
  • Data exposure, filtering, or token/size limits considered. The tool verifies the media type and returned URL, limits the binary to 3.75 MB, and refuses upload redirects.

Tool renaming

  • Existing tool names are preserved.

Lint & tests

  • Passed locally with golangci-lint run and go test ./....

Docs

  • Updated the generated tool documentation.

Skills

  • Updated issue authoring and pull request authoring.

@gwomtt
gwomtt marked this pull request as ready for review December 2, 2026 16:32
@gwomtt
gwomtt requested a review from a team as a code owner December 2, 2026 16:32
Copilot AI adaptive review requested due to automatic review settings December 2, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 thread pkg/github/attachments.go
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 thread pkg/github/attachments.go
Comment on lines +114 to +115
if mediaType == "video/mp4" && len(content) >= 12 && string(content[4:8]) == "ftyp" {
detected = "video/mp4"
Comment thread pkg/github/attachments.go
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)
}
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

AI Assessment: Missing Details

Thanks for the contribution. Please edit the description to fill in these
sections of the pull request template:

  • Tool renaming

Generated by Pull Request Triage · copilot · auto (Claude Sonnet 5.5) · ~11 AIC · ⌖ ~1 AIC · ⊞ 6.6K · history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants