Skip to content

fix: preserve NAT stdio MCP arguments and environment - #178

Merged
rapids-bot[bot] merged 3 commits into
NVIDIA:mainfrom
zhongxuanwang-nv:fix/nat-mcp-stdio-configuration
Aug 7, 2026
Merged

fix: preserve NAT stdio MCP arguments and environment#178
rapids-bot[bot] merged 3 commits into
NVIDIA:mainfrom
zhongxuanwang-nv:fix/nat-mcp-stdio-configuration

Conversation

@zhongxuanwang-nv

@zhongxuanwang-nv zhongxuanwang-nv commented Aug 5, 2026

Copy link
Copy Markdown
Member

Overview

Fix NAT stdio MCP configuration so the structured args and env fields in the capability plan are forwarded to NAT instead of being silently dropped. Document the resulting command, argument, and environment mapping in the NAT adapter README.

The NAT adapter is now on main through #175; this draft contains the focused fix, regression coverage, and its adapter documentation.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Appends structured MCP arguments to any legacy arguments parsed from the stdio command.
  • Preserves configured process environment values in the NAT MCP server mapping.
  • Documents argument ordering, environment forwarding, and URL-only variable expansion.
  • Extends the stdio MCP regression test to cover inline arguments, structured arguments, and environment variables together.

Validation

  • uv run --no-sync pytest -q tests/adapters/test_external_nat_adapter.py — 52 passed, 2 skipped after rebasing.
  • pre-commit run --files external/nat/README.md.
  • just test-python — full Python suite passed before rebasing; the rebase introduced no code conflicts.
  • uv run --with ruff ruff check ....
  • git diff --check.

Where should the reviewer start?

Start with nat_mcp_server_config in external/nat/src/nemo_fabric_adapters/nat/adapter.py; the README directly below the MCP routing section and the regression coverage in tests/adapters/test_external_nat_adapter.py explain and test the behavior.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • New Features

    • Added NeMo Fabric integration for configuring and running NAT workflows.
    • Supports models, tools, MCP servers, function groups, system instructions, and tool policies.
    • Added asynchronous workflow execution with persistent runtime and session management.
    • MCP stdio servers now support command arguments and environment variables.
  • Reliability

    • Added validation for configurations, runtime requests, invocations, and workflow results.
    • Errors are reported in a structured, non-retryable format with sensitive values redacted.
  • Documentation

    • Documented MCP stdio URL expansion, argument handling, and environment forwarding.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This change adds a NeMo Fabric-to-NAT adapter. It translates Fabric configuration, manages persistent NAT runtime resources, supports MCP transports and tool policies, and validates lifecycle, invocation, cleanup, serialization, and failure handling.

Changes

NAT adapter

Layer / File(s) Summary
Adapter contract and configuration mapping
external/nat/src/nemo_fabric_adapters/nat/adapter.py, tests/adapters/test_external_nat_adapter.py
Defines adapter metadata. It validates workflow, model, instruction, and harness settings. It maps Fabric model settings into NAT configuration.
MCP and tool capability translation
external/nat/src/nemo_fabric_adapters/nat/adapter.py, tests/adapters/test_external_nat_adapter.py, external/nat/README.md
Translates stdio, SSE, and streamable HTTP MCP servers into NAT function groups. It applies allow, block, group, and root tool policies. The documentation describes stdio command and environment handling.
Persistent runtime lifecycle
external/nat/src/nemo_fabric_adapters/nat/adapter.py, tests/adapters/test_external_nat_adapter.py
Builds and validates typed NAT configuration. It manages workflow builders and sessions, validates invocations, serializes results, and normalizes startup, execution, cleanup, and serialization failures.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FabricLifecycle
  participant NatRuntime
  participant NATWorkflowBuilder
  participant NATSessionManager
  FabricLifecycle->>NatRuntime: start lifecycle payload
  NatRuntime->>NATWorkflowBuilder: build workflow from typed NAT configuration
  NatRuntime->>NATSessionManager: create persistent session manager
  FabricLifecycle->>NatRuntime: invoke request and context
  NatRuntime->>NATSessionManager: create managed session
  NatRuntime->>NATWorkflowBuilder: execute workflow with run context
  NATWorkflowBuilder-->>NatRuntime: workflow result
  NatRuntime-->>FabricLifecycle: JSON-compatible success or structured error
  FabricLifecycle->>NatRuntime: shutdown
  NatRuntime->>NATSessionManager: close runtime resources
Loading

Possibly related PRs

  • NVIDIA/NeMo-Fabric#175: Directly relates to the NAT adapter, MCP handling, runtime behavior, documentation, and tests.
  • NVIDIA/NeMo-Fabric#176: Introduces the typed FabricConfig.workflow contract used to select and configure NAT workflows.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title uses the allowed fix type, follows Conventional Commits format, describes the change, and is 53 characters without a trailing period.
Description check ✅ Passed The description includes the required overview, reviewer starting point, related issue action keyword, contributor attestations, and validation details.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@external/nat/README.md`:
- Around line 49-51: Update the README’s NeMo Fabric-to-NAT mapping
documentation near the routed capability_plan.native.mcp_servers description to
state that structured stdio args are appended after arguments parsed from the
url, and that env entries are forwarded to NAT’s stdio mapping. Also document
that $VAR expansion applies only to url, not to args or env values.

In `@external/nat/src/nemo_fabric_adapters/nat/adapter.py`:
- Around line 346-347: Update the env handling in the nat_mcp_server_config
translation to validate that env is a string-to-string mapping, report invalid
input through nat_invalid_mcp_server, and deep-copy the validated mapping using
the module’s existing _mapping helper or equivalent. Add a rejection test
covering a non-mapping env value and preserve the existing behavior for valid
mappings.

In `@tests/adapters/test_external_nat_adapter.py`:
- Around line 710-716: Extend the adapter tests with focused coverage for the
subprocess entry point and credential-free doctor flow: patch lifecycle.serve,
call adapter.main(), and assert it receives NatRuntime, while preserving the
__main__ guard behavior; add a doctor assertion using the staged descriptor
alongside the existing plan coverage, and keep the credential-dependent run path
opt-in.
- Around line 959-986: Extend
test_mcp_stdio_expands_command_and_maps_structured_args_and_env to cover a bare
stdio command with no structured args, preferably by parametrizing the test.
Assert that the result contains the transport and command but omits the args key
entirely, preserving the existing merged-arguments case and its expected
mapping.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 7856b94c-0701-43fd-9915-1fb5ad8fc251

📥 Commits

Reviewing files that changed from the base of the PR and between a227a6b and f9f9699.

📒 Files selected for processing (9)
  • external/README.md
  • external/nat/README.md
  • external/nat/examples/calculator.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/fabric-adapter.json
  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
  • tests/adapters/test_external_nat_adapter.py
📜 Review details
⏰ Context from checks skipped due to timeout. (18)
  • GitHub Check: Pre-commit
  • GitHub Check: Test (Python 3.13, macos-arm64)
  • GitHub Check: Test (Python 3.13, linux-amd64)
  • GitHub Check: Test (Python 3.14, linux-amd64)
  • GitHub Check: Test (Python 3.12, linux-amd64)
  • GitHub Check: Test (Python 3.13, linux-arm64)
  • GitHub Check: Test (Python 3.11, linux-arm64)
  • GitHub Check: Test (Python 3.14, linux-arm64)
  • GitHub Check: Test (Python 3.14, macos-arm64)
  • GitHub Check: Test (Python 3.11, linux-amd64)
  • GitHub Check: Test (Python 3.12, windows-amd64)
  • GitHub Check: Test (Python 3.14, windows-amd64)
  • GitHub Check: Test (Python 3.13, windows-amd64)
  • GitHub Check: Test (Python 3.12, macos-arm64)
  • GitHub Check: Test (Python 3.11, macos-arm64)
  • GitHub Check: Test (Python 3.11, windows-amd64)
  • GitHub Check: Test (Python 3.12, linux-arm64)
  • GitHub Check: Test (x86_64)
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{md,rst}

📄 CodeRabbit inference engine (.agents/skills/contribute-api/SKILL.md)

Update documentation and examples in the same branch as the public API change.

Files:

  • external/README.md
  • external/nat/README.md
**/*

📄 CodeRabbit inference engine (.agents/skills/karpathy-guidelines/SKILL.md)

**/*: Before implementing, explicitly state assumptions, surface ambiguity and tradeoffs, present multiple interpretations when relevant, and ask for clarification rather than silently deciding or proceeding when requirements are unclear.
Prefer the minimum code needed to solve the requested problem: avoid speculative features, unnecessary abstractions, unrequested flexibility, and handling of impossible scenarios; simplify overcomplicated solutions.
When editing existing code, make surgical changes only: do not modify unrelated code, comments, formatting, or pre-existing dead code; match the existing style, and remove only unused imports, variables, or functions introduced by your changes.
Define verifiable success criteria for each task, such as writing regression tests for bugs and invalid-input tests for validation, then verify the implementation against those criteria. For multi-step work, state a brief plan with a verification check for each step.

**/*: Always spell NVIDIA in all caps; do not use Nvidia, nvidia, nVidia, nVIDIA, or NV.
Use an NVIDIA before a noun, because the name begins with an “en” sound.
Do not add a registered trademark symbol after NVIDIA when referring to the company; use trademark symbols with product names only when required by the document type or legal guidance.
Verify official capitalization, spacing, hyphenation, and spelling for NVIDIA and third-party product names; do not rewrite official product names for grammar or title-case rules.
Precede NVIDIA product names with NVIDIA on first mention when natural and accurate, and link the first mention when the destination helps the reader.
On first use, include the company name and full model qualifier when it helps identify the model; preserve official capitalization and punctuation, and use shorter family names only after establishing the full name.
For learning-oriented and developer content, do not force trademark symbols unless explicitly required; for press, ...

Files:

  • external/README.md
  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/README.md
  • external/nat/examples/email_phishing.py
  • external/nat/fabric-adapter.json
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{md,mdx,rst}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

**/*.{md,mdx,rst}: For NeMo Fabric documentation, verify technical claims against the current repository, public API, or documented command before reviewing style.
Always spell NVIDIA in all caps; do not use Nvidia, nvidia, or NV.
Format commands, code elements, expressions, package names, file names, and paths as inline code.
Use descriptive link text; avoid raw URLs and weak anchors such as here or read more.
Use title case consistently for technical documentation headings.
Introduce code blocks, lists, tables, and images with complete sentences.
Write procedures as imperative, parallel steps; split long procedures into smaller tasks.
Prefer active voice, present tense, short sentences, contractions, and plain English while preserving necessary technical precision.
Use can for possibility and reserve may for permission.
Use after for temporal relationships instead of once, and prefer refer to over see when directing readers to another resource.
Avoid culture-specific idioms, unnecessary Latinisms, jokes, and marketing exaggeration in technical documentation.
Spell out months in body text, avoid ordinal dates, and use clear time zones.
Spell out whole numbers from zero through nine unless they are technical values, parameters, versions, or UI values; use numerals for 10 or greater and commas in thousands.
Do not add trademark symbols to learning-oriented documentation unless the source, platform, or legal guidance explicitly requires them.
Do not replace precise technical terms with simpler words when doing so would lose precision.
Do not flag passive voice when the actor is unknown or the action is the important part.
Do not rewrite API names, package names, command flags, or code literals for style.

**/*.{md,mdx,rst}: Use consistent title case for technical-document headings and table headers; avoid quotation marks, ampersands, and exclamation marks in headings, while preserving official product, event, research, and whitepaper title ...

Files:

  • external/README.md
  • external/nat/README.md
**/*.{md,rst,txt,adoc}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-language-mechanics.md)

**/*.{md,rst,txt,adoc}: For technical documentation, use professional, active, conversational, engaging, precise, and plain-English prose. Prefer active voice, present tense, short sentences, and scannable paragraphs. Avoid casual or imprecise language, swearing, threats, insults, jokes, puns, culture-specific idioms, marketing exaggeration, and unsupported third-party comparisons.
Use can for possibility and reserve may for permission; use after for temporal order; use refer to for cross-references; prefer short direct sentences and specific verbs; avoid unnecessary please in technical documentation.
Prefer active voice when the actor matters. Passive voice is acceptable when the actor is unknown or irrelevant, when the action or result is the focus, or in programmer documentation.
Use natural contractions in conversational technical prose, but do not force them in formal legal copy, API references, or generated text.
Prefer simpler English over Latinisms: use for example or such as instead of e.g., and so on instead of etc., that is instead of i.e., compared to instead of vs., and by, through, or using instead of via. Use industry-standard terms such as in silico, in vitro, and in vivo when appropriate, and italicize them in running text.
Use that without commas for essential clauses, and which with commas for nonessential clauses.
Format dates and times clearly: spell out months in body text; use forms such as June 12, 2025; avoid numeric or ordinal dates; capitalize days; use 12-hour time when appropriate; include a space before a.m. or p.m.; use ET and PT for needed time zones; avoid 24/7; and prefer from 12:30 to 1:00 p.m. for prose ranges.
Format numbers consistently: spell out zero through nine in body text, use numerals for 10 or greater and for technical values, use commas in thousands, do not begin a sentence with a numeral, spell out ordinals, and use numerals consistently within a category wh...

Files:

  • external/README.md
  • external/nat/README.md
**/*.{md,mdx,yml,py,rs,sh}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Keep documentation aligned with current NeMo Fabric behavior, repository layout, entry points, commands, package names, APIs, bindings, and support claims.

Files:

  • external/README.md
  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/README.md
  • external/nat/examples/email_phishing.py
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{md,mdx}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

**/*.{md,mdx}: Use the full product name NVIDIA NeMo Fabric on first use, typically in the title and H1; use NeMo Fabric thereafter. Use fabric alone only for the CLI tool and surround it with backticks.
Treat incorrect or stale commands, package names, paths, APIs, support claims, procedures, examples, terminology, or public behavior documentation as blocking issues.
Capitalize NVIDIA correctly and format code, commands, paths, and filenames as inline code where needed.
Use title case for technical-documentation headings.
Introduce code blocks, tables, and lists with complete lead-in sentences; ensure examples match current APIs and build commands.
Use descriptive anchor text, avoid raw URLs and generic labels such as here, and use repository-relative .mdx paths for links within docs/.
Prefer active voice, present tense, short sentences, plain English, consistent terminology, and imperative, parallel, scannable procedures.
Use after instead of once when expressing temporal sequence, and use can rather than may when describing possibility rather than permission.
Avoid ambiguous numeric dates and ordinal dates in body text.
For learning-oriented documentation, do not force trademark symbols unless the source document explicitly requires them.
When reporting documentation-review findings, lead with Must fix, Should fix, and Nice to have categories; include file path, line reference, current problem, rationale, and a concrete rewrite or direction.

Files:

  • external/README.md
  • external/nat/README.md
**/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update relevant SDK, API reference, adapter, example, integration, and support documentation when the corresponding public surface changes.

Files:

  • external/README.md
  • external/nat/README.md
**/*.{html,md}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

HTML and Markdown files must use the specified SPDX HTML-comment header.

Files:

  • external/README.md
  • external/nat/README.md
{*.md,**/*.md,**/*.mdx,**/*.ipynb}

⚙️ CodeRabbit configuration file

{*.md,**/*.md,**/*.mdx,**/*.ipynb}: Enforce the product name in user-facing prose: use "NVIDIA NeMo Fabric" on first use and "NeMo Fabric" thereafter. Flag standalone capitalized "Fabric" when it refers to the product. Do not flag the lowercase fabric CLI command, package/import/crate names, code identifiers, API symbols, configuration keys, file paths, or unrelated generic uses of the word.

Files:

  • external/README.md
  • external/nat/README.md
**/*.{rs,py,pyi,json,yaml,yml}

📄 CodeRabbit inference engine (.agents/skills/contribute-api/SKILL.md)

Determine and update every affected public surface, including the CLI, PyO3 bindings, Python SDK, type stubs, schemas, and adapter contract, so they remain in parity.

Files:

  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/fabric-adapter.json
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{rs,py}

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

For native binding changes, run cargo check -p fabric-python --locked.

Use snake_case for functions and variables; use PascalCase for Rust types and Python classes.

Files:

  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{py,pyi}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

If Python code or a Python-facing adapter changes, run just test-python.

In Python SDK, adapters, examples, and tests, follow the existing style, use type annotations for public APIs, and keep native binding declarations synchronized with their Rust implementations.

Files:

  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{rs,py,pyi}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

**/*.{rs,py,pyi}: If public configuration types change, confirm schema snapshot tests in just test-rust pass and review generated schema diffs.
For schema or public contract changes, run both language suites and review changes under schemas/ and generated API references.

Files:

  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{py,pyi,rs}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

For Python SDK or PyO3 binding changes, use python-tests, run focused pytest tests first, then just test-python; rebuild with just build-python when native code or packaging changes.

Public contract changes must keep native Python binding declarations synchronized with their Rust implementations.

Files:

  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{rs,py,toml}

📄 CodeRabbit inference engine (.agents/skills/update-project-version/SKILL.md)

When editing version helpers, verify every nemo-fabric-* workspace package through Cargo metadata and reject a static version in python/pyproject.toml.

Files:

  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{toml,rs,py}

📄 CodeRabbit inference engine (.agents/skills/update-project-version/SKILL.md)

Avoid blind repository-wide replacement of version-like strings; distinguish package-version references from examples and unrelated dependency versions.

Files:

  • external/nat/src/nemo_fabric_adapters/nat/__init__.py
  • external/nat/examples/calculator_mcp.py
  • external/nat/examples/email_phishing.py
  • external/nat/examples/calculator.py
  • tests/adapters/test_external_nat_adapter.py
  • external/nat/src/nemo_fabric_adapters/nat/adapter.py
**/*.{json,jsonschema}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Public contract changes must keep checked-in JSON Schema snapshots synchronized.

Files:

  • external/nat/fabric-adapter.json
tests/adapters/**/*.py

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

tests/adapters/**/*.py: If an adapter or integration changes, run its focused tests.
For adapter behavior changes, run focused adapter tests under tests/adapters, then run just test-python.

Files:

  • tests/adapters/test_external_nat_adapter.py
tests/**/*.{rs,py}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

When adding functionality, include tests in the corresponding Rust crate or the relevant area under tests/.

Files:

  • tests/adapters/test_external_nat_adapter.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/skills/python-tests/SKILL.md)

tests/**/*.py: Use pytest to run Python tests.
Do not add @pytest.mark.asyncio to tests; async tests are automatically detected by the async runner.
Do not add -> None return type annotations to test functions.
When mocking a class, use unittest.mock.MagicMock or AsyncMock, using the spec argument when necessary, rather than defining a new class.
Prefix mocked class names with mock, not fake.
Prefer pytest fixtures over helper methods.
If a fixture is needed in multiple test files, define it once in conftest.py rather than repeating it.
Define fixtures using @pytest.fixture(name="<fixture_name>"[, scope="<scope>"]) and a <fixture_name>_fixture function; specify scope only when it is not function.
Prefer pytest.mark.parametrize over separate tests for different input types.
Use @pytest.mark.usefixtures when a fixture is needed but its returned value is unused or it returns no value.
Avoid defensive programming in tests; access expected values directly so missing data raises a clear failure, such as using results["data"] instead of results.get("data").
When adapter installation metadata changes, packaging metadata tests must directly assert that the root project depends unconditionally on the exact-version nemo-fabric-runtime distribution.
Packaging metadata tests must verify that each root harness extra delegates to the matching version of the leaf adapter's harness extra.
Packaging metadata tests must verify that bare leaf dependencies remain adapter-owned and that the root adapter-tests dependency group installs each leaf through its harness extra.
Packaging metadata tests must verify that every leaf provides full; only adapters importing NeMo Relay Python APIs provide relay, while adapters using an external Relay executable have full equal to harness.

Files:

  • tests/adapters/test_external_nat_adapter.py
tests/adapters/test_*.py

📄 CodeRabbit inference engine (.agents/skills/contribute-adapter/SKILL.md)

tests/adapters/test_*.py: Add focused tests for descriptor shape and exact capabilities, positive normalized-surface mappings, rejection of unsupported values and unenforceable policies, result normalization without secret leakage, one-shot execution, continuation, runtime isolation, and the packaged subprocess entry point.
Provide a credential-free fixture covering plan, doctor, and run; keep credential-dependent live-harness tests opt-in while retaining a deterministic CI end-to-end path.

Files:

  • tests/adapters/test_external_nat_adapter.py
{tests/**,python/tests/**}

⚙️ CodeRabbit configuration file

{tests/**,python/tests/**}: Tests should cover the behavior promised by the changed API surface, including error paths, lifecycle cleanup, and SDK/native parity where relevant.

Files:

  • tests/adapters/test_external_nat_adapter.py
🧠 Learnings (1)
📚 Learning: 2026-06-29T22:34:52.407Z
Learnt from: AjayThorve
Repo: NVIDIA/NeMo-Fabric PR: 27
File: adapters/codex-cli/fabric-adapter.json:13-15
Timestamp: 2026-06-29T22:34:52.407Z
Learning: In NeMo-Fabric adapter manifest files (e.g., `*/fabric-adapter.json`), keep `config.accepts` limited to the top-level Fabric capability sections that `resolve_capability_plan` consumes (such as `models`, `tools`, `mcp`, `skills`, `telemetry`). Do not add adapter-owned `harness.settings` keys to `config.accepts`; `harness.settings` should remain adapter-owned and be passed through unchanged.

Applied to files:

  • external/nat/fabric-adapter.json
🪛 ast-grep (0.45.0)
external/nat/examples/email_phishing.py

[info] 90-90: use jsonify instead of json.dumps for JSON output
Context: json.dumps(output.to_mapping(), indent=2)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

external/nat/examples/calculator.py

[info] 85-85: use jsonify instead of json.dumps for JSON output
Context: json.dumps(output.to_mapping(), indent=2)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

tests/adapters/test_external_nat_adapter.py

[info] 904-904: use jsonify instead of json.dumps for JSON output
Context: json.dumps(result)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 928-928: use jsonify instead of json.dumps for JSON output
Context: json.dumps(result)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

🪛 Ruff (0.16.1)
external/nat/examples/calculator_mcp.py

[warning] 39-39: Avoid specifying long messages outside the exception class

(TRY003)

tests/adapters/test_external_nat_adapter.py

[warning] 33-33: Dynamically typed expressions (typing.Any) are disallowed in **settings

(ANN401)


[warning] 180-180: Dynamically typed expressions (typing.Any) are disallowed in input_value

(ANN401)


[warning] 182-182: Dynamically typed expressions (typing.Any) are disallowed in context

(ANN401)


[warning] 183-183: Dynamically typed expressions (typing.Any) are disallowed in raw_request

(ANN401)

external/nat/src/nemo_fabric_adapters/nat/adapter.py

[warning] 59-59: Dynamically typed expressions (typing.Any) are disallowed in **metadata

(ANN401)


[warning] 73-73: Dynamically typed expressions (typing.Any) are disallowed in value

(ANN401)


[warning] 176-176: Too many branches (13 > 12)

(PLR0912)


[warning] 288-288: Dynamically typed expressions (typing.Any) are disallowed in value

(ANN401)


[warning] 305-305: Dynamically typed expressions (typing.Any) are disallowed in server

(ANN401)


[warning] 551-551: Too many branches (14 > 12)

(PLR0912)


[warning] 705-705: Dynamically typed expressions (typing.Any) are disallowed in build_nat_config

(ANN401)


[warning] 733-733: Prefer TypeError exception for invalid type

(TRY004)


[warning] 733-733: Avoid specifying long messages outside the exception class

(TRY003)


[warning] 745-747: Avoid specifying long messages outside the exception class

(TRY003)


[warning] 752-752: Dynamically typed expressions (typing.Any) are disallowed in response

(ANN401)


[warning] 785-785: Do not catch blind exception: Exception

(BLE001)


[warning] 786-789: Use logging.exception instead of logging.error

Replace with exception

(TRY400)


[warning] 865-869: Use a single with statement with multiple contexts instead of nested with statements

(SIM117)


[warning] 873-873: Do not catch blind exception: Exception

(BLE001)


[warning] 874-877: Use logging.exception instead of logging.error

Replace with exception

(TRY400)


[warning] 888-891: Use logging.exception instead of logging.error

Replace with exception

(TRY400)

🔇 Additional comments (15)
external/README.md (1)

1-19: LGTM!

external/nat/fabric-adapter.json (1)

83-94: LGTM!

external/nat/src/nemo_fabric_adapters/nat/__init__.py (1)

1-4: LGTM!

external/nat/src/nemo_fabric_adapters/nat/adapter.py (5)

339-345: LGTM!


176-257: LGTM!


288-302: LGTM!

Also applies to: 398-483, 508-684


780-914: LGTM!


705-725: LGTM!

external/nat/README.md (1)

16-45: LGTM!

Also applies to: 53-71, 73-118

tests/adapters/test_external_nat_adapter.py (2)

41-196: LGTM!


199-957: LGTM!

Also applies to: 1015-1023

external/nat/examples/calculator_mcp.py (2)

14-44: LGTM!


8-13: 📐 Maintainability & Code Quality

No change is needed.

The locked MCP Python SDK 1.28.1 exports FastMCP from mcp.server.fastmcp and supports the called tool decorator form.

			> Likely an incorrect or invalid review comment.
external/nat/examples/calculator.py (1)

27-90: LGTM!

external/nat/examples/email_phishing.py (1)

26-95: LGTM!

Comment thread external/nat/README.md
Comment thread external/nat/src/nemo_fabric_adapters/nat/adapter.py
Comment thread tests/adapters/test_external_nat_adapter.py
Comment thread tests/adapters/test_external_nat_adapter.py
@AjayThorve
AjayThorve marked this pull request as ready for review August 6, 2026 06:22
@AjayThorve
AjayThorve requested a review from a team as a code owner August 6, 2026 06:22
@coderabbitai coderabbitai Bot mentioned this pull request Aug 6, 2026
2 tasks
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
@zhongxuanwang-nv
zhongxuanwang-nv force-pushed the fix/nat-mcp-stdio-configuration branch from f9f9699 to 3d9f36c Compare August 6, 2026 17:03
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@zhongxuanwang-nv
zhongxuanwang-nv marked this pull request as draft August 6, 2026 17:03
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
@zhongxuanwang-nv
zhongxuanwang-nv marked this pull request as ready for review August 6, 2026 17:31
@zhongxuanwang-nv

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit 0207e06 into NVIDIA:main Aug 7, 2026
33 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants