Repository navigation
fix(mcp): support OAuth for organization MCP server listings (OHE-3861) - #1140
Merged
hieptl merged 4 commits intoNov 3, 2026
Merged
Conversation
Organization MCP server listings rejected oauth2 credentials outright.
Both management kinds now accept them:
- An organization-managed listing must be authorized by the admin before
it is saved. Its tokens are stored on the listing, encrypted, and every
member launches with them.
- A user-managed listing stores only the OAuth client settings. Each
member authorizes with their own account through the new PUT and DELETE
/api/organizations/{org_id}/mcp-servers/{name}/connection routes. The
tokens live on org_member.org_mcp_oauth_states (migration 212) and join
the listing at launch; a member who has not connected does not get the
server.
Tokens and the client secret never reach the browser. An OAuth start that
names a listing restores its client secret but not its stored tokens, so
it always needs fresh consent, and that flow's status omits oauth_state.
The organization routes read the tokens server-side from the finished job
after checking its owner and URL.
A member's tokens stop applying when an admin changes the listing's URL or
client ID, and deleting a listing removes them. The sandbox write-back
webhook falls back to the listings of the sandbox's organization, on the
listing or on the owner's row, and ignores owners who left that org.
Contributor
|
|
2 of 6 tasks
hieptl
marked this pull request as ready for review
November 3, 2026 11:38
…on routes (OHE-3861) The service account guard requires every mutating route to say whether a service account key may call it. The PUT and DELETE connection routes store or forget the caller's own OAuth tokens for a user-managed listing, like the account-level key and secret routes, and a service account cannot complete an OAuth sign-in anyway, so both now reject service account keys.
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…-oauth-for-organization-mcp-servers
hieptl
deleted the
hiep/ohe-3861-restore-oauth-for-organization-mcp-servers
branch
November 3, 2026 13:19
Contributor
|
🚀 Released in 1.85.0. |
2 of 6 tasks
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.
HUMAN:
AGENT:
Why
Organization MCP server listings (OHE-3091) reject OAuth:
server/routes/org_mcp_servers.pyanswers 422 "OAuth-authenticated MCP servers cannot be shared with the organization yet". Servers that only support OAuth cannot be offered to an organization at all. This support was built on top of #1121 but was not part of it when it merged.Summary
PUTandDELETE /api/organizations/{org_id}/mcp-servers/{name}/connectionroutes. Tokens live onorg_member.org_mcp_oauth_states(migration 212) and join the listing at launch; a member who has not connected does not get the server.Issue Number
OHE-3861 (OHE-3091). The UI is in #1141.
How to Test
uv run --group test pytest \ tests/unit/server/routes/test_org_mcp_servers.py \ tests/unit/storage/test_org_mcp_servers_store.py \ tests/unit/app_server/test_mcp_oauth_router.py \ tests/unit/app_server/test_webhook_router_mcp_oauth_state.py \ tests/unit/app_server/test_live_status_app_conversation_service.py \ tests/unit/test_agent_profiles.py510 tests pass (the store tests start Postgres through Docker).
ruff0.12.5, the version pre-commit pins, is clean, and mypy reports nothing new on the touched files.It also runs on shared-5 together with the UI PR and the OHE-3866 fixes: the connection route is mounted and answers 401 when signed out. I have not yet signed in with a real OAuth provider there.
Video/Screenshots
Backend only. Screenshots of the UI are in #1141.
Type
Notes
212_add_org_member_org_mcp_oauth_statesadds a nullableorg_member.org_mcp_oauth_statescolumn (encrypted, stored as a string), with no backfill.Enterprise server image for this PR: