nvidia-nat-mcp 1.5.0a20260103__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.
Files changed (40) hide show
  1. nat/meta/pypi.md +1 -1
  2. nat/plugins/mcp/__init__.py +1 -1
  3. nat/plugins/mcp/auth/__init__.py +1 -1
  4. nat/plugins/mcp/auth/auth_flow_handler.py +1 -1
  5. nat/plugins/mcp/auth/auth_provider.py +1 -1
  6. nat/plugins/mcp/auth/auth_provider_config.py +2 -1
  7. nat/plugins/mcp/auth/register.py +1 -1
  8. nat/plugins/mcp/auth/service_account/__init__.py +1 -1
  9. nat/plugins/mcp/auth/service_account/provider.py +1 -1
  10. nat/plugins/mcp/auth/service_account/provider_config.py +1 -1
  11. nat/plugins/mcp/auth/service_account/token_client.py +1 -1
  12. nat/plugins/mcp/auth/token_storage.py +2 -2
  13. nat/plugins/mcp/cli/__init__.py +15 -0
  14. nat/plugins/mcp/cli/commands.py +1094 -0
  15. nat/plugins/mcp/client/__init__.py +15 -0
  16. nat/plugins/mcp/{client_base.py → client/client_base.py} +1 -1
  17. nat/plugins/mcp/{client_config.py → client/client_config.py} +24 -9
  18. nat/plugins/mcp/{client_impl.py → client/client_impl.py} +219 -51
  19. nat/plugins/mcp/exception_handler.py +1 -1
  20. nat/plugins/mcp/exceptions.py +1 -1
  21. nat/plugins/mcp/register.py +5 -4
  22. nat/plugins/mcp/server/__init__.py +15 -0
  23. nat/plugins/mcp/server/front_end_config.py +109 -0
  24. nat/plugins/mcp/server/front_end_plugin.py +155 -0
  25. nat/plugins/mcp/server/front_end_plugin_worker.py +415 -0
  26. nat/plugins/mcp/server/introspection_token_verifier.py +72 -0
  27. nat/plugins/mcp/server/memory_profiler.py +320 -0
  28. nat/plugins/mcp/server/register_frontend.py +27 -0
  29. nat/plugins/mcp/server/tool_converter.py +290 -0
  30. nat/plugins/mcp/utils.py +1 -1
  31. {nvidia_nat_mcp-1.5.0a20260103.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/METADATA +5 -5
  32. nvidia_nat_mcp-1.5.0a20260115.dist-info/RECORD +37 -0
  33. nvidia_nat_mcp-1.5.0a20260115.dist-info/entry_points.txt +9 -0
  34. nat/plugins/mcp/tool.py +0 -138
  35. nvidia_nat_mcp-1.5.0a20260103.dist-info/RECORD +0 -27
  36. nvidia_nat_mcp-1.5.0a20260103.dist-info/entry_points.txt +0 -3
  37. {nvidia_nat_mcp-1.5.0a20260103.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/WHEEL +0 -0
  38. {nvidia_nat_mcp-1.5.0a20260103.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
  39. {nvidia_nat_mcp-1.5.0a20260103.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/licenses/LICENSE.md +0 -0
  40. {nvidia_nat_mcp-1.5.0a20260103.dist-info → nvidia_nat_mcp-1.5.0a20260115.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,37 @@
1
+ nat/meta/pypi.md,sha256=-P0JFDuIEDuCRryhXejNke80c_b6AeAzMNKMGgS-NT4,1489
2
+ nat/plugins/mcp/__init__.py,sha256=hiEJ2ajB5zhZuZOUHAyHfTA9w9UNhygij7hp4yfA6QE,685
3
+ nat/plugins/mcp/exception_handler.py,sha256=iEVSZFgiKm6Mr2XB3NRYbYBgyK7GJ6LnnPYXs8MYwJI,7653
4
+ nat/plugins/mcp/exceptions.py,sha256=87fm20cBNijam8n0dYx7drwCZqH1zr9tKls2ayfkK0A,5985
5
+ nat/plugins/mcp/register.py,sha256=-_SHPsqmVuFNlo6fwnXpZA9whIlMKifk4vnBfNX33mA,858
6
+ nat/plugins/mcp/utils.py,sha256=5foCyTdCp0p72FvlP_VjkQe6wgWLc9__XCfGk_iAUbY,9116
7
+ nat/plugins/mcp/auth/__init__.py,sha256=hiEJ2ajB5zhZuZOUHAyHfTA9w9UNhygij7hp4yfA6QE,685
8
+ nat/plugins/mcp/auth/auth_flow_handler.py,sha256=BvrclzC1mmVBsUZ2lx6Cv5NNFtMmUDxsTwLAKRrjiWU,9130
9
+ nat/plugins/mcp/auth/auth_provider.py,sha256=c-Y_FIDVUjEUixvqzeh7Sl0r5aiCR9JDyfudnfC6um8,21326
10
+ nat/plugins/mcp/auth/auth_provider_config.py,sha256=l0jbQZ_lYEK0B1DlkjkoKUcWIvW5pZas_rbE_WWqvq8,4226
11
+ nat/plugins/mcp/auth/register.py,sha256=FEp4L_ff4HQgFI4QDH04NIEIKRvh8bacns957dQlk9g,1759
12
+ nat/plugins/mcp/auth/token_storage.py,sha256=Zuj0tAWqkv8pPt4baeVEL2eEmnCE4AjU4h6eLhyKyKI,9263
13
+ nat/plugins/mcp/auth/service_account/__init__.py,sha256=hiEJ2ajB5zhZuZOUHAyHfTA9w9UNhygij7hp4yfA6QE,685
14
+ nat/plugins/mcp/auth/service_account/provider.py,sha256=Gsb44cy-5Ap_1BcG3Ny9fc94VtfPg4lVrwM3LKeTBA8,5920
15
+ nat/plugins/mcp/auth/service_account/provider_config.py,sha256=rrzHAo1qmK1yI5CNaadNTVsmh5qtYF1UrYz2Q1nLF2E,5332
16
+ nat/plugins/mcp/auth/service_account/token_client.py,sha256=bGAjq_vG8oo8ZoQfRJjEgigGmF0hgF0umaUOWv0_ZOY,5986
17
+ nat/plugins/mcp/cli/__init__.py,sha256=GLpBQw8r1Nj38vIOluSHsTlLINI24tZ_JJbcWWksBJE,709
18
+ nat/plugins/mcp/cli/commands.py,sha256=CFqLqaG2ldKqdbOAfNfUc1wyYRxuq2psoGX0mE_-2Go,48869
19
+ nat/plugins/mcp/client/__init__.py,sha256=SFdgClH-7zCAAcujmdvtfiqSz3Xe1KVRX7fviW-45Zg,714
20
+ nat/plugins/mcp/client/client_base.py,sha256=jWNwb20qWIUuIJg7Ldp_WgiJlQmYin4YvVSJ9_ECP5c,26831
21
+ nat/plugins/mcp/client/client_config.py,sha256=qrBjXCKHpMoS2A5i9DoXkN7hdYnGy77FBcZDGZlyb4w,7179
22
+ nat/plugins/mcp/client/client_impl.py,sha256=dygcLnhnWnMh7u45aLvYbGEP1uv02uSb886YsOucxgs,36661
23
+ nat/plugins/mcp/server/__init__.py,sha256=Ioza5tZX7qlOicklSVbhcXO3r7EjRLENvV5AtBSusAQ,723
24
+ nat/plugins/mcp/server/front_end_config.py,sha256=yFmEMKcz_ANJnef4Zu4dwGtnfNZ0uzVdc_dYYCLmgCg,5749
25
+ nat/plugins/mcp/server/front_end_plugin.py,sha256=WAqgYFHAswUK1WKk_PIUo6Lyf0pvJLelT3esHhmIHFM,6896
26
+ nat/plugins/mcp/server/front_end_plugin_worker.py,sha256=2_PQ938IbYKFKDsmDw6rcgBWHZdbxZetUopU4Ik1FDQ,18187
27
+ nat/plugins/mcp/server/introspection_token_verifier.py,sha256=oyhZkCTo6u3w7m469DicF57BNmhTPLcMYtWuHvcCsRg,2840
28
+ nat/plugins/mcp/server/memory_profiler.py,sha256=KjJw4ARSmEFult2MorFySiucog0bD8ClI9ZbkJhIwns,12816
29
+ nat/plugins/mcp/server/register_frontend.py,sha256=gfHfQaQ4NhkZkDSrFur1bxbG93kbAGBtumm4eKYOzKE,1178
30
+ nat/plugins/mcp/server/tool_converter.py,sha256=v35IILT5S2jE7ZTYQzm8-4CMu5Xa21BACeRP1MS1vzA,11608
31
+ nvidia_nat_mcp-1.5.0a20260115.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
32
+ nvidia_nat_mcp-1.5.0a20260115.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
33
+ nvidia_nat_mcp-1.5.0a20260115.dist-info/METADATA,sha256=SVVtI6zoLVr33_W167VxtESeEabwXxzMsh9zaagfY_g,2326
34
+ nvidia_nat_mcp-1.5.0a20260115.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
35
+ nvidia_nat_mcp-1.5.0a20260115.dist-info/entry_points.txt,sha256=t5HYRfXR-dyZf6BWRz1u1TqPprKpCWt-WLHKQXfiLLU,231
36
+ nvidia_nat_mcp-1.5.0a20260115.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
37
+ nvidia_nat_mcp-1.5.0a20260115.dist-info/RECORD,,
@@ -0,0 +1,9 @@
1
+ [nat.cli]
2
+ mcp = nat.plugins.mcp.cli.commands:mcp_command
3
+
4
+ [nat.components]
5
+ nat_mcp = nat.plugins.mcp.register
6
+ nat_mcp_auth = nat.plugins.mcp.auth.register
7
+
8
+ [nat.front_ends]
9
+ nat_mcp_server = nat.plugins.mcp.server.register_frontend
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,27 +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=nhf62n8WNHdWqWBzt0im_V1RHyiGBdkhtDp3d9ZXQ0E,26826
4
- nat/plugins/mcp/client_config.py,sha256=l9tVUHe8WdFPJ9rXDg8dZkQi1dvHGYwoqQ8Glqg2LGs,6783
5
- nat/plugins/mcp/client_impl.py,sha256=UQQgn47stzOEfYhuLC8669-6xaj4gWDUgWWNsCpI-JM,28618
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=dUIig7jeKz0ctb4o38jFGbe2uvM3DMR3PSJjfN_Lr5M,9111
11
- nat/plugins/mcp/auth/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
12
- nat/plugins/mcp/auth/auth_flow_handler.py,sha256=v21IK3IKZ2TLEP6wO9r-sJQiilWPq7Ry40M96SAxQFA,9125
13
- nat/plugins/mcp/auth/auth_provider.py,sha256=lrjAmCLHjGzeYWreLPtd3QGpSgIrmiu70zGMSg7QmIA,21321
14
- nat/plugins/mcp/auth/auth_provider_config.py,sha256=ZdiUObYU_Oj8KDDZ-JqkS6kJgup5EBy2ZREUOBw_kkI,4143
15
- nat/plugins/mcp/auth/register.py,sha256=miNZNmNszGgMCOCADLpH0Nz1nugkDXqdVc7ooapBx-c,1754
16
- nat/plugins/mcp/auth/token_storage.py,sha256=aS13ZvEJXcYzkZ0GSbrSor4i5bpjD5BkXHQw1iywC9k,9240
17
- nat/plugins/mcp/auth/service_account/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
18
- nat/plugins/mcp/auth/service_account/provider.py,sha256=jJmt7PA_U3C59K5chSzmEIOd2bRxRKqXly9vHkTmsHQ,5915
19
- nat/plugins/mcp/auth/service_account/provider_config.py,sha256=KhvQpROporbNKDFnx8np8b31QhdT3s5zYXd_IVTLgfE,5327
20
- nat/plugins/mcp/auth/service_account/token_client.py,sha256=PRJ3u8Ts1tpuLuQKOyHDPOIAynSKxW9a928Rhh_4fhc,5981
21
- nvidia_nat_mcp-1.5.0a20260103.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
22
- nvidia_nat_mcp-1.5.0a20260103.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
23
- nvidia_nat_mcp-1.5.0a20260103.dist-info/METADATA,sha256=xv7x3H74BIO0yALKUUwlbFbeoeG6TwgOKhajl3634Pg,2319
24
- nvidia_nat_mcp-1.5.0a20260103.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- nvidia_nat_mcp-1.5.0a20260103.dist-info/entry_points.txt,sha256=rYvUp4i-klBr3bVNh7zYOPXret704vTjvCk1qd7FooI,97
26
- nvidia_nat_mcp-1.5.0a20260103.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
27
- nvidia_nat_mcp-1.5.0a20260103.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [nat.components]
2
- nat_mcp = nat.plugins.mcp.register
3
- nat_mcp_auth = nat.plugins.mcp.auth.register