Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions external/nat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ The adapter consumes the routed `capability_plan.native.mcp_servers` entries,
including the normalized per-server filters. NeMo Fabric MCP tool names remain bare
server-local names; NAT exposes a selected member as `<server>__<tool>`.

For `stdio` servers, NeMo Fabric expands `$VAR` references in `url`, parses the
command and inline arguments, appends structured `args`, and forwards `env` to
NAT. Only `url` supports variable expansion; `args` and `env` values are literal.

| NeMo Fabric server policy | Generated NAT function group |
| --- | --- |
| `allowed_tools` omitted and `blocked_tools=[]` | No `include` or `exclude`; expose all discovered tools |
Expand Down
7 changes: 5 additions & 2 deletions external/nat/src/nemo_fabric_adapters/nat/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,11 @@ def nat_mcp_server_config(name: str, server: Any) -> dict[str, Any]:
"transport": "stdio",
"command": command[0],
}
if command[1:]:
result["args"] = command[1:]
args = [*command[1:], *common_utils.normalize_list(server.get("args"))]
if args:
result["args"] = args
if env := server.get("env"):
result["env"] = env
Comment thread
zhongxuanwang-nv marked this conversation as resolved.
return result

if transport in {"http", "streamablehttp"}:
Expand Down
14 changes: 12 additions & 2 deletions tests/adapters/test_external_nat_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ def test_mcp_server_normalizes_streamable_http_aliases(transport: str):
}


def test_mcp_stdio_expands_environment_and_parses_quoted_arguments(
def test_mcp_stdio_expands_command_and_maps_structured_args_and_env(
monkeypatch: pytest.MonkeyPatch,
):
monkeypatch.setenv("NAT_TEST_MCP_COMMAND", "/opt/nat/bin/mcp-server")
Expand All @@ -1005,13 +1005,23 @@ def test_mcp_stdio_expands_environment_and_parses_quoted_arguments(
{
"transport": "stdio",
"url": "$NAT_TEST_MCP_COMMAND --label 'safe mode' --port 9000",
"args": ["--trace", "--request-timeout=10"],
"env": {"NAT_MCP_TOKEN": "test-token"},
},
)

assert result == {
"transport": "stdio",
"command": "/opt/nat/bin/mcp-server",
"args": ["--label", "safe mode", "--port", "9000"],
"args": [
"--label",
"safe mode",
"--port",
"9000",
"--trace",
"--request-timeout=10",
],
"env": {"NAT_MCP_TOKEN": "test-token"},
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.


Expand Down
Loading