[codex] Implement hosted MCP OAuth for ChatGPT#8508
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4b046cb45
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return urlunsplit((parts.scheme, parts.netloc, parts.path, urlencode(params), parts.fragment)) | ||
|
|
||
|
|
||
| @router.get("/authorize", response_class=HTMLResponse, tags=["mcp"]) |
There was a problem hiding this comment.
Use non-conflicting MCP OAuth paths
I checked backend/main.py: auth.router is included before mcp_sse.router, and backend/routers/auth.py already registers GET /authorize and POST /token. Starlette matches the earlier auth routes first, so ChatGPT's OAuth discovery will hit auth_authorize (422 for missing provider) and auth_token (looks for a main-app Redis auth code) instead of these MCP handlers, making the hosted MCP OAuth flow unusable until these endpoints are moved or the routing is disambiguated.
Useful? React with 👍 / 👎.
Addresses review feedback: - _now() returns datetime.now(timezone.utc) instead of naive utcnow(), preventing TypeError when comparing persisted Firestore timestamps (which decode as tz-aware UTC) against _now() in auth-code exchange, access-token validation, and refresh-token rotation. - list_user_grants sort fallback uses tz-aware datetime.min to stay consistent with persisted aware timestamps. - Add test_mcp_oauth.py to backend/test.sh per AGENTS.md requirement so the OAuth suite runs in CI.
49f4dab to
d90aa27
Compare
Review feedback addressed
Thread #1 — no route conflict exists (d90aa27)Codex claimed
Thread #2 — timezone-aware UTC datetimes (d90aa27)
Changed Thread #3 — OAuth tests added to CI runner (d90aa27)Added Verification
|
|
I looked into this and I don't think there's an actual route conflict here.
The I verified this statically across every router under
No |
|
Verified this concern against the actual route registration — there is no conflict, so no change is needed. Evidence:
The authorization-server metadata advertises Leaving this thread open since no code change is warranted. |
Summary
omi_mcp_...API-key auth working while preventing OAuth tokens from falling through legacy full-access helpers.Closes #8506
Validation
make setupbackend/test-preflight.sh(passes; optional dependency/env warnings only)python3 -m py_compile backend/database/mcp_oauth.py backend/routers/mcp_sse.py backend/routers/mcp.py backend/tests/unit/test_mcp_oauth.py backend/tests/unit/test_mcp_data_endpoints.pyblack --line-length 120 --skip-string-normalization backend/database/mcp_oauth.py backend/routers/mcp_sse.py backend/routers/mcp.py backend/tests/unit/test_mcp_oauth.py backend/tests/unit/test_mcp_data_endpoints.pygit diff --checkpytest backend/tests/unit/test_mcp_oauth.py backend/tests/unit/test_mcp_data_endpoints.py -q(28 passed)python3 backend/scripts/scan_async_blockers.py(no changed MCP files flagged; existing unrelated blockers remain elsewhere)Known unrelated failure
backend/test.shreaches existingtests/unit/test_speaker_sample.pyfailures becauseutils.speaker_sampledoes not exposedeepgram_prerecorded_from_bytesfor those monkeypatches; this is outside the MCP OAuth diff.