Repository navigation
Download pull request attachments (images in comment threads) so agents can review PRs #1777
Pedro Simeão Carvalho (pesimeao)
started this conversation in
Backlog of Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Add a way to download pull request attachments, so an agent reviewing a pull request can see the screenshots and files that reviewers paste into comments.
Why I need this
We are using agents connected to this MCP server to help analyze pull requests: read the diff, go through the comment threads, check whether each comment was addressed, and suggest what is still missing before merge.
Many of our review comments are not text. Reviewers paste a screenshot of a broken UI, an error dialog, a log excerpt as an image, or attach a small file. Today
repo_pull_request_threadreturns those comments with only the markdown link to the attachment, for example:The agent cannot open that URL (it needs the same Azure DevOps authentication the server already has), so it has to skip the comment or guess what the screenshot shows. In practice, the comments with screenshots are often the most important ones in the review, so the analysis ends up incomplete exactly where it matters.
Work items already have
wit_work_item_attachment, so this would bring pull request comments to the same level.This was asked before in #665 (and #669). It was closed because it wasn't clear which API to use. There is a public endpoint for exactly this, and the Node API already wraps it as
GitApi.getAttachmentContent.Tools
I'd suggest adding an action to the existing
repo_pull_request_threadtool instead of a new tool:repo_pull_request_threadwithaction: get_attachmentDownloads a pull request attachment by file name (the last segment of the URL that appears in the comment).
Parameters:
repositoryId,pullRequestId,project(same as the other actions)fileName(required for this action)savePath(optional): if provided, saves the file to a directory inside the server's working directory and returns the path, like the work item attachment tool doesResponse:
Endpoint: GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/attachments/{fileName}?api-version=7.1
Docs: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-request-attachments/get
Security
Since earlier attachment requests were closed over security concerns, these are the points I took care with:
savePathandfileNameare validated so the file can only be written inside the working directory (same checks aswit_work_item_attachment, shared between the two tools)Rules
Implementation
I already have this implemented and tested in #1763. I opened it before creating this issue, so it was closed per the contribution guidelines, my bad. The code is ready:
get_attachmentaction onrepo_pull_request_thread, as described abovewit_work_item_attachmentmoved to a shared helper, so both tools use the same validationsavePath, rejected paths, failed downloads and a missing file namemainIf this gets a 👍 I'll open the PR again from the same branch.
All reactions