MCP OAuth discovery requests have no per-request timeout
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- cli
Research direction
Start with the three unbounded fetch calls: fetchProtectedResourceMetadata and fetchAuthorizationServerMetadata in packages/core/src/mcp/oauth-utils.ts, and the WWW-Authenticate probe in packages/core/src/mcp/oauth-provider.ts. Compare them with the HEAD probe in packages/core/src/tools/mcp-client.ts, which already passes signal: AbortSignal.timeout(5000). Add a similar signal to each call and assert it in oauth-utils.test.ts, where fetch is mocked. Done when every discovery request has a bounded timeout and the tests check that the signal is passed.
Written by the indexing model from the issue text.
Description
What happened?
The MCP OAuth discovery requests have no per-request deadline. OAuthUtils.fetchProtectedResourceMetadata and OAuthUtils.fetchAuthorizationServerMetadata call fetch(validatedUrl) with no signal:
- https://github.com/google-gemini/gemini-cli/blob/eecccfcd5aff25de5e78135ca20f7abe3f566955/packages/core/src/mcp/oauth-utils.ts#L281
- https://github.com/google-gemini/gemini-cli/blob/eecccfcd5aff25de5e78135ca20f7abe3f566955/packages/core/src/mcp/oauth-utils.ts#L318
and the WWW-Authenticate probe in MCPOAuthProvider does the same:
The only bound left is the global undici dispatcher from packages/core/src/utils/fetch.ts (60 s headers timeout, 5 min body timeout). Discovery runs these requests one after another: the protected resource metadata (path-based, then root-based), then up to five authorization server well-known endpoints in discoverAuthorizationServerMetadata. Every URL comes from the MCP server or its metadata. If that host accepts the connection and never answers, OAuth setup for that server waits up to 60 s per URL before moving on, so several minutes in the worst case, before it reports anything.
The HEAD probe in mcp-client.ts already uses signal: AbortSignal.timeout(5000) for the same kind of request (https://github.com/google-gemini/gemini-cli/blob/eecccfcd5aff25de5e78135ca20f7abe3f566955/packages/core/src/tools/mcp-client.ts#L2048-L2054), so the OAuth path looks like it was missed rather than intentionally unbounded.
What did you expect to happen?
Each discovery request fails fast (a few seconds, like the probe in mcp-client.ts) and discovery moves on to the next well-known URL or reports that OAuth discovery failed.
Client information
Found by reading main at eecccfcd5aff25de5e78135ca20f7abe3f566955. Not reproduced against a live server yet; it can be reproduced with an MCP server URL that answers 401 with a WWW-Authenticate: Bearer resource_metadata="..." header whose metadata URL points at a host that accepts the connection and never responds.
Login information
Not relevant (MCP server OAuth, not Gemini login).
Anything else we need to know?
Adding signal: AbortSignal.timeout(...) to the three calls above is the minimal fix, and the existing tests in oauth-utils.test.ts mock fetch, so the signal can be asserted there. I'm happy to send a PR for this once the issue is triaged.
- Dominant language
- TypeScript
- Stars
- 109k
- Forks
- 15k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 106
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google-gemini/gemini-cli
-
--acp never answers initialize when a sandbox is enabled (stdin read as a piped prompt before the sandbox hop)Possibly taken @Raamia claimed this 1 day ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-gemini/gemini-cli#30398 · 2 comments ·
Maintainers usually reply within 1 day
-
** Docs: `/shells` slash command (and `/bashes`) is documented but was removed in #22740 — tutorial and tip tell users to run a command that doesn't existPossibly taken @DZH166 claimed this 1 day ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30396 · 2 comments ·
Maintainers usually reply within 1 day
-
** Docs: System Prompt Override guide links "Persisting Environment Variables" to an anchor that does not exist in authentication.mdxPossibly taken @DZH166 claimed this 1 day ago. Openstatus/need-triage
Difficulty 1/5 Under an hour Newbie friendliness 82/100
google-gemini/gemini-cli#30394 · 2 comments ·
Maintainers usually reply within 1 day
-
core tests: orphan PTY slave fd test fails on Macs where /dev/ttys001 existsPossibly taken @Anoshor claimed this 2 days ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-gemini/gemini-cli#30384 · 2 comments ·
Maintainers usually reply within 1 day
-
cli tests: gemini.test.tsx fails locally unless GEMINI_CLI_TRUST_WORKSPACE is setPossibly taken @Anoshor claimed this 2 days ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
google-gemini/gemini-cli#30383 · 3 comments ·
Maintainers usually reply within 1 day
All issues in google-gemini/gemini-cli
Similar issues
-
bug done
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neavo/LinguaGacha#1124 ·
Maintainers usually reply within 1 day
-
[fullsend] E2E: backstage-microsoft-auth — catalogQuery missing error handler for network errorsPossibly taken @fullsend-ai-coder claimed this today. Opene2e-failure ready-to-code
Difficulty 2/5 Under an hour Newbie friendliness 78/100
redhat-developer/rhdh-plugin-export-overlays#4821 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
brylie/mission-island#225 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sagemathinc/sagebrush#1683 ·
Maintainers usually reply within 1 day