Skip to content

Add periodictable MCP tool - #1421

Merged
tamohannes merged 11 commits into
mainfrom
feat/periodictable-mcp-tool
May 2, 2026
Merged

tamohannes merged 11 commits into
mainfrom
feat/periodictable-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 periodictable MCP tool #1414.
  • Add a built-in periodictable MCP tool for element, isotope, and neutron scattering lookup.
  • Document the new built-in tool and add focused MCP client tests.

Test plan

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

Summary by CodeRabbit

  • New Features

    • Added a periodic table lookup tool for element and isotope details, including atomic properties, optional neutron scattering data, and natural isotope abundances.
  • Documentation

    • Updated the built-in tools reference to list the periodic table lookup tool.
  • Tests

    • Added tests verifying tool configuration and that element/isotope capabilities are listed.

tamohannes added 9 commits May 1, 2026 12:02
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
…-mcp-tool

Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
@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: 68cc6372-2f1e-4bcb-9266-24806588f083

📥 Commits

Reviewing files that changed from the base of the PR and between 1b7857d and e5aa60b.

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

📝 Walkthrough

Walkthrough

Adds a new MCP-compatible tool module nemo_skills.mcp.servers.periodictable_tool that provides element-info and isotope-info lookups backed by the periodictable library; adds tests for the tool and a single docs bullet referencing it.

Changes

PeriodictableTool Feature

Layer / File(s) Summary
Data / Helpers
nemo_skills/mcp/servers/periodictable_tool.py
New _resolve_element(name_or_symbol) helper that finds elements by name, symbol, or atomic number.
Core Implementation
nemo_skills/mcp/servers/periodictable_tool.py
Adds element_info(element: str) -> str and isotope_info(element: str, mass_number: int) -> str that format element/isotope details (mass, density/crystal when available, neutron scattering fields when present, and natural isotope lists).
MCP Tool Adapter
nemo_skills/mcp/servers/periodictable_tool.py
Adds PeriodictableTool(Tool) with _config, default_config(), configure(), list_tools() exposing JSON input schemas for element-info and isotope-info, and execute() dispatcher routing to the lookup functions or returning an unknown-tool error.
Tests
tests/test_mcp_clients.py
Adds TestPeriodictableTool with test_periodictable_tool_config (asserts default_config() is {}) and test_periodictable_direct_list_tools (configures tool, calls list_tools(), asserts both tool names are present).
Documentation
docs/agentic_inference/tool_calling.md
Adds a single bullet in "Built-in Tools" referencing nemo_skills.mcp.servers.periodictable_tool.PeriodictableTool and noting the periodictable dependency.

Sequence Diagram

sequenceDiagram
participant Client
participant PeriodictableTool
participant PeriodictableLib
Client->>PeriodictableTool: call execute(tool_name, arguments)
PeriodictableTool->>PeriodictableTool: normalize & dispatch
PeriodictableTool->>PeriodictableLib: resolve element / fetch isotope data
PeriodictableLib-->>PeriodictableTool: element/isotope data
PeriodictableTool-->>Client: formatted string result or error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% 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 accurately and concisely summarizes the main change: adding a new periodictable MCP tool. It is clear, specific, and directly related to 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/periodictable-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: 3

🤖 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 duplicate bullet for PeriodictableTool: keep a
single entry for nemo_skills.mcp.servers.periodictable_tool.PeriodictableTool
and delete the repeated line so the built-in tools list contains only one
description (choose the clearer wording: "Element, isotope, and neutron
scattering lookup via periodictable (requires `periodictable`)"). Ensure the
remaining bullet uses the correct fully-qualified symbol PeriodictableTool and
its GitHub link.

In `@nemo_skills/mcp/servers/periodictable_tool.py`:
- Around line 66-76: The AttributeError except blocks in periodictable_tool.py
(around the blocks that inspect el.neutron and the later block at lines
~107-118) silently swallow unexpected structure issues; replace the try/except
with explicit attribute probes (e.g., check hasattr(el, "neutron") and then use
getattr(el.neutron, "b_c", None) / getattr(..., "coherent", None) etc.) and only
append lines when those attributes are present and not None; apply the same
pattern to the second neutron-reading block so unexpected AttributeError is not
hidden and real bugs fail fast.
- Line 45: The symbol comparison is case-sensitive (s == el.symbol) causing
inputs like "fe" to miss; update the matching logic in the lookup (the
conditional using s, el.name, el.symbol, el.number) to compare symbol
case-insensitively by normalizing both sides (e.g., compare s.lower() to
el.symbol.lower()), keeping the existing checks for name and number intact so
name/number matching still works.
🪄 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: 888cc25f-4fb1-40db-9656-dad7e7da0442

📥 Commits

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

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

Comment thread docs/agentic_inference/tool_calling.md Resolved

@gwarmstrong gwarmstrong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
@tamohannes
tamohannes force-pushed the feat/periodictable-mcp-tool branch from 1b7857d to 038f763 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/periodictable_tool.py`:
- Around line 127-130: The configure method currently accepts any keys and
stores them in self._config even though list_tools() and execute() don't use
them; change configure (in class PeriodicTableTool) to validate overrides
against an explicit allowed set (e.g., allowed keys like "some_known_key1",
"some_known_key2" or the actual config fields used by list_tools/execute) and
raise ValueError for any unknown keys so typos/misconfigurations fail fast, or
alternatively implement real consumption by mapping allowed keys into the fields
used by list_tools() and execute(); update the method that references
self._config (list_tools and execute) to read only those validated keys.
🪄 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: 09387e7b-3855-4cd7-9e5c-50c63b7b0ab0

📥 Commits

Reviewing files that changed from the base of the PR and between 484a684 and 1b7857d.

📒 Files selected for processing (2)
  • docs/agentic_inference/tool_calling.md
  • nemo_skills/mcp/servers/periodictable_tool.py
✅ Files skipped from review due to trivial changes (1)
  • docs/agentic_inference/tool_calling.md

Comment on lines +127 to +130
def configure(self, overrides: dict[str, Any] | None = None, context: dict[str, Any] | None = None) -> None:
if overrides:
self._config.update(overrides)

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Reject unsupported configure() overrides instead of silently storing dead config

Line 128-Line 130 currently accepts any override key, but those values never affect list_tools() or execute(). This can hide typos/misconfiguration. Fail fast when overrides are provided (or implement real config consumption).

Suggested fix
 class PeriodictableTool(Tool):
     def __init__(self) -> None:
-        self._config: dict[str, Any] = {}
+        self._config: dict[str, Any] = {}

     def default_config(self) -> dict[str, Any]:
-        return dict(self._config)
+        return {}

     def configure(self, overrides: dict[str, Any] | None = None, context: dict[str, Any] | None = None) -> None:
-        if overrides:
-            self._config.update(overrides)
+        if overrides:
+            keys = ", ".join(sorted(overrides))
+            raise ValueError(f"Unsupported config for PeriodictableTool: {keys}")

As per coding guidelines, "Avoid cases where user-passed parameters are unused; code should fail if user specifies an unsupported argument or if a required argument is missing. Use dataclass or **kwargs syntax to handle this automatically".

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

In `@nemo_skills/mcp/servers/periodictable_tool.py` around lines 127 - 130, The
configure method currently accepts any keys and stores them in self._config even
though list_tools() and execute() don't use them; change configure (in class
PeriodicTableTool) to validate overrides against an explicit allowed set (e.g.,
allowed keys like "some_known_key1", "some_known_key2" or the actual config
fields used by list_tools/execute) and raise ValueError for any unknown keys so
typos/misconfigurations fail fast, or alternatively implement real consumption
by mapping allowed keys into the fields used by list_tools() and execute();
update the method that references self._config (list_tools and execute) to read
only those validated keys.

Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
@tamohannes
tamohannes merged commit 3b89f08 into main May 2, 2026
5 checks passed
@tamohannes
tamohannes deleted the feat/periodictable-mcp-tool branch May 2, 2026 04:21
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 `PeriodictableTool`
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#1421.

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

## Test plan

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

---------

Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Co-authored-by: Christian Munley <cmunley@nvidia.com>
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 `PeriodictableTool`
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#1421.

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

## Test plan

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

---------

Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
Co-authored-by: Christian Munley <cmunley@nvidia.com>
Signed-off-by: Rita Fernandes Neves <rfernandesne@nvidia.com>
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