Repository navigation
[codex] Add public PKCE MCP OAuth clients - #8516
Merged
Merged
Conversation
There was a problem hiding this comment.
2 issues found across 4 files
Confidence score: 4/5
- In
backend/database/mcp_oauth.py, the dict-based registry can let a nestedclient_idoverride the configured map key, soget_client(<configured key>)may fail and a different client ID may be enabled instead; normalize/validate entries so the registry key is authoritative before merging. - In
backend/routers/mcp_sse.py, the duplicateget_daily_summariesscope key is silently overwritten, which can hide mapping mistakes and make future auth-scope changes error-prone; remove the duplicate entry now to keep behavior explicit.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/routers/mcp_sse.py">
<violation number="1" location="backend/routers/mcp_sse.py:217">
P3: Remove duplicate `get_daily_summaries` entry; duplicate dict keys are ignored/overwritten and make scope mappings easier to misread.</violation>
</file>
<file name="backend/database/mcp_oauth.py">
<violation number="1" location="backend/database/mcp_oauth.py:113">
P2: Dict-shaped registry entries let nested `client_id` override the map key. This can make `get_client(<configured key>)` miss the client and unexpectedly enable the nested ID instead.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| entries = [] | ||
| for client_id, config in parsed.items(): | ||
| if isinstance(config, dict): | ||
| entries.append({"client_id": client_id, **config}) |
There was a problem hiding this comment.
P2: Dict-shaped registry entries let nested client_id override the map key. This can make get_client(<configured key>) miss the client and unexpectedly enable the nested ID instead.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/database/mcp_oauth.py, line 113:
<comment>Dict-shaped registry entries let nested `client_id` override the map key. This can make `get_client(<configured key>)` miss the client and unexpectedly enable the nested ID instead.</comment>
<file context>
@@ -35,13 +49,87 @@ def _csv_env(name: str) -> list[str]:
+ entries = []
+ for client_id, config in parsed.items():
+ if isinstance(config, dict):
+ entries.append({"client_id": client_id, **config})
+ elif isinstance(parsed, list):
+ entries = [config for config in parsed if isinstance(config, dict)]
</file context>
Suggested change
| entries.append({"client_id": client_id, **config}) | |
| entries.append({**config, "client_id": client_id}) |
| "get_chat_messages": "chat.read", | ||
| "get_people": "people.read", | ||
| "get_screen_activity": "screen_activity.read", | ||
| "get_daily_summaries": "conversations.read", |
There was a problem hiding this comment.
P3: Remove duplicate get_daily_summaries entry; duplicate dict keys are ignored/overwritten and make scope mappings easier to misread.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/routers/mcp_sse.py, line 217:
<comment>Remove duplicate `get_daily_summaries` entry; duplicate dict keys are ignored/overwritten and make scope mappings easier to misread.</comment>
<file context>
@@ -199,17 +205,29 @@ def invalid_mcp_auth_exception(
"get_chat_messages": "chat.read",
"get_people": "people.read",
"get_screen_activity": "screen_activity.read",
+ "get_daily_summaries": "conversations.read",
}
</file context>
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.
Summary
MCP_OAUTH_CLIENTS_JSONMCP_OAUTH_CHATGPT_*confidential-client path as isolated legacy compatibilitytoken_endpoint_auth_method=noneclient path for no-secret PKCE setupRollout goals
This supports both required states:
The generic JSON registry is intended for pre-registered Claude or other MCP connectors later; DCR/CIMD/private_key_jwt are not implemented in this PR.
Review
Oracle reviewed the setup against the two rollout goals and future connector compatibility. I fixed the two code-level findings before opening this PR:
"false"cannot accidentally create no-secret public clientsI also added a public refresh-token regression test and documented that rollout must use the exact provider callback URI, not just the older ChatGPT redirect URI.
Tests
cd backend && pytest tests/unit/test_mcp_oauth.py tests/unit/test_mcp_data_endpoints.py -qpython backend/scripts/scan_async_blockers.pyNote: the async scan exits 0 and still reports existing repo-wide findings outside the MCP OAuth files.