Skip to content

Commit 7bba72a

Browse files
Address code review feedback and add tool interaction docs
Co-authored-by: SamMorrowDrums <[email protected]>
1 parent 00b2390 commit 7bba72a

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

pkg/github/__toolsnaps__/issue_graph.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"title": "Get issue relationship graph",
44
"readOnlyHint": true
55
},
6-
"description": "Get a graph representation of an issue or pull request and its related issues/PRs.\n\nThis tool helps understand the relationships between issues and PRs in a repository, especially useful for:\n- Understanding the scope of work for an issue or PR\n- Planning implementation for a task that's part of a larger epic\n- Identifying blockers or dependencies\n- Finding related work that might conflict or overlap\n- Understanding why a piece of work exists (tracing to parent epic)\n\nThe graph shows:\n- Node types: epic (large initiatives), batch (parent issues), task (regular issues), pr (pull requests)\n- Parent/child relationships from sub-issues and \"closes/fixes\" references\n- Related issues mentioned in bodies\n\nCall this tool early when working on an issue to gather appropriate context about the work hierarchy.",
6+
"description": "Get a graph representation of an issue or pull request and its related issues/PRs.\n\nThis tool helps understand the relationships between issues and PRs in a repository, especially useful for:\n- Understanding the scope of work for an issue or PR\n- Planning implementation for a task that's part of a larger epic\n- Identifying blockers or dependencies\n- Finding related work that might conflict or overlap\n- Understanding why a piece of work exists (tracing to parent epic)\n\nThe graph shows:\n- Node types: epic (large initiatives), batch (parent issues), task (regular issues), pr (pull requests)\n- Parent/child relationships from sub-issues and \"closes/fixes\" references\n- Related issues mentioned in bodies\n\nCall this tool early when working on an issue to gather appropriate context about the work hierarchy.\n\nWorks well with:\n- issue_read: After using issue_graph to identify important related issues, use issue_read to get full details of specific issues\n- pull_request_read: Use to get full PR details for PRs identified in the graph\n- search_issues: If the graph reveals related work areas, search for more issues in those areas\n- list_issues: List all issues in the repository to find additional context not captured in the graph",
77
"inputSchema": {
88
"properties": {
99
"issue_number": {

pkg/github/issue_graph.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818

1919
const (
2020
// MaxGraphDepth is the maximum depth to crawl for related issues
21-
// Reduced to 3 for performance (can be increased in future versions)
2221
MaxGraphDepth = 3
2322
// MaxConcurrentFetches is the maximum number of concurrent API calls
2423
MaxConcurrentFetches = 5
@@ -449,6 +448,7 @@ func (gc *graphCrawler) crawl(ctx context.Context) error {
449448
current := queue[0]
450449
queue = queue[1:]
451450

451+
// Skip if beyond max depth (shouldn't happen, but defensive check)
452452
if current.depth > MaxGraphDepth {
453453
continue
454454
}
@@ -477,8 +477,8 @@ func (gc *graphCrawler) crawl(ctx context.Context) error {
477477
continue
478478
}
479479

480-
// Don't crawl further if at max depth
481-
if current.depth >= MaxGraphDepth {
480+
// Don't crawl further from nodes at max depth (they are leaf nodes for crawling)
481+
if current.depth == MaxGraphDepth {
482482
continue
483483
}
484484

@@ -541,9 +541,6 @@ func (gc *graphCrawler) crawl(ctx context.Context) error {
541541
continue
542542
}
543543
subNumber := *subIssue.Number
544-
if subNumber == 0 {
545-
continue
546-
}
547544
subKey := nodeKey(current.owner, current.repo, subNumber)
548545

549546
// This node is parent of sub-issue
@@ -802,7 +799,13 @@ The graph shows:
802799
- Parent/child relationships from sub-issues and "closes/fixes" references
803800
- Related issues mentioned in bodies
804801
805-
Call this tool early when working on an issue to gather appropriate context about the work hierarchy.`)),
802+
Call this tool early when working on an issue to gather appropriate context about the work hierarchy.
803+
804+
Works well with:
805+
- issue_read: After using issue_graph to identify important related issues, use issue_read to get full details of specific issues
806+
- pull_request_read: Use to get full PR details for PRs identified in the graph
807+
- search_issues: If the graph reveals related work areas, search for more issues in those areas
808+
- list_issues: List all issues in the repository to find additional context not captured in the graph`)),
806809
mcp.WithToolAnnotation(mcp.ToolAnnotation{
807810
Title: t("TOOL_ISSUE_GRAPH_USER_TITLE", "Get issue relationship graph"),
808811
ReadOnlyHint: ToBoolPtr(true),

pkg/github/issue_graph_test.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"net/http"
7+
"strings"
78
"testing"
89
"time"
910

@@ -415,9 +416,9 @@ func TestIssueGraphWithSubIssues(t *testing.T) {
415416
path := r.URL.Path
416417
var issue *github.Issue
417418
switch {
418-
case contains(path, "/101"):
419+
case strings.Contains(path, "/101"):
419420
issue = subIssue1
420-
case contains(path, "/102"):
421+
case strings.Contains(path, "/102"):
421422
issue = subIssue2
422423
default:
423424
issue = parentIssue
@@ -432,7 +433,7 @@ func TestIssueGraphWithSubIssues(t *testing.T) {
432433
requestCount++
433434
// Return sub-issues only for the parent issue
434435
path := r.URL.Path
435-
if contains(path, "/100/") {
436+
if strings.Contains(path, "/100/") {
436437
w.WriteHeader(http.StatusOK)
437438
_, _ = w.Write([]byte(subIssuesJSON))
438439
} else {
@@ -470,17 +471,3 @@ func TestIssueGraphWithSubIssues(t *testing.T) {
470471
assert.Contains(t, textContent.Text, "#100")
471472
assert.Contains(t, textContent.Text, "Parent Issue")
472473
}
473-
474-
// Helper function to check if path contains substring
475-
func contains(s, substr string) bool {
476-
return len(s) >= len(substr) && (s == substr || len(s) > 0 && containsSubstr(s, substr))
477-
}
478-
479-
func containsSubstr(s, substr string) bool {
480-
for i := 0; i <= len(s)-len(substr); i++ {
481-
if s[i:i+len(substr)] == substr {
482-
return true
483-
}
484-
}
485-
return false
486-
}

0 commit comments

Comments
 (0)