Skip to content

feat(mcp): infer the open PR and GitHub metadata on hosted uploads - #1271

Merged
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/project-thread-q1oxjo
Oct 22, 2026
Merged

Zach Dunn (zachdunn) merged 1 commit into
mainfrom
claude/project-thread-q1oxjo

Conversation

@zachdunn

Copy link
Copy Markdown
Member

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 repo plus exactly the right pr or branch. Anything less landed under screenshots/misc/<date>/ with no GitHub link, and hosted uploads never got gh.title or the derived repo key.

What changes (hosted MCP only)

  • Open PR from repo + branch (CLI CLI: PR-aware upload context — concrete nudge, auto-default, and post-PR promote hint #700 parity). When put or sign_upload_url gets repo + branch and no pr, 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 if pr was passed. put keeps branch so it also promotes that branch's staged files. sign_upload_url drops it and its next says which PR was found. With no PR or several, it stages as before.
  • gh.title on PR/issue uploads, read from the shared member title cache.
  • Derived repo metadata whenever repo is passed. Like the CLI, it's only added to a metadata map that already exists, so a bare re-upload never wipes stored metadata.
  • Hint when there's no repo. The upload result (and sign_upload_url's next) tells the agent to pass repo and branch from git remote get-url origin and git 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

  • New tests in apps/mcp/test/mcp-branch-promote.test.ts:
    • branch resolves to the one open PR, with comment, gh.title, repo and the hint.
    • An explicit pr gets gh.title.
    • Two open PRs still stage.
    • A repo bound to another workspace never calls GitHub.
    • sign_upload_url signs and then PUTs end to end to the PR key with the title.
    • An upload with no repo returns the hint.
  • pnpm --filter @uploads/mcp test (168 passed), pnpm --filter @uploads/api test (3503 passed), and typecheck for both.
  • Not yet verified live. Once deployed, try put with repo + branch against an open PR in a bound repo.

Generated by Claude Code

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
@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cb29aeb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@zachdunn Zach Dunn (zachdunn) self-assigned this Oct 22, 2026
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 2
  • coderabbit:review
  • review
🚫 Excluded labels (none allowed): 1
  • wip

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c1a3c04-294f-457a-a058-5659bc8ac84d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Member Author

The rule this PR ships: if the repo is linked to your workspace, branch finds the open PR. Otherwise, pass pr.

This is deliberately the same scope as staged-file auto-promotion, and repo_link_status already reports whether a repo is linked. Explicit pr + repo still works on any repo. The PR lookup skips two cases, and passing pr covers both:

  • Public repos that aren't linked. PR numbers there are already public, but a second rule isn't worth having.
  • PRs from forks. The lookup only matches owner:branch in the repo itself.

We're keeping the model simple on purpose, so no visibility or fork handling for now.


Generated by Claude Code

@zachdunn
Zach Dunn (zachdunn) merged commit ecf8252 into main Oct 22, 2026
3 checks passed
@zachdunn
Zach Dunn (zachdunn) deleted the claude/project-thread-q1oxjo branch October 22, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants