Skip to content

⚡ Bolt: Batch MCP OAuth Token resolution - #161

Open
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
bolt-batch-mcp-oauth-token-queries-10492137682816094658
Open

⚡ Bolt: Batch MCP OAuth Token resolution#161
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
bolt-batch-mcp-oauth-token-queries-10492137682816094658

Conversation

@Donach

@Donach Donach commented Jul 30, 2026

Copy link
Copy Markdown

💡 What: Refactored injectPerUserOAuthTokens in apps/agor-daemon/src/register-hooks.ts to pre-fetch both shared and per-user MCP OAuth tokens using a single batch database query via a new getTokensForServers method on UserMCPOAuthTokenRepository. The results are indexed in an in-memory Map with compound keys (${serverId}:${userId | 'shared'}) for instant lookup.
🎯 Why: Previously, listing MCP servers resulted in N+1 database queries due to individual await userTokenRepo.getToken(...) calls inside a Promise.all loop. This caused significant latency on endpoints fetching large sets of tools/servers.
📊 Impact: Reduces database latency and connections by eliminating N+1 DB roundtrips. N queries are replaced with exactly 1 query, improving endpoint performance linearly relative to the number of returned servers.
🔬 Measurement: Verify by monitoring database query logs or tracing endpoint latency when querying find on the mcp-servers or session-mcp-servers endpoints.


PR created automatically by Jules for task 10492137682816094658 started by @Donach

Batch resolves MCP OAuth tokens using an in-memory Map initialized via a single `getTokensForServers` database query to eliminate N+1 latency in `mcp-servers` and `session-mcp-servers` API endpoints.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant