refactor(github): use App installation token + bot identity in mesh consumers#3196
Open
refactor(github): use App installation token + bot identity in mesh consumers#3196
Conversation
The mcp-github connection's downstream token is an App installation token; calls to GET /user no longer reflect a real user. Replace the on-the-fly fetch with hardcoded bot constants matching the App's bot account, and add unit tests covering happy path, proactive refresh, refresh failure, and missing-token cases. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ion/repositories The downstream token is an App installation token, so /user/installations no longer applies. Synthesize a single-installation summary from the installation's first repo owner; preserve the output shape so the repo-picker UI stays unchanged. Pagination is removed — the App is bound to one installation, so one repo's owner suffices. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The throw-only fetch stub returns Promise<never>, which doesn't structurally overlap with typeof fetch. Use double cast and match the two-param signature used by sibling tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Contributor
Release OptionsSuggested: Patch ( React with an emoji to override the release type:
Current version:
|
knip flagged MCP_GITHUB_BOT_NAME / MCP_GITHUB_BOT_EMAIL as unused exports. They are only consumed inside github-clone-info.ts; remove the export keyword instead of silencing knip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nstallation/repositories" This reverts commit a332445.
…installation/repositories" This reverts commit 6d52b28.
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.
What is this contribution about?
Refactors Mesh's GitHub consumer code to rely on the App installation token already stored in the
mcp-githubconnection's downstream token, dropping all uses of the user's GitHub identity. Themcp-githubconnection model and storage are unchanged — only consumer call sites are touched.Two surfaces change:
apps/mesh/src/shared/github-clone-info.tsno longer fetchesGET /userto populate git committer name/email; it returns hardcoded bot identity (mcp-github[bot]+ the matchingusers.noreply.github.comemail). Daemon clones are now committed by the App's bot, decoupled from whoever connected GitHub.apps/mesh/src/tools/github/list-user-orgs.tsswapsGET /user/installationsforGET /installation/repositoriesand synthesizes a single-installation summary from the first repo's owner. The output schema is preserved so the existing repo-picker UI keeps working without changes.How to Test
mcp-githubconnection is connected at the org level.VM_START(sandbox provisioning) flow that exercisesbuildCloneInfo— confirmgit config user.nameinside the daemon showsmcp-github[bot]andgit config user.emailshowsmcp-github[bot]@users.noreply.github.com.search_repositoriesflow.bun test apps/mesh/src/shared/github-clone-info.test.ts apps/mesh/src/tools/github/list-user-orgs.test.ts— 12 tests pass.Migration Notes
No database, schema, or config migration. Hard cutover at the consumer layer: any pre-existing per-user
mcp-githubconnection rows are inert under the new code (consumers no longer need user-scoped tokens). Org admins do not need to reconnect — the samemcp-githubconnection's downstream token is now interpreted as an App installation token end-to-end.Review Checklist
github-clone-info.test.ts+ updatedlist-user-orgs.test.ts)Summary by cubic
Refactors GitHub consumers to use the App installation token end-to-end. Commits now use the bot identity, and org/repo selection reads from the installation’s repositories. No changes to the
mcp-githubconnection model.Refactors
buildCloneInfo: dropsGET /user; commits usemcp-github[bot]withmcp-github[bot]@users.noreply.github.com. Proactively refreshes expired tokens and throwsRECONNECT_ERRORwhen needed.GITHUB_LIST_USER_ORGS: swapsGET /user/installationsforGET /installation/repositories?per_page=1; synthesizes a single-install summary from the first repo’s owner; preserves output shape; proactive refresh and 401 retry withRECONNECT_ERRORon failure.Bug Fixes
Written for commit 2d33fcf. Summary will update on new commits. Review in cubic