Repository navigation
fix(github-mcp): return the issue or PR together with its comments - #19
Merged
Merged
Conversation
Run without a terminal, `gh issue view --comments` and `gh pr view --comments` print only the comment list and skip the preview. issue_view with with_comments and pr_view with comments passed that flag, so they returned the comments without the title, body, or metadata, and empty output for an item without comments, although both schema descriptions promise the comments in addition to the item. A new _gh_view_with_comments helper runs the view once for the preview and once with `--comments`, then appends the comments after a `--- comments ---` line, or `--- comments and reviews ---` for a PR, because gh's PR list includes reviews. The second call always runs because gh's PR preview prints no comment count to decide on. A failure of either call fails the tool call or returns fallback, never the preview on its own. REFERENCE.md describes the separator lines for both tools. Co-Authored-By: Claude <noreply@anthropic.com>
_gh_view_with_comments captured each call's stderr together with its stdout, so without suppress_errors a gh warning on an item without comments produced a `--- comments ---` line followed by the warning. Both calls now go through _gh_capture_split: the separator depends on the comments output alone, a warning on a successful call is dropped as in the other tools that capture stderr apart, and a failed call reports its stderr. The helper no longer takes suppress_errors, since the callers already decide whether to print a failure. It logs the --comments call, which the server log left out. The schema descriptions of with_comments and comments now name the separator, the reviews in a PR's list, and that max_lines counts the item and its comments together. REFERENCE.md corrects the with_field_values case and lists the known limits of the two calls: a comment count that can disagree with the list, hidden comments gh leaves out, and a separator a body can contain. New tests cover a warning on an item without comments, a failed first call that skips the comments call, fallback when the comments call fails, the number and --repo reaching the comments call, and fields turning the flag off. Co-Authored-By: Claude <noreply@anthropic.com>
pi's tool_search adds each tool's parameter descriptions to its search text. The new description of pr_view's comments repeated "comments" and "reviews", so pr_comments ranked 6th and pr_reviews 4th, past the limits tool-search-ranking.test.ts allows (5th and 3rd). The description in tools-read.json now names those words once at most and leaves the separator text and the reviews to REFERENCE.md. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17.
Run without a terminal,
gh issue view --commentsandgh pr view --commentsprint only the comment list and return before the preview (pkg/cmd/issue/view/view.go,pkg/cmd/pr/view/view.goin cli/cli).issue_viewwithwith_comments: trueandpr_viewwithcomments: truepassed that flag, so they returned the comments without the title, body, or metadata, and nothing at all for an item without comments, although both schema descriptions promise the comments in addition to the item.Changes
_gh_view_with_comments(lib/common.sh): runs the view once for the preview and once with--comments, then appends the comments after a--- comments ---line, or--- comments and reviews ---for a PR, because gh's PR list includes reviews. With no comments, the result is the preview alone. Both calls go through_gh_capture_split, so a gh warning on stderr never counts as a comment; a failed call reports its stderr. The--commentscall is logged.fallback. It never returns the item without its comments, which would read as an item that has none.max_linescounts the item and its comments together, like on every other tool. Before, it applied to the comments alone, because the preview was missing.with_commentsandcommentsname the separator, the reviews, and themax_linesbehavior.REFERENCE.mddescribes the same and lists the known limits.Known limits
The item and its comments come from two gh calls, not one
--json …,commentscall rendered with jq. That keeps gh's own text format, and costs these:comments:count disagree with the list.