Skip to content

feat: add list_pull_request_review_threads tool to expose PRRT_ node IDs for resolving threads #2229

Description

@scottlz0310-user

Problem

resolve_pull_request_review_thread requires a thread node ID in PRRT_xxx format. However, this ID is not returned by any existing REST-based MCP tool — it is only obtainable via the GraphQL API.

Currently there is no way to complete the "list unresolved threads → resolve them" flow using the MCP tools alone, because there is no tool to retrieve the PRRT_xxx node IDs needed by resolve_pull_request_review_thread.

Proposed Solution

Add a list_pull_request_review_threads tool that uses the existing githubv4 GraphQL client (already a dependency) to query review threads and return their node IDs.

Tool Definition

Name:list_pull_request_review_threads

Input:

ParameterTypeRequiredDescription
ownerstringRepository owner
repostringRepository name
pull_numberintegerPull request number
is_resolvedbooleanFilter by resolution status. Omit to return all threads.

Output (per thread):

FieldTypeDescription
idstringNode ID in PRRT_xxx format — required for resolve_pull_request_review_thread
isResolvedbooleanWhether the thread has been resolved
isOutdatedbooleanWhether the thread is outdated (code changed after the comment)
pathstringFile path the thread is on
lineintegerEnd line number
startLineintegerStart line number
firstComment.bodystringBody of the first comment in the thread
firstComment.authorstringLogin of the commenter
firstComment.createdAtstringISO 8601 timestamp

Response envelope:

{
"threads": [...],
"totalCount": 4,
"truncated": false
}

Suggested GraphQL Query

query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
totalCountnodes {
idisResolvedisOutdatedpathlinestartLinecomments(first: 1) {
nodes {
bodyauthor { login }
createdAt
}
}
}
}
}
}
}

Registration

Would fit naturally in AllTools() in pkg/github/tools.go, alongside the existing resolve_pull_request_review_thread tool in ToolsetMetadataPullRequests.

Use Case / Motivation

The intended workflow is:

list_pull_request_review_threads(owner, repo, pull_number, is_resolved=false)
→ returns [{ id: "PRRT_kwDO...", ... }, ...]
resolve_pull_request_review_thread(threadId: "PRRT_kwDO...")
→ marks thread as resolved

Without list_pull_request_review_threads, an AI agent has no way to obtain the PRRT_xxx ID, making resolve_pull_request_review_thread effectively unusable from an MCP context.

Validation

We implemented this tool as a local patch against the current main branch and validated the end-to-end flow:

  • Tool appears in the MCP tool list ✅
  • Returns PRRT_xxx node IDs correctly ✅
  • is_resolved=false filter works as expected ✅
  • Returned IDs successfully used with resolve_pull_request_review_thread to resolve all 4 unresolved threads in a live PR ✅

The patch implementation is available at:
https://github.com/scottlz0310/Mcp-Docker/blob/main/patches/github/list_pr_review_threads.go

Additional Notes

  • No new dependencies required — uses the existing github.com/shurcooL/githubv4 client
  • is_resolved uses a 3-value pattern (nil = all, true = resolved only, false = unresolved only) consistent with similar optional boolean filters in the codebase
  • Type names chosen to avoid collision with existing reviewThreadsQuery / reviewThreadNode types in pullrequests.go

Happy to submit a PR if this direction looks good to the maintainers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions