Skip to content

Conversation

@willkill07
Copy link
Member

@willkill07 willkill07 commented Oct 23, 2025

Description

nat mcp serve --tool_names only filtered based on function names.
This should be expanded to support function group names as well.

Closes

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features
    • Enhanced function registration now supports group prefix-based filtering alongside exact name matching, providing more flexible organization and selection of available functions.

@willkill07 willkill07 self-assigned this Oct 23, 2025
@willkill07 willkill07 requested a review from a team as a code owner October 23, 2025 14:32
@willkill07 willkill07 added improvement Improvement to existing functionality non-breaking Non-breaking change labels Oct 23, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 23, 2025

Walkthrough

The filtering logic for selecting functions to register in the MCP front-end plugin worker now supports tool_names acting as function group prefixes. Functions are included if their exact name appears in tool_names or if their name starts with a group prefix derived from tool_names.

Changes

Cohort / File(s) Summary
Function filtering logic enhancement
src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py
Extended filtering criteria to support prefix-based group matching in addition to exact name matching when registering functions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title Check ✅ Passed The title "feat(mcp): allow MCP Server --tool_name filter to reference function groups" is fully aligned with the main changeset, which extends the filtering logic to support tool_names acting as function group prefixes in addition to exact function name matching. The title uses imperative mood with the verb "allow" and clearly summarizes the functional change. The title is 77 characters, which exceeds the approximate 72-character guideline by 5 characters, but this minor overage is reasonable given that the tilde (~) in the requirement suggests the limit is flexible, and the descriptive accuracy of the title is well-maintained within that slight excess.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py (1)

213-213: Consider adding return type hint for consistency with coding guidelines.

The method signature is missing a return type hint. Per the coding guidelines, all public APIs should have type hints on both parameters and return values.

-    async def add_routes(self, mcp: FastMCP, builder: WorkflowBuilder):
+    async def add_routes(self, mcp: FastMCP, builder: WorkflowBuilder) -> None:

Note: The abstract method at line 80 would also need the same update for consistency.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc2b84b and 049906f.

📒 Files selected for processing (1)
  • src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.py: In code comments use the abbreviations: nat (API namespace/CLI), nvidia-nat (package), NAT (env var prefixes); never use these abbreviations in documentation
Follow PEP 20 and PEP 8 for Python style
Run yapf with column_limit=120; yapf is used for formatting (run second)
Indent with 4 spaces (no tabs) and end each file with a single trailing newline
Use ruff (ruff check --fix) as a linter (not formatter) per pyproject.toml; fix warnings unless explicitly ignored
Respect Python naming schemes: snake_case for functions/variables, PascalCase for classes, UPPER_CASE for constants
When re-raising exceptions, use bare raise to preserve stack trace; log with logger.error(), not logger.exception()
When catching and logging without re-raising, use logger.exception() to capture full stack trace
Provide Google-style docstrings for every public module, class, function, and CLI command
Docstring first line must be a concise description ending with a period
Validate and sanitize all user input, especially in web or CLI interfaces
Prefer httpx with SSL verification enabled by default and follow OWASP Top-10 recommendations
Use async/await for I/O-bound work (HTTP, DB, file I/O)
Cache expensive computations with functools.lru_cache or an external cache when appropriate
Leverage NumPy vectorized operations when beneficial and feasible

Files:

  • src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py
{src/**/*.py,packages/*/src/**/*.py}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{src/**/*.py,packages/*/src/**/*.py}: All importable Python code must live under src/ or packages//src/
All public APIs must have Python 3.11+ type hints on parameters and return values
Prefer typing/collections.abc abstractions (e.g., Sequence over list)
Use typing.Annotated for units or metadata when useful
Treat pyright warnings as errors during development

Files:

  • src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py
src/nat/**/*

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

src/nat/**/* contains core functionality; changes should prioritize backward compatibility

Files:

  • src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py

⚙️ CodeRabbit configuration file

This directory contains the core functionality of the toolkit. Changes should prioritize backward compatibility.

Files:

  • src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py
{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}: Every file must start with the standard SPDX Apache-2.0 header
Confirm copyright years are up to date when a file is changed
All source files must include the SPDX Apache-2.0 header template (copy from an existing file)

Files:

  • src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Files:

  • src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: CI Pipeline / Check
🔇 Additional comments (1)
src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py (1)

236-241: LGTM! The filtering logic correctly supports both exact function names and function group prefixes.

The implementation properly handles both use cases:

  • Exact function name matching (line 236) preserves backward compatibility
  • Function group prefix matching (line 239) enables the new feature using dot notation

The use of f"{group_name}." ensures proper prefix matching and prevents false positives (e.g., "group" won't incorrectly match "grouped.func").

Signed-off-by: Will Killian <[email protected]>
@willkill07 willkill07 changed the title fix: allow MCP Server --tool_name filter to reference function groups feat(mcp): allow MCP Server --tool_name filter to reference function groups Oct 23, 2025
@willkill07
Copy link
Member Author

/merge

@rapids-bot rapids-bot bot merged commit f2615a3 into NVIDIA:release/1.3 Oct 23, 2025
17 checks passed
@willkill07 willkill07 deleted the wkk_allow-mcp-tool-name-filter-to-reference-function-groups branch October 23, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement to existing functionality non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants