Skip to content

Add periodictable MCP tool - #1414

Closed
tamohannes wants to merge 9 commits into
NVIDIA-NeMo:mainfrom
tamohannes:feat/periodictable-mcp-tool
Closed

tamohannes wants to merge 9 commits into
NVIDIA-NeMo:mainfrom
tamohannes:feat/periodictable-mcp-tool

Conversation

@tamohannes

@tamohannes tamohannes commented May 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add a built-in periodictable MCP tool for element, isotope, and neutron scattering lookup.
  • Document the new built-in tool in the agentic inference tool-calling guide.
  • Add MCP client tests for tool configuration and stdio tool listing.

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

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Added a periodic table lookup tool returning element and isotope details (atomic mass/number, optional density/crystal structure, natural isotopes, and optional neutron scattering/absorption data).
  • Documentation

    • Updated built-in tools reference to include the new periodic table lookup.
  • Tests

    • Added tests to ensure the tool is discoverable and lists expected tool names.
  • Chores

    • CI workflow updates for conditional registry auth, dependency extras, build retry/cache behavior, and tightened test selection.

@coderabbitai

coderabbitai Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new MCP stdio server wrapping the periodictable library providing element-info and isotope-info tools, documents the tool, adds async tests for the MCP client, and updates CI to conditionally handle GHCR login, install the tools extra, optionally enable buildx cache, and exclude live tests.

Changes

Cohort / File(s) Summary
Documentation
docs/agentic_inference/tool_calling.md
Added PeriodictableTool to the built-in tools reference.
MCP Server Implementation
nemo_skills/mcp/servers/periodictable_tool.py
New stdio MCP server module providing element-info and isotope-info tools; looks up elements/isotopes via periodictable, formats outputs, handles missing fields, defines PeriodictableTool(MCPClientTool) and main().
Tests
tests/test_mcp_clients.py
Added async test for PeriodictableTool verifying stdio client configuration and that list_tools() exposes element-info and isotope-info; ensures shutdown in finally block.
CI Workflow
.github/workflows/tests.yml
Gate GHCR login/build steps on GHCR_PAT, install .[dev,tools], add retry_docker_build, make buildx cache flags conditional on token, and change pytest marker to exclude gpu and live; add fork-safe MCP test step when GHCR absent.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant MCPServer as "Periodictable\n(stdio server)"
    participant Lib as "periodictable\nlibrary"
    Client->>MCPServer: start stdio server (python -m nemo_skills.mcp.servers.periodictable_tool)
    Client->>MCPServer: list_tools() / call `element-info` or `isotope-info`
    MCPServer->>Lib: lookup element / isotope data
    Lib-->>MCPServer: element/isotope properties (or not found)
    MCPServer-->>Client: formatted result or not-found message
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 periodictable MCP tool' accurately and concisely describes the main change: introducing a new periodictable MCP tool for element/isotope/scattering lookups, which is reflected in the new module, documentation, tests, and workflow updates.
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 unit tests (beta)
  • Create PR with unit tests

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

@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.

Hi @tamohannes , Thank you for the contributions! I would encourage you to please switch to a tool path that avoids the MCP protocol (we have found it to cause real latency and stability issues during RL) in favor of a direct tool approach. The changes should be fairly minimal--please see the DirectPythonTool for an example.

@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 @.github/workflows/tests.yml:
- Around line 26-27: The step "Login to GHCR" is gated with an invalid
step-level conditional using secrets (if: ${{ secrets.GHCR_PAT != '' }});
instead populate an environment variable from the secret (e.g., set GHCR_PAT:
${{ secrets.GHCR_PAT }} at the job or workflow env level) and change the step
conditional to use the env context (if: env.GHCR_PAT != '') so the step can be
properly gated; update the "Login to GHCR" step to reference env.GHCR_PAT rather
than secrets.GHCR_PAT.
🪄 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: 5263bcab-ebbd-4579-af37-fdd2018d5c47

📥 Commits

Reviewing files that changed from the base of the PR and between 14e8b6a and 94bfacb.

📒 Files selected for processing (1)
  • .github/workflows/tests.yml

Comment thread .github/workflows/tests.yml Resolved
Signed-off-by: tamohannes <[email protected]>
@tamohannes
tamohannes force-pushed the feat/periodictable-mcp-tool branch from 94bfacb to 77a2cb3 Compare May 1, 2026 19:03

@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.

♻️ Duplicate comments (1)
.github/workflows/tests.yml (1)

26-33: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use env for GHCR gating; step-level if should not reference secrets directly.

This can break workflow validation and block CI execution. Switch the gate to env.GHCR_PAT.

Suggested patch
     - name: Login to GHCR
-      if: ${{ secrets.GHCR_PAT != '' }}
+      env:
+        GHCR_PAT: ${{ secrets.GHCR_PAT }}
+      if: ${{ env.GHCR_PAT != '' }}
       uses: docker/login-action@v3
       with:
         registry: ghcr.io
         username: ${{ github.actor }}
-        password: ${{ secrets.GHCR_PAT }}
+        password: ${{ env.GHCR_PAT }}
#!/bin/bash
set -euo pipefail

# 1) Quick pattern check for disallowed direct `secrets` usage in step-level `if`
rg -nP '^\s*if:\s*\$\{\{\s*secrets\.' .github/workflows/tests.yml || true

# 2) Full workflow lint check if actionlint is available
if command -v actionlint >/dev/null 2>&1; then
  actionlint .github/workflows/tests.yml
else
  echo "actionlint not installed; install it to validate context availability rules."
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/tests.yml around lines 26 - 33, The step "Login to GHCR"
currently uses a step-level conditional referencing secrets (if: ${{
secrets.GHCR_PAT != '' }}), which is invalid; instead expose GHCR_PAT as an
environment variable (e.g., set env.GHCR_PAT: ${{ secrets.GHCR_PAT }} at the job
or workflow level) and change the step conditional to reference env.GHCR_PAT
(if: ${{ env.GHCR_PAT != '' }}); update the "Login to GHCR" step that uses
docker/login-action@v3 to use the new env variable for gating and keep the
password value as ${{ secrets.GHCR_PAT }} in the step inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/tests.yml:
- Around line 26-33: The step "Login to GHCR" currently uses a step-level
conditional referencing secrets (if: ${{ secrets.GHCR_PAT != '' }}), which is
invalid; instead expose GHCR_PAT as an environment variable (e.g., set
env.GHCR_PAT: ${{ secrets.GHCR_PAT }} at the job or workflow level) and change
the step conditional to reference env.GHCR_PAT (if: ${{ env.GHCR_PAT != '' }});
update the "Login to GHCR" step that uses docker/login-action@v3 to use the new
env variable for gating and keep the password value as ${{ secrets.GHCR_PAT }}
in the step inputs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8f4b2aed-063d-48e5-be96-46f7191c8e7a

📥 Commits

Reviewing files that changed from the base of the PR and between 94bfacb and 77a2cb3.

📒 Files selected for processing (4)
  • .github/workflows/tests.yml
  • 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 (2)
  • docs/agentic_inference/tool_calling.md
  • nemo_skills/mcp/servers/periodictable_tool.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_mcp_clients.py

@tamohannes

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tamohannes

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tamohannes

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tamohannes

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tamohannes

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tamohannes

Copy link
Copy Markdown
Collaborator Author

Updated this PR to use the direct \ path instead of launching a stdio MCP server. The PR diff is now limited to the tool implementation, docs reference, and focused tests; workflow/pyproject changes were removed. @coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@tamohannes Sure! I'll kick off a fresh review of the updated PR changes — tool implementation, docs reference, and focused tests.

[review]

@tamohannes

Copy link
Copy Markdown
Collaborator Author

Updated this PR to use the direct Tool path instead of launching a stdio MCP server. The PR diff is now limited to the tool implementation, docs reference, and focused tests; workflow/pyproject changes were removed. @coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@tamohannes Sure! I'll kick off a fresh review of the updated PR — focusing on the direct Tool path implementation, docs reference, and the focused tests now that the workflow/pyproject changes have been removed.

[review]

@tamohannes

Copy link
Copy Markdown
Collaborator Author

Updated to the direct Tool implementation path (no stdio MCP server/client). The final diff is scoped to the tool file, docs reference, and focused tests only. @coderabbitai review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@tamohannes Sure! Kicking off a fresh review of the updated PR — scoped to the direct Tool implementation, docs reference, and focused tests.

[review]

@tamohannes

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #1421, reopened from an internal NVIDIA-NeMo/Skills branch so CI can access repository secrets.

@tamohannes tamohannes closed this May 2, 2026
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