-
Notifications
You must be signed in to change notification settings - Fork 129
feat: support enterprise oauth transport config for hosted mcp servers #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OchnikBartek
wants to merge
1
commit into
main
Choose a base branch
from
fix/183
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,6 +60,14 @@ class MCPAuth: | |||||||||||||
| client_name: OAuth client name advertised during dynamic client | ||||||||||||||
| registration (``oauth`` only). Some servers (e.g. Figma's hosted MCP | ||||||||||||||
| during beta) allowlist this; leave ``None`` to use the default. | ||||||||||||||
| scopes: OAuth scopes to request up front (``oauth`` only). Some hosted | ||||||||||||||
| servers (e.g. Atlassian's) require explicit scopes at registration | ||||||||||||||
| instead of granting a default set. Cached tokens are namespaced per | ||||||||||||||
| scope set, so changing this forces a fresh authorization rather | ||||||||||||||
| than silently reusing a token minted under the old scopes. | ||||||||||||||
| callback_port: Fixed localhost port for the OAuth redirect URI | ||||||||||||||
| (``oauth`` only). Needed by servers that validate a pre-registered | ||||||||||||||
| redirect URI; ``None`` lets the client pick a free port. | ||||||||||||||
| """ | ||||||||||||||
|
|
||||||||||||||
| secret_key: str = "" | ||||||||||||||
|
|
@@ -69,10 +77,14 @@ class MCPAuth: | |||||||||||||
| value_template: str = "Bearer {token}" | ||||||||||||||
| instructions: str = "" | ||||||||||||||
| client_name: str | None = None | ||||||||||||||
| scopes: list[str] = field(default_factory=list) | ||||||||||||||
| callback_port: int | None = None | ||||||||||||||
|
|
||||||||||||||
| def __post_init__(self) -> None: | ||||||||||||||
| if self.kind in _SECRET_AUTH_KINDS and not self.secret_key: | ||||||||||||||
| raise MCPConfigError(f"{self.kind} MCP auth requires a non-empty secret_key") | ||||||||||||||
| if self.callback_port is not None and self.callback_port <= 0: | ||||||||||||||
| raise MCPConfigError(f"callback_port must be positive, got {self.callback_port}") | ||||||||||||||
|
Comment on lines
+86
to
+87
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: while you're validating, the upper bound is worth the same line.
Suggested change
|
||||||||||||||
| # Fail fast on a template that would raise at `render_value` time — | ||||||||||||||
| # extra placeholders (`{foo}`) or unbalanced literal braces (B13). | ||||||||||||||
| try: | ||||||||||||||
|
|
@@ -97,6 +109,8 @@ def from_dict(cls, data: dict[str, Any]) -> MCPAuth: | |||||||||||||
| value_template=data.get("value_template", "Bearer {token}"), | ||||||||||||||
| instructions=data.get("instructions", ""), | ||||||||||||||
| client_name=data.get("client_name"), | ||||||||||||||
| scopes=list(data.get("scopes", [])), | ||||||||||||||
| callback_port=data.get("callback_port"), | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right instinct — the silent fallback was the confusing part — but
logging.getLogger(__name__)is the wrong channel here, and it can make things worse than staying quiet.load_mcp_registry()is called from inside running Textual modals (apps/cli/modals/mcp_view.py:178,apps/cli/modals/info_view.py:97).apps.cli.mcp_storeisn't in_NOISY_CONSOLE_LOGGERS, so it propagates to root; root has no handler under the TUI, sologging.lastResortwrites the record straight to stderr — over the live screen. That's exactly whatquiet_console_logging()and the stdio log-file redirect exist to prevent. And the user who needs this message (repeated re-auth) still doesn't get anything actionable in the UI.The house pattern for CLI-side warnings is the session logger —
propagate=False, file handler, no screen corruption:Same for the second
logger.warningbelow. If you want the user to actually see it, the/mcpview already has a place to surface it — but the file log is the minimum and the safe default.