Skip to content

[Feature] MCP and HTTP tools, agentic tutorial, see-also pointers#3737

Open
vmoens wants to merge 2 commits into
gh/vmoens/268/basefrom
gh/vmoens/268/head
Open

[Feature] MCP and HTTP tools, agentic tutorial, see-also pointers#3737
vmoens wants to merge 2 commits into
gh/vmoens/268/basefrom
gh/vmoens/268/head

Conversation

@vmoens
Copy link
Copy Markdown
Collaborator

@vmoens vmoens commented May 10, 2026

Stack from ghstack (oldest at bottom):

Adds the remaining built-ins, a sphinx-gallery tutorial, and soft
"see also" pointers in the legacy classes' docstrings. No
DeprecationWarning is emitted -- legacy transforms keep working
unchanged, and the as_tool() adapter from the previous commit gives
users a soft migration path.

New tools under torchrl.envs.llm.agentic.tools:

  • MCPToolset / MCPServerConfig: connects to an MCP server over stdio
    and materialises remote tools as N native Tool instances, each with
    the server's auto-discovered input_schema. Replaces the legacy
    MCPToolTransform's background-thread plumbing with native asyncio.
    Optional dependency on the 'mcp' package.
  • HttpTool: stdlib-only async HTTP via urllib.request offloaded to a
    worker thread. Optional allowed_hosts list plus a hard
    max_response_bytes cap. Pair with RateLimiter under ToolCompose for
    per-host throttling.

torchrl.envs.llm.agentic top-level exports gain HttpTool,
MCPServerConfig, MCPToolset.

Documentation:

  • New sphinx-gallery tutorial tutorials/sphinx-tutorials/llm_agentic.py
    walking through a minimal agentic loop (Python + Stop), parser
    swapping (XML / JSON / OpenAI / Anthropic), parallel-dispatch
    motivation, the as_tool() migration recipe, and an MCP example.
    Smoke-tested end-to-end (prints '<tool_result call_id="c1">4</tool_result>').
  • docs/source/reference/llms_envs.rst gains a "Built-in tools and
    adapters" autosummary block and a migration table mapping each legacy
    class to its agentic counterpart and adapter recipe.

Soft .. seealso:: pointers added to the docstrings of:
ExecuteToolsInOrder, PythonInterpreter, SimpleToolTransform,
MCPToolTransform, BrowserTransform, XMLBlockParser, JSONCallParser.
Each points readers at the modern equivalent or the as_tool() adapter
without changing runtime behaviour.

Tests extend test/llm/test_llm_transforms.py with TestMCPToolset
(import-gated, server config) and TestHttpTool (host allowlist,
protocol conformance).

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 10, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3737

Note: Links to docs will display an error until the docs builds have been completed.

❌ 5 New Failures

As of commit ff12538 with merge base d386287 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions github-actions Bot added Feature New feature Documentation Improvements or additions to documentation llm/ LLM-related PR, triggers LLM CI tests tutorials/ labels May 10, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 10, 2026
[ghstack-poisoned]
vmoens added a commit that referenced this pull request May 11, 2026
Adds the remaining built-ins, a sphinx-gallery tutorial, and soft
"see also" pointers in the legacy classes' docstrings. No
DeprecationWarning is emitted -- legacy transforms keep working
unchanged, and the as_tool() adapter from the previous commit gives
users a soft migration path.

New tools under torchrl.envs.llm.agentic.tools:

- MCPToolset / MCPServerConfig: connects to an MCP server over stdio
  and materialises remote tools as N native Tool instances, each with
  the server's auto-discovered input_schema. Replaces the legacy
  MCPToolTransform's background-thread plumbing with native asyncio.
  Optional dependency on the 'mcp' package.
- HttpTool: stdlib-only async HTTP via urllib.request offloaded to a
  worker thread. Optional allowed_hosts list plus a hard
  max_response_bytes cap. Pair with RateLimiter under ToolCompose for
  per-host throttling.

torchrl.envs.llm.agentic top-level exports gain HttpTool,
MCPServerConfig, MCPToolset.

Documentation:

- New sphinx-gallery tutorial tutorials/sphinx-tutorials/llm_agentic.py
  walking through a minimal agentic loop (Python + Stop), parser
  swapping (XML / JSON / OpenAI / Anthropic), parallel-dispatch
  motivation, the as_tool() migration recipe, and an MCP example.
  Smoke-tested end-to-end (prints '<tool_result call_id="c1">4</tool_result>').
- docs/source/reference/llms_envs.rst gains a "Built-in tools and
  adapters" autosummary block and a migration table mapping each legacy
  class to its agentic counterpart and adapter recipe.

Soft .. seealso:: pointers added to the docstrings of:
ExecuteToolsInOrder, PythonInterpreter, SimpleToolTransform,
MCPToolTransform, BrowserTransform, XMLBlockParser, JSONCallParser.
Each points readers at the modern equivalent or the as_tool() adapter
without changing runtime behaviour.

Tests extend test/llm/test_llm_transforms.py with TestMCPToolset
(import-gated, server config) and TestHttpTool (host allowlist,
protocol conformance).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
ghstack-source-id: 7432aa1
Pull-Request: #3737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Documentation Improvements or additions to documentation Feature New feature llm/ LLM-related PR, triggers LLM CI tests tutorials/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant