nvidia-nat-mcp 1.4.0a20251015__py3-none-any.whl → 1.4.0a20251022__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nat/plugins/mcp/auth/auth_flow_handler.py +64 -0
- {nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/METADATA +2 -2
- {nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/RECORD +8 -8
- {nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/WHEEL +0 -0
- {nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/entry_points.txt +0 -0
- {nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/top_level.txt +0 -0
|
@@ -54,6 +54,9 @@ class MCPAuthenticationFlowHandler(ConsoleAuthenticationFlowHandler):
|
|
|
54
54
|
self._redirect_app: FastAPI | None = None
|
|
55
55
|
self._server_lock = asyncio.Lock()
|
|
56
56
|
self._oauth_client: AsyncOAuth2Client | None = None
|
|
57
|
+
self._redirect_host: str = "localhost" # Default host, will be overridden from config
|
|
58
|
+
self._redirect_port: int = 8000 # Default port, will be overridden from config
|
|
59
|
+
self._server_task: asyncio.Task | None = None
|
|
57
60
|
|
|
58
61
|
async def authenticate(self, config: AuthProviderBaseConfig, method: AuthFlowType) -> AuthenticatedContext:
|
|
59
62
|
"""
|
|
@@ -88,6 +91,34 @@ class MCPAuthenticationFlowHandler(ConsoleAuthenticationFlowHandler):
|
|
|
88
91
|
async def _handle_oauth2_auth_code_flow(self, cfg: OAuth2AuthCodeFlowProviderConfig) -> AuthenticatedContext:
|
|
89
92
|
logger.info("Starting MCP OAuth2 authorization code flow")
|
|
90
93
|
|
|
94
|
+
# Extract and validate host and port from redirect_uri for callback server
|
|
95
|
+
from urllib.parse import urlparse
|
|
96
|
+
parsed_uri = urlparse(str(cfg.redirect_uri))
|
|
97
|
+
|
|
98
|
+
# Validate scheme/host and choose a safe non-privileged bind port
|
|
99
|
+
scheme = (parsed_uri.scheme or "http").lower()
|
|
100
|
+
if scheme not in ("http", "https"):
|
|
101
|
+
raise ValueError(f"redirect_uri must use http or https scheme, got '{scheme}'")
|
|
102
|
+
|
|
103
|
+
host = parsed_uri.hostname
|
|
104
|
+
if not host:
|
|
105
|
+
raise ValueError("redirect_uri must include a hostname, for example http://localhost:8000/auth/redirect")
|
|
106
|
+
|
|
107
|
+
# Never auto-bind to 80/443; default to 8000 when port is not specified
|
|
108
|
+
port = parsed_uri.port or 8000
|
|
109
|
+
if not (1 <= port <= 65535):
|
|
110
|
+
raise ValueError(f"Invalid redirect port: {port}. Expected 1-65535.")
|
|
111
|
+
|
|
112
|
+
if scheme == "https" and parsed_uri.port is None:
|
|
113
|
+
logger.warning(
|
|
114
|
+
"redirect_uri uses https without an explicit port; binding to %d (plain HTTP). "
|
|
115
|
+
"Terminate TLS at a reverse proxy and forward to this port.",
|
|
116
|
+
port)
|
|
117
|
+
|
|
118
|
+
self._redirect_host = host
|
|
119
|
+
self._redirect_port = port
|
|
120
|
+
logger.info("MCP redirect server will use %s:%d", self._redirect_host, self._redirect_port)
|
|
121
|
+
|
|
91
122
|
state = secrets.token_urlsafe(16)
|
|
92
123
|
flow_state = _FlowState()
|
|
93
124
|
client = self.construct_oauth_client(cfg)
|
|
@@ -142,3 +173,36 @@ class MCPAuthenticationFlowHandler(ConsoleAuthenticationFlowHandler):
|
|
|
142
173
|
"raw_token": token,
|
|
143
174
|
},
|
|
144
175
|
)
|
|
176
|
+
|
|
177
|
+
async def _start_redirect_server(self) -> None:
|
|
178
|
+
"""
|
|
179
|
+
Override to use the host and port from redirect_uri config instead of hardcoded localhost:8000.
|
|
180
|
+
|
|
181
|
+
This allows MCP authentication to work with custom redirect hosts and ports
|
|
182
|
+
specified in the configuration.
|
|
183
|
+
"""
|
|
184
|
+
# If the server is already running, do nothing
|
|
185
|
+
if self._server_controller:
|
|
186
|
+
return
|
|
187
|
+
try:
|
|
188
|
+
if not self._redirect_app:
|
|
189
|
+
raise RuntimeError("Redirect app not built.")
|
|
190
|
+
|
|
191
|
+
self._server_controller = _FastApiFrontEndController(self._redirect_app)
|
|
192
|
+
|
|
193
|
+
self._server_task = asyncio.create_task(
|
|
194
|
+
self._server_controller.start_server(host=self._redirect_host, port=self._redirect_port))
|
|
195
|
+
logger.debug("MCP redirect server starting on %s:%d", self._redirect_host, self._redirect_port)
|
|
196
|
+
|
|
197
|
+
# Wait for the server to bind (max ~10s)
|
|
198
|
+
start = asyncio.get_running_loop().time()
|
|
199
|
+
while True:
|
|
200
|
+
server = getattr(self._server_controller, "_server", None)
|
|
201
|
+
if server and getattr(server, "started", False):
|
|
202
|
+
break
|
|
203
|
+
if asyncio.get_running_loop().time() - start > 10:
|
|
204
|
+
raise RuntimeError("Redirect server did not report ready within 10s")
|
|
205
|
+
await asyncio.sleep(0.1)
|
|
206
|
+
except Exception as exc:
|
|
207
|
+
raise RuntimeError(
|
|
208
|
+
f"Failed to start MCP redirect server on {self._redirect_host}:{self._redirect_port}: {exc}") from exc
|
{nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nvidia-nat-mcp
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.0a20251022
|
|
4
4
|
Summary: Subpackage for MCP client integration in NeMo Agent toolkit
|
|
5
5
|
Author: NVIDIA Corporation
|
|
6
6
|
Maintainer: NVIDIA Corporation
|
|
@@ -16,7 +16,7 @@ Requires-Python: <3.14,>=3.11
|
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE-3rd-party.txt
|
|
18
18
|
License-File: LICENSE.md
|
|
19
|
-
Requires-Dist: nvidia-nat==v1.4.
|
|
19
|
+
Requires-Dist: nvidia-nat==v1.4.0a20251022
|
|
20
20
|
Requires-Dist: aiorwlock~=1.5
|
|
21
21
|
Requires-Dist: mcp~=1.14
|
|
22
22
|
Dynamic: license-file
|
|
@@ -9,15 +9,15 @@ nat/plugins/mcp/register.py,sha256=HOT2Wl2isGuyFc7BUTi58-BbjI5-EtZMZo7stsv5pN4,8
|
|
|
9
9
|
nat/plugins/mcp/tool.py,sha256=xNfBIF__ugJKFEjkYEM417wWM1PpuTaCMGtSFmxHSuA,6089
|
|
10
10
|
nat/plugins/mcp/utils.py,sha256=4kNF5FJRiDUn-3fQcsvwvWtG6tYG1y4jU7vpptp0fsA,4522
|
|
11
11
|
nat/plugins/mcp/auth/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
|
|
12
|
-
nat/plugins/mcp/auth/auth_flow_handler.py,sha256=
|
|
12
|
+
nat/plugins/mcp/auth/auth_flow_handler.py,sha256=v21IK3IKZ2TLEP6wO9r-sJQiilWPq7Ry40M96SAxQFA,9125
|
|
13
13
|
nat/plugins/mcp/auth/auth_provider.py,sha256=BgH66DlZgzhLDLO4cBERpHvNAmli5fMo_SCy11W9aBU,21251
|
|
14
14
|
nat/plugins/mcp/auth/auth_provider_config.py,sha256=b1AaXzOuAkygKXAWSxMKWg8wfW8k33tmUUq6Dk5Mmwk,4038
|
|
15
15
|
nat/plugins/mcp/auth/register.py,sha256=L2x69NjJPS4s6CCE5myzWVrWn3e_ttHyojmGXvBipMg,1228
|
|
16
16
|
nat/plugins/mcp/auth/token_storage.py,sha256=aS13ZvEJXcYzkZ0GSbrSor4i5bpjD5BkXHQw1iywC9k,9240
|
|
17
|
-
nvidia_nat_mcp-1.4.
|
|
18
|
-
nvidia_nat_mcp-1.4.
|
|
19
|
-
nvidia_nat_mcp-1.4.
|
|
20
|
-
nvidia_nat_mcp-1.4.
|
|
21
|
-
nvidia_nat_mcp-1.4.
|
|
22
|
-
nvidia_nat_mcp-1.4.
|
|
23
|
-
nvidia_nat_mcp-1.4.
|
|
17
|
+
nvidia_nat_mcp-1.4.0a20251022.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
18
|
+
nvidia_nat_mcp-1.4.0a20251022.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
19
|
+
nvidia_nat_mcp-1.4.0a20251022.dist-info/METADATA,sha256=Sjoj9mfeyQYBGa_CzTaskWWtUOzdqrsu6M0C_Yl-9vY,2319
|
|
20
|
+
nvidia_nat_mcp-1.4.0a20251022.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
nvidia_nat_mcp-1.4.0a20251022.dist-info/entry_points.txt,sha256=rYvUp4i-klBr3bVNh7zYOPXret704vTjvCk1qd7FooI,97
|
|
22
|
+
nvidia_nat_mcp-1.4.0a20251022.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
|
23
|
+
nvidia_nat_mcp-1.4.0a20251022.dist-info/RECORD,,
|
|
File without changes
|
{nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nvidia_nat_mcp-1.4.0a20251015.dist-info → nvidia_nat_mcp-1.4.0a20251022.dist-info}/top_level.txt
RENAMED
|
File without changes
|