Skip to content

backport: issue_graph tool — cross-repo issue/PR hierarchy traversal #3

Description

@gastrodon

Summary

Backport the issue_graph tool from upstream PR github#1511 (tracking issue: github#1510).

For autonomous agents this collapses N+1 issue traversal calls into one, returning a complete graph of epics, tasks, sub-issues, and linked PRs.

What the tool does

BFS traversal from a root issue/PR following:

  • Sub-issues (native GitHub sub-issue relationship)
  • Linked PRs (closing references)
  • Parent epics (tracked-in)

Returns a flat node+edge list optimized for LLM consumption.

Parameters:

  • owner (required)
  • repo (required)
  • issue_number (required): int
  • focus (optional): "epic" or "batch" — filters traversal direction
  • cross_repo (optional, bool): follow references into other repos

Backport approach

  1. Fetch the upstream diff: curl https://github.com/github/github-mcp-server/pull/1511.diff
  2. Read it carefully — the PR was generated by Copilot against an older main, expect drift
  3. Implement the tool manually in pkg/github/issues.go or a new pkg/github/issue_graph.go
  4. Register in the issues toolset

Key implementation notes

  • Sub-issues use the subIssues GraphQL connection — requires sub-issues beta header. Find where beta headers are added in the codebase (look for sub-issues or betas.go)
  • The BFS traversal should have a depth/node limit to prevent runaway queries (upstream uses 50 nodes)
  • Cross-repo references need careful handling — only follow if cross_repo=true
  • Output format: flat array of {id, type, title, state, url, relationships: [{type, target_id}]}

Reference

Upstream PR diff: https://github.com/github/github-mcp-server/pull/1511.diff
Upstream issue: github#1510

Files to Modify

  • pkg/github/issues.go or new pkg/github/issue_graph.go
  • pkg/github/issues_test.go or new pkg/github/issue_graph_test.go
  • toolset registration for issues toolset

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions