-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Suggested Changes for github-pr-review-mcp-server
1) Security & Input Validation
- Call
validate_repo_params(owner, repo, branch)at the start ofresolve_pr_url. - Replace regex-only PR URL parsing with
urllib.parse.urlparse:- Require
https. - Allow optional trailing slash / query.
- Ensure path matches
/OWNER/REPO/pull/NUMBER. - Reject hosts not in
GITHUB_HOSTSenv allowlist.
- Require
- Replace
shlex.quotewithhttpxparams=for REST queries. - Loosen
validate_comment: acceptline,original_line,position,original_position.
2) GitHub API Robustness
- Use modern headers everywhere:
Accept: application/vnd.github+jsonX-GitHub-Api-Version: 2022-11-28User-Agent: mcp-pr-review-spec-maker/1.0
- Normalize env vars:
GITHUB_API_URLfor REST base.GITHUB_GRAPHQL_URLoptional override.GH_HOSTfor HTML host (defaultgithub.com).
- Detect secondary rate limits (403/429 “abuse detection”):
- Back off ~60s and retry once.
- Expand 5xx retry backoff ceiling to ~15s.
3) Pagination & Large Repos
- Add
_get_all_open_prshelper:- Use
per_page=100, followLinkheaders up to 5 pages. - Pre-compile
LINK_NEXT_RE = re.compile(r'<([^>]+)>\s*;\s*rel="next"').
- Use
4) Logging & Redaction
- Add a logging filter to redact:
AuthorizationheadersGITHUB_TOKEN- Any
*_TOKEN
- Move
load_dotenv()andlogging.basicConfig()underif __name__ == "__main__":. - Prefer
logger.debug()overprint()except for user-visible progress.
5) MCP Best Practices
- Tool schemas:
- Add
format: "uri"topr_url. - Keep
required: []where mutually exclusive inputs exist (e.g.,markdownvscomments).
- Add
- Yield cooperatively (
await asyncio.sleep(0)) in loops for cancellation.
6) URL & Remote Parsing
- Allow dots in repo names by updating
REMOTE_REGEXESto capture[^/]+?. _get_reposhould raiseValueError(f"Not a git repository: {path}").- Standardize module name (
git_pr_resolver.pyvsgithub_pr_resolver.py).
7) Testing Plan
- Unit tests (mocked HTTP with
pytest-httpx/respx):- PR URL parsing (valid/invalid).
- Repo param validation.
- GraphQL happy path and error fallback.
- Pagination across multiple pages.
- 403/429 rate-limit handling.
- File writing (reject symlinks, bad names).
- Property tests (hypothesis):
- Filenames matching regex.
- Comment dicts with different line/position keys.
- Integration tests (skip unless
GITHUB_TOKENset):- Resolve PR + generate markdown on a small PR.
- CI:
ruff check,ruff format --check.mypy --strict.pytest --covwith ≥90% threshold.
8) Optional Enhancements
- Combine review + issue comments when requested.
- Support ETag caching with
If-None-Match. - Extend
User-Agentwith version and host (e.g.,(+host=github.com)).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels