Skip to content

[codex] Add public PKCE MCP OAuth clients - #8516

Merged
Git-on-my-level merged 4 commits into
mainfrom
codex/mcp-public-pkce-oauth
Jun 28, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
codex/mcp-public-pkce-oauth

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jun 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add a provider-neutral MCP OAuth client registry via MCP_OAUTH_CLIENTS_JSON
  • keep the existing MCP_OAUTH_CHATGPT_* confidential-client path as isolated legacy compatibility
  • add a public token_endpoint_auth_method=none client path for no-secret PKCE setup
  • align advertised MCP tool scopes with grantable OAuth scopes and consent text
  • document the new config shape and exact provider callback allowlist requirement

Rollout goals

This supports both required states:

  1. ChatGPT app review can keep using confidential TEST creds for the designated tester account.
  2. Public users can connect Omi to ChatGPT without receiving or retrieving a shared client secret.

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:

  • expanded supported OAuth scopes so public/default clients can request scopes for the tools we advertise
  • hardened JSON client parsing so truthy strings like "false" cannot accidentally create no-secret public clients

I 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 -q
  • python backend/scripts/scan_async_blockers.py

Note: the async scan exits 0 and still reports existing repo-wide findings outside the MCP OAuth files.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Confidence score: 4/5

  • In backend/database/mcp_oauth.py, the dict-based registry can let a nested client_id override the configured map key, so get_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 duplicate get_daily_summaries scope 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})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@Git-on-my-level
Git-on-my-level merged commit 26712cf into main Jun 28, 2026
4 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/mcp-public-pkce-oauth branch June 28, 2026 22:10
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