Skip to content

Add particle MCP tool - #1422

Merged
tamohannes merged 12 commits into
mainfrom
feat/particle-mcp-tool
May 2, 2026
Merged

tamohannes merged 12 commits into
mainfrom
feat/particle-mcp-tool

Conversation

@tamohannes

@tamohannes tamohannes commented May 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Reopened from an internal NVIDIA-NeMo/Skills branch so CI can access repository secrets.
  • Replaces Add particle MCP tool #1415.
  • Add a built-in particle MCP tool for PDG particle lookup and search.
  • Document the new built-in tool and add focused MCP client tests.

Test plan

  • python -m py_compile nemo_skills/mcp/servers/particle_tool.py
  • python -m pytest tests/test_mcp_clients.py::TestParticleTool -q --tb=short
  • python -m pytest tests/test_mcp_clients.py -q --tb=short

Summary by CodeRabbit

  • New Features

    • Added particle property lookup and search, enabling queries by name or PDG ID with mass, charge, spin, lifetime and quantum numbers.
  • Documentation

    • Added reference docs for the new particle lookup/search tool (notes it requires the particle package).
  • Tests

    • Added tests for the particle tool’s configuration, tool listing, and rejection of unsupported extra arguments.

@coderabbitai

coderabbitai Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7b5b8895-bac1-4551-ae6e-30bd50fd0fb1

📥 Commits

Reviewing files that changed from the base of the PR and between cb2990d and 7bdc40e.

📒 Files selected for processing (2)
  • docs/agentic_inference/tool_calling.md
  • tests/test_mcp_clients.py
✅ Files skipped from review due to trivial changes (2)
  • docs/agentic_inference/tool_calling.md
  • tests/test_mcp_clients.py

📝 Walkthrough

Walkthrough

Adds a new MCP tool module exposing PDG particle lookups and name-based search via the particle package, plus tests and a docs reference entry.

Changes

Particle Tool Implementation

Layer / File(s) Summary
Core & Constants
nemo_skills/mcp/servers/particle_tool.py
Adds logging, MAX_SEARCH_RESULTS = 10, and _format_particle(p) to render particle properties as Markdown.
Lookup & Search Functions
nemo_skills/mcp/servers/particle_tool.py
Adds particle_lookup(name_or_id) (attempts PDG ID parse → Particle.from_name → Particle.findall) and particle_search(query) (uses Particle.findall, truncates to 10, formats results).
Tool Wrapper & Wiring
nemo_skills/mcp/servers/particle_tool.py
Adds ParticleTool(Tool) with default_config(), configure() (rejects unsupported overrides), async list_tools() registering particle-lookup and particle-search, and async execute() dispatching to the lookup/search functions and rejecting extra_args.
Tests
tests/test_mcp_clients.py
Adds TestParticleTool asserting default_config() == {}, list_tools() includes both tools, and that execute(..., extra_args=...) raises ValueError about unsupported extra_args.
Documentation
docs/agentic_inference/tool_calling.md
Adds a Built-in Tools entry documenting nemo_skills.mcp.servers.particle_tool.ParticleTool and noting it requires the particle package.

Sequence Diagram

sequenceDiagram
  participant Client
  participant ParticleTool
  participant ParticlePkg

  Client->>ParticleTool: call "particle-lookup" or "particle-search" with args
  ParticleTool->>ParticlePkg: resolve by PDG ID or name / call findall(query)
  ParticlePkg-->>ParticleTool: particle object(s) or empty result
  ParticleTool-->>Client: formatted Markdown result or "not found" message
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add particle MCP tool' clearly and concisely describes the main change: introducing a new particle physics lookup tool for the MCP framework. It directly summarizes the primary contribution of the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/particle-mcp-tool

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/test_mcp_clients.py (1)

1010-1025: ⚡ Quick win

Add execute-path tests for ParticleTool (not just registration).

Current tests validate configuration and tool names, but not dispatch correctness. Please add coverage for:

  • execute("particle-lookup", ...) and execute("particle-search", ...) routing
  • unknown tool handling
  • argument validation (missing/extra args)

Using monkeypatch on particle_lookup / particle_search keeps these unit tests deterministic.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_mcp_clients.py` around lines 1010 - 1025, Add unit tests that
exercise ParticleTool.execute routing and argument validation: instantiate
ParticleTool, call configure(), then monkeypatch the underlying functions
particle_lookup and particle_search to simple async stubs and assert
execute("particle-lookup", args) and execute("particle-search", args) call the
correct stub and return expected values; also test execute with an unknown tool
name raises the expected error/exception and test argument validation by calling
execute with missing and extra args to assert it rejects invalid argument
shapes. Use the existing test structure in TestParticleTool and the methods
ParticleTool.list_tools, ParticleTool.execute, and the module-level
particle_lookup/particle_search names so tests remain deterministic via
monkeypatching.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/agentic_inference/tool_calling.md`:
- Around line 374-375: Remove the duplicated bullet for
nemo_skills.mcp.servers.particle_tool.ParticleTool in
docs/agentic_inference/tool_calling.md by deleting the redundant list item so
only one entry for ParticleTool remains (keep the existing link and description
for ParticleTool and ensure surrounding list formatting is unchanged).

In `@nemo_skills/mcp/servers/particle_tool.py`:
- Around line 119-122: The configure method currently accepts arbitrary
overrides and silently stores them in self._config; change it to validate
overrides against the tool's supported keys and reject unknown keys: in
configure (method configure on the Particle tool class) check that overrides is
a dict, compute unknown = set(overrides) - set(self._config.keys()) (or against
an explicit allowed_keys set if present), and if unknown is non-empty raise a
ValueError listing the unsupported keys; otherwise update self._config with the
validated overrides so only supported config keys are accepted.

---

Nitpick comments:
In `@tests/test_mcp_clients.py`:
- Around line 1010-1025: Add unit tests that exercise ParticleTool.execute
routing and argument validation: instantiate ParticleTool, call configure(),
then monkeypatch the underlying functions particle_lookup and particle_search to
simple async stubs and assert execute("particle-lookup", args) and
execute("particle-search", args) call the correct stub and return expected
values; also test execute with an unknown tool name raises the expected
error/exception and test argument validation by calling execute with missing and
extra args to assert it rejects invalid argument shapes. Use the existing test
structure in TestParticleTool and the methods ParticleTool.list_tools,
ParticleTool.execute, and the module-level particle_lookup/particle_search names
so tests remain deterministic via monkeypatching.
🪄 Autofix (Beta)

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: CHILL

Plan: Enterprise

Run ID: 702cea0f-e173-4079-af4a-154508357e9a

📥 Commits

Reviewing files that changed from the base of the PR and between 6877a00 and f8d22b5.

📒 Files selected for processing (3)
  • docs/agentic_inference/tool_calling.md
  • nemo_skills/mcp/servers/particle_tool.py
  • tests/test_mcp_clients.py

Comment thread docs/agentic_inference/tool_calling.md Resolved
@tamohannes
tamohannes force-pushed the feat/particle-mcp-tool branch from b75b80b to 7b8fdff Compare May 2, 2026 00:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nemo_skills/mcp/servers/particle_tool.py`:
- Around line 146-152: The execute method currently ignores the extra_args
parameter which can hide unsupported caller-supplied params; update execute (the
async method named execute) to validate extra_args and fail fast when it is
non-empty (e.g., raise ValueError or return a clear error) before dispatching to
particle_lookup(**arguments) or particle_search(**arguments); ensure the check
references the extra_args symbol and returns/errors immediately so callers know
unsupported extra args were provided.
🪄 Autofix (Beta)

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: CHILL

Plan: Enterprise

Run ID: 3526d683-a31c-45aa-85f6-a842a5340ab6

📥 Commits

Reviewing files that changed from the base of the PR and between f8d22b5 and b75b80b.

📒 Files selected for processing (2)
  • docs/agentic_inference/tool_calling.md
  • nemo_skills/mcp/servers/particle_tool.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/agentic_inference/tool_calling.md

@tamohannes
tamohannes merged commit f9d6f20 into main May 2, 2026
5 checks passed
@tamohannes
tamohannes deleted the feat/particle-mcp-tool branch May 2, 2026 05:05
cmunley1 added a commit to NVIDIA-NeMo/Gym that referenced this pull request Jun 16, 2026
## Summary

- Add a NeMo-Gym `ns_tools` config that exposes `ParticleTool` through
the existing NeMo-Skills ToolManager bridge.
- Add a focused config test to keep the resource-server wiring valid.
- This is the Gym-side companion to NVIDIA-NeMo/Skills#1422.

Replaces fork-origin PR #1220 so CI can run with full repository
secrets.

## Test plan

- `PYTHONPATH=. python -m pytest
resources_servers/ns_tools/tests/test_particle_mcp_config.py -q
--tb=short`

---------

Signed-off-by: tamohannes <[email protected]>
Co-authored-by: Christian Munley <[email protected]>
ritaneves pushed a commit to NVIDIA-NeMo/Gym that referenced this pull request Jun 25, 2026
## Summary

- Add a NeMo-Gym `ns_tools` config that exposes `ParticleTool` through
the existing NeMo-Skills ToolManager bridge.
- Add a focused config test to keep the resource-server wiring valid.
- This is the Gym-side companion to NVIDIA-NeMo/Skills#1422.

Replaces fork-origin PR #1220 so CI can run with full repository
secrets.

## Test plan

- `PYTHONPATH=. python -m pytest
resources_servers/ns_tools/tests/test_particle_mcp_config.py -q
--tb=short`

---------

Signed-off-by: tamohannes <[email protected]>
Co-authored-by: Christian Munley <[email protected]>
Signed-off-by: Rita Fernandes Neves <[email protected]>
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