Skip to content

⚡ Bolt: [Batch FeathersJS MCP OAuth Token Fetches] - #168

Open
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
jules-1360143747327675935-0dc222d7
Open

⚡ Bolt: [Batch FeathersJS MCP OAuth Token Fetches]#168
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
jules-1360143747327675935-0dc222d7

Conversation

@Donach

@Donach Donach commented Aug 3, 2026

Copy link
Copy Markdown

💡 What: Implemented a batched token retrieval method getTokensForServers in the UserMCPOAuthTokenRepository and refactored the injectPerUserOAuthTokens hook to pre-fetch all needed tokens using Drizzle's inArray prior to mapping.

🎯 Why: Previously, when fetching a list of MCP servers (like in a paginated find endpoint), the injectToken map function would execute an individual database lookup for each MCP server to inject its corresponding OAuth token. This caused an O(N) database query explosion (N+1 query issue).

📊 Impact: Severely reduces database round-trips from O(N) to O(1) for lists of MCP servers, lowering query latency, decreasing API response times, and reducing load on the database connection pool.

🔬 Measurement: Review database query logs or use performance monitoring when hitting the mcp-servers find endpoint. The number of SELECT queries for user_mcp_oauth_tokens will remain at exactly one query, regardless of how many MCP servers are returned in the response.


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

Resolves an N+1 query problem when injecting OAuth tokens into lists of MCP servers by utilizing `getTokensForServers()` in `UserMCPOAuthTokenRepository`. Instead of repeatedly querying for each server's token in `apps/agor-daemon/src/register-hooks.ts`, we now extract the relevant IDs and perform one batched fetch via `inArray`.
@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