Add bounded GitHub file excerpt MCP wrapper#50684
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Cross-repository defaults, special-character paths, and end-only line ranges currently produce incorrect behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Adds a bounded GitHub file-content wrapper to reduce unnecessary MCP response tokens.
Changes:
- Adds byte- and line-bounded file excerpts.
- Adopts the wrapper in structural analysis.
- Adds focused wrapper tests and recompiles workflows.
File summaries
| File | Description |
|---|---|
.github/workflows/shared/github-mcp-pagination-wrappers.md |
Defines and documents the wrapper. |
.github/workflows/github-mcp-structural-analysis.md |
Uses bounded excerpts. |
.github/workflows/github-mcp-structural-analysis.lock.yml |
Recompiled workflow. |
.github/workflows/deep-report.lock.yml |
Recompiled imported wrapper. |
pkg/workflow/mcp_scripts_shared_wrappers_test.go |
Tests schema and bounded output. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Balanced
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| OWNER="${INPUT_OWNER:-}" | ||
| REPO="${INPUT_REPO:-}" | ||
| PATH_IN_REPO="${INPUT_PATH:-}" | ||
| REF="${INPUT_REF:-${GITHUB_SHA:-}}" |
| BYTE_END=$((BYTE_OFFSET + MAX_BYTES)) | ||
| export OWNER REPO PATH_IN_REPO REF BYTE_OFFSET MAX_BYTES START_LINE END_LINE | ||
| gh api \ | ||
| --method GET \ | ||
| -H "Accept: application/vnd.github.raw" \ | ||
| -H "Range: bytes=${BYTE_OFFSET}-${BYTE_END}" \ | ||
| "repos/${OWNER}/${REPO}/contents/${PATH_IN_REPO}" \ | ||
| -f "ref=${REF}" > "$RAW_FILE" |
| if start_line: | ||
| line_start = int(start_line) | ||
| line_end = int(end_line) if end_line else line_start + 99 | ||
| lines = text.splitlines(keepends=True) | ||
| text = "".join(lines[line_start - 1:line_end]) |
|
@copilot please review the latest PR feedback, refresh this branch if it is behind
Run: https://github.com/github/gh-aw/actions/runs/31052246569
|
…line filtering; sort actions-lock containers Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed all three review issues and fixed the CI failures:
|
GitHub MCP
get_file_contentsonly returns whole files, which makes large README-style reads expensive when agents need only a small section. This adds a reusable bounded-read wrapper for workflows that need targeted file context.MCP script wrapper
get_file_contents_excerpttoshared/github-mcp-pagination-wrappers.md.byteOffset,maxBytes,startLine, andendLine.gh apiwith a byteRangeheader, then optionally filters lines before returning JSON.Workflow adoption
get_file_contents.Coverage
gh apiresponse.Example:
Run: https://github.com/github/gh-aw/actions/runs/31052246569> Generated by 👨🍳 PR Sous Chef · gpt54 · 5.39 AIC · ⌖ 7.13 AIC · ⊞ 8.3K · ◷