Repository navigation
feat(mcp): infer the open PR and GitHub metadata on hosted uploads - #1271
Conversation
The hosted MCP has no git, so agents had to pass repo plus pr or branch exactly, and anything less landed under misc/ with no GitHub link. - put and sign_upload_url with repo + branch now attach to that branch's one open PR when the repo is bound to the workspace (CLI #700 parity), looked up through the GitHub App. Fail-open, capped at 3 seconds. - PR/issue uploads on bound repos get gh.title; tagged uploads get the derived repo key, like the CLI. - An upload with no repo returns a hint to pass repo and branch from git, and the tool descriptions tell agents with a checkout to do so. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GUUmSuqWrQKpTQoqrtLeGy
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 2
🚫 Excluded labels (none allowed): 1
Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The rule this PR ships: if the repo is linked to your workspace, This is deliberately the same scope as staged-file auto-promotion, and
We're keeping the model simple on purpose, so no visibility or fork handling for now. Generated by Claude Code |
Requested by Zach · project thread
Why
The hosted MCP has no git, so it got none of the context the CLI infers from the working directory. Agents had to pass
repoplus exactly the rightprorbranch. Anything less landed underscreenshots/misc/<date>/with no GitHub link, and hosted uploads never gotgh.titleor the derivedrepokey.What changes (hosted MCP only)
putorsign_upload_urlgetsrepo+branchand nopr, the server asks GitHub through the App for open PRs with that head branch. If exactly one is open, the upload attaches to it as ifprwas passed.putkeepsbranchso it also promotes that branch's staged files.sign_upload_urldrops it and itsnextsays which PR was found. With no PR or several, it stages as before.gh.titleon PR/issue uploads, read from the shared member title cache.repometadata wheneverrepois passed. Like the CLI, it's only added to a metadata map that already exists, so a bare re-upload never wipes stored metadata.sign_upload_url'snext) tells the agent to passrepoandbranchfromgit remote get-url originandgit branch --show-current. The tool descriptions say the same thing.Safety: the lookups only run for repos bound to the calling workspace (
repo_link_status= self), so a workspace never learns PR numbers or titles for a repo that isn't its own. They fail open and are capped at 3 seconds, so a slow GitHub falls back to today's behavior.New module
apps/api/src/github-pull-context.ts(exported as@uploads/api/github-pull-context) holds the binding check, the open-PR lookup and the title read. The github-screenshots skill (plus its plugin copy) and the docs tool catalog are updated.Testing
apps/mcp/test/mcp-branch-promote.test.ts:branchresolves to the one open PR, with comment,gh.title,repoand the hint.prgetsgh.title.sign_upload_urlsigns and then PUTs end to end to the PR key with the title.pnpm --filter @uploads/mcp test(168 passed),pnpm --filter @uploads/api test(3503 passed), and typecheck for both.putwithrepo+branchagainst an open PR in a bound repo.Generated by Claude Code