nvidia-nat-mcp 1.4.0a20251014__py3-none-any.whl → 1.5.0a20260115__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.
Potentially problematic release.
This version of nvidia-nat-mcp might be problematic. Click here for more details.
- nat/meta/pypi.md +1 -1
- nat/plugins/mcp/__init__.py +1 -1
- nat/plugins/mcp/auth/__init__.py +1 -1
- nat/plugins/mcp/auth/auth_flow_handler.py +65 -1
- nat/plugins/mcp/auth/auth_provider.py +3 -2
- nat/plugins/mcp/auth/auth_provider_config.py +5 -2
- nat/plugins/mcp/auth/register.py +9 -1
- nat/plugins/mcp/auth/service_account/__init__.py +14 -0
- nat/plugins/mcp/auth/service_account/provider.py +136 -0
- nat/plugins/mcp/auth/service_account/provider_config.py +137 -0
- nat/plugins/mcp/auth/service_account/token_client.py +156 -0
- nat/plugins/mcp/auth/token_storage.py +2 -2
- nat/plugins/mcp/cli/__init__.py +15 -0
- nat/plugins/mcp/cli/commands.py +1094 -0
- nat/plugins/mcp/client/__init__.py +15 -0
- nat/plugins/mcp/{client_base.py → client/client_base.py} +18 -10
- nat/plugins/mcp/{client_config.py → client/client_config.py} +24 -9
- nat/plugins/mcp/{client_impl.py → client/client_impl.py} +253 -62
- nat/plugins/mcp/exception_handler.py +1 -1
- nat/plugins/mcp/exceptions.py +1 -1
- nat/plugins/mcp/register.py +5 -4
- nat/plugins/mcp/server/__init__.py +15 -0
- nat/plugins/mcp/server/front_end_config.py +109 -0
- nat/plugins/mcp/server/front_end_plugin.py +155 -0
- nat/plugins/mcp/server/front_end_plugin_worker.py +415 -0
- nat/plugins/mcp/server/introspection_token_verifier.py +72 -0
- nat/plugins/mcp/server/memory_profiler.py +320 -0
- nat/plugins/mcp/server/register_frontend.py +27 -0
- nat/plugins/mcp/server/tool_converter.py +290 -0
- nat/plugins/mcp/utils.py +153 -36
- {nvidia_nat_mcp-1.4.0a20251014.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/METADATA +5 -5
- nvidia_nat_mcp-1.5.0a20260115.dist-info/RECORD +37 -0
- nvidia_nat_mcp-1.5.0a20260115.dist-info/entry_points.txt +9 -0
- nat/plugins/mcp/tool.py +0 -138
- nvidia_nat_mcp-1.4.0a20251014.dist-info/RECORD +0 -23
- nvidia_nat_mcp-1.4.0a20251014.dist-info/entry_points.txt +0 -3
- {nvidia_nat_mcp-1.4.0a20251014.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/WHEEL +0 -0
- {nvidia_nat_mcp-1.4.0a20251014.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat_mcp-1.4.0a20251014.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat_mcp-1.4.0a20251014.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/top_level.txt +0 -0
nat/plugins/mcp/tool.py
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
# you may not use this file except in compliance with the License.
|
|
6
|
-
# You may obtain a copy of the License at
|
|
7
|
-
#
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
#
|
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
# See the License for the specific language governing permissions and
|
|
14
|
-
# limitations under the License.
|
|
15
|
-
|
|
16
|
-
import logging
|
|
17
|
-
from typing import Literal
|
|
18
|
-
|
|
19
|
-
from pydantic import BaseModel
|
|
20
|
-
from pydantic import Field
|
|
21
|
-
from pydantic import HttpUrl
|
|
22
|
-
from pydantic import model_validator
|
|
23
|
-
|
|
24
|
-
from nat.builder.builder import Builder
|
|
25
|
-
from nat.builder.function_info import FunctionInfo
|
|
26
|
-
from nat.cli.register_workflow import register_function
|
|
27
|
-
from nat.data_models.function import FunctionBaseConfig
|
|
28
|
-
from nat.plugins.mcp.client_base import MCPToolClient
|
|
29
|
-
from nat.utils.decorators import deprecated
|
|
30
|
-
|
|
31
|
-
logger = logging.getLogger(__name__)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class MCPToolConfig(FunctionBaseConfig, name="mcp_tool_wrapper"):
|
|
35
|
-
"""
|
|
36
|
-
Function which connects to a Model Context Protocol (MCP) server and wraps the selected tool as a NeMo Agent toolkit
|
|
37
|
-
function.
|
|
38
|
-
"""
|
|
39
|
-
# Add your custom configuration parameters here
|
|
40
|
-
url: HttpUrl | None = Field(default=None,
|
|
41
|
-
description="The URL of the MCP server (for streamable-http or sse modes)")
|
|
42
|
-
mcp_tool_name: str = Field(description="The name of the tool served by the MCP Server that you want to use")
|
|
43
|
-
transport: Literal["sse", "stdio", "streamable-http"] = Field(
|
|
44
|
-
default="streamable-http",
|
|
45
|
-
description="The type of transport to use (default: streamable-http, backwards compatible with sse)")
|
|
46
|
-
command: str | None = Field(default=None,
|
|
47
|
-
description="The command to run for stdio mode (e.g. 'docker' or 'python')")
|
|
48
|
-
args: list[str] | None = Field(default=None, description="Additional arguments for the stdio command")
|
|
49
|
-
env: dict[str, str] | None = Field(default=None, description="Environment variables to set for the stdio process")
|
|
50
|
-
description: str | None = Field(default=None,
|
|
51
|
-
description="""
|
|
52
|
-
Description for the tool that will override the description provided by the MCP server. Should only be used if
|
|
53
|
-
the description provided by the server is poor or nonexistent
|
|
54
|
-
""")
|
|
55
|
-
|
|
56
|
-
@model_validator(mode="after")
|
|
57
|
-
def validate_model(self):
|
|
58
|
-
"""Validate that stdio and SSE/Streamable HTTP properties are mutually exclusive."""
|
|
59
|
-
if self.transport == 'stdio':
|
|
60
|
-
if self.url is not None:
|
|
61
|
-
raise ValueError("url should not be set when using stdio client type")
|
|
62
|
-
if not self.command:
|
|
63
|
-
raise ValueError("command is required when using stdio client type")
|
|
64
|
-
elif self.transport in ['streamable-http', 'sse']:
|
|
65
|
-
if self.command is not None or self.args is not None or self.env is not None:
|
|
66
|
-
raise ValueError(
|
|
67
|
-
"command, args, and env should not be set when using streamable-http or sse client type")
|
|
68
|
-
if not self.url:
|
|
69
|
-
raise ValueError("url is required when using streamable-http or sse client type")
|
|
70
|
-
return self
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def mcp_tool_function(tool: MCPToolClient) -> FunctionInfo:
|
|
74
|
-
"""
|
|
75
|
-
Create a NeMo Agent toolkit function from an MCP tool.
|
|
76
|
-
|
|
77
|
-
Args:
|
|
78
|
-
tool: The MCP tool to wrap
|
|
79
|
-
|
|
80
|
-
Returns:
|
|
81
|
-
The NeMo Agent toolkit function
|
|
82
|
-
"""
|
|
83
|
-
|
|
84
|
-
def _convert_from_str(input_str: str) -> tool.input_schema:
|
|
85
|
-
return tool.input_schema.model_validate_json(input_str)
|
|
86
|
-
|
|
87
|
-
async def _response_fn(tool_input: BaseModel | None = None, **kwargs) -> str:
|
|
88
|
-
# Run the tool, catching any errors and sending to agent for correction
|
|
89
|
-
try:
|
|
90
|
-
if tool_input:
|
|
91
|
-
args = tool_input.model_dump()
|
|
92
|
-
return await tool.acall(args)
|
|
93
|
-
|
|
94
|
-
_ = tool.input_schema.model_validate(kwargs)
|
|
95
|
-
return await tool.acall(kwargs)
|
|
96
|
-
except Exception as e:
|
|
97
|
-
logger.warning("Error calling tool %s", tool.name, exc_info=True)
|
|
98
|
-
return str(e)
|
|
99
|
-
|
|
100
|
-
return FunctionInfo.create(single_fn=_response_fn,
|
|
101
|
-
description=tool.description,
|
|
102
|
-
input_schema=tool.input_schema,
|
|
103
|
-
converters=[_convert_from_str])
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
@register_function(config_type=MCPToolConfig)
|
|
107
|
-
@deprecated(
|
|
108
|
-
reason=
|
|
109
|
-
"This function is being replaced with the new mcp_client function group that supports additional MCP features",
|
|
110
|
-
feature_name="mcp_tool_wrapper")
|
|
111
|
-
async def mcp_tool(config: MCPToolConfig, builder: Builder):
|
|
112
|
-
"""
|
|
113
|
-
Generate a NeMo Agent Toolkit Function that wraps a tool provided by the MCP server.
|
|
114
|
-
"""
|
|
115
|
-
|
|
116
|
-
from nat.plugins.mcp.client_base import MCPSSEClient
|
|
117
|
-
from nat.plugins.mcp.client_base import MCPStdioClient
|
|
118
|
-
from nat.plugins.mcp.client_base import MCPStreamableHTTPClient
|
|
119
|
-
|
|
120
|
-
# Initialize the client
|
|
121
|
-
if config.transport == 'stdio':
|
|
122
|
-
client = MCPStdioClient(command=config.command, args=config.args, env=config.env)
|
|
123
|
-
elif config.transport == 'streamable-http':
|
|
124
|
-
client = MCPStreamableHTTPClient(url=str(config.url))
|
|
125
|
-
elif config.transport == 'sse':
|
|
126
|
-
client = MCPSSEClient(url=str(config.url))
|
|
127
|
-
else:
|
|
128
|
-
raise ValueError(f"Invalid transport type: {config.transport}")
|
|
129
|
-
|
|
130
|
-
async with client:
|
|
131
|
-
# If the tool is found create a MCPToolClient object and set the description if provided
|
|
132
|
-
tool: MCPToolClient = await client.get_tool(config.mcp_tool_name)
|
|
133
|
-
if config.description:
|
|
134
|
-
tool.set_description(description=config.description)
|
|
135
|
-
|
|
136
|
-
logger.info("Configured to use tool: %s from MCP server at %s", tool.name, client.server_name)
|
|
137
|
-
|
|
138
|
-
yield mcp_tool_function(tool)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
nat/meta/pypi.md,sha256=EYyJTCCEOWzuuz-uNaYJ_WBk55Jiig87wcUr9E4g0yw,1484
|
|
2
|
-
nat/plugins/mcp/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
|
|
3
|
-
nat/plugins/mcp/client_base.py,sha256=JIyO2ZJsVkQ1g5BOU2zKXGHg_0yxv16g7_YJAqdCXTA,26504
|
|
4
|
-
nat/plugins/mcp/client_config.py,sha256=l9tVUHe8WdFPJ9rXDg8dZkQi1dvHGYwoqQ8Glqg2LGs,6783
|
|
5
|
-
nat/plugins/mcp/client_impl.py,sha256=j7cKAUBKtZAY3mt5Mm8VqgqMhRZk7kzvUd1nwMU_h0o,27072
|
|
6
|
-
nat/plugins/mcp/exception_handler.py,sha256=4JVdZDJL4LyumZEcMIEBK2LYC6djuSMzqUhQDZZ6dUo,7648
|
|
7
|
-
nat/plugins/mcp/exceptions.py,sha256=EGVOnYlui8xufm8dhJyPL1SUqBLnCGOTvRoeyNcmcWE,5980
|
|
8
|
-
nat/plugins/mcp/register.py,sha256=HOT2Wl2isGuyFc7BUTi58-BbjI5-EtZMZo7stsv5pN4,831
|
|
9
|
-
nat/plugins/mcp/tool.py,sha256=xNfBIF__ugJKFEjkYEM417wWM1PpuTaCMGtSFmxHSuA,6089
|
|
10
|
-
nat/plugins/mcp/utils.py,sha256=4kNF5FJRiDUn-3fQcsvwvWtG6tYG1y4jU7vpptp0fsA,4522
|
|
11
|
-
nat/plugins/mcp/auth/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
|
|
12
|
-
nat/plugins/mcp/auth/auth_flow_handler.py,sha256=2JgK0aH-5ouQCd2ov0lDMJAD5ZWIQJ7SVcXaLArxn6Y,6010
|
|
13
|
-
nat/plugins/mcp/auth/auth_provider.py,sha256=BgH66DlZgzhLDLO4cBERpHvNAmli5fMo_SCy11W9aBU,21251
|
|
14
|
-
nat/plugins/mcp/auth/auth_provider_config.py,sha256=b1AaXzOuAkygKXAWSxMKWg8wfW8k33tmUUq6Dk5Mmwk,4038
|
|
15
|
-
nat/plugins/mcp/auth/register.py,sha256=L2x69NjJPS4s6CCE5myzWVrWn3e_ttHyojmGXvBipMg,1228
|
|
16
|
-
nat/plugins/mcp/auth/token_storage.py,sha256=aS13ZvEJXcYzkZ0GSbrSor4i5bpjD5BkXHQw1iywC9k,9240
|
|
17
|
-
nvidia_nat_mcp-1.4.0a20251014.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
18
|
-
nvidia_nat_mcp-1.4.0a20251014.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
19
|
-
nvidia_nat_mcp-1.4.0a20251014.dist-info/METADATA,sha256=_QFv7NGYwOEFEtOixk3PhwAlBiLsadjkToubYXk2bmU,2319
|
|
20
|
-
nvidia_nat_mcp-1.4.0a20251014.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
-
nvidia_nat_mcp-1.4.0a20251014.dist-info/entry_points.txt,sha256=rYvUp4i-klBr3bVNh7zYOPXret704vTjvCk1qd7FooI,97
|
|
22
|
-
nvidia_nat_mcp-1.4.0a20251014.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
|
23
|
-
nvidia_nat_mcp-1.4.0a20251014.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nvidia_nat_mcp-1.4.0a20251014.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/top_level.txt
RENAMED
|
File without changes
|