Merge pull request #383 from balwa/patch-1

Update mcp tools sample code
This commit is contained in:
Sergio Paniego Blanco
2025-04-03 15:08:45 +02:00
committed by GitHub

View File

@@ -280,6 +280,11 @@ The MCP servers tools can be loaded in a ToolCollection object as follow:
import os
from smolagents import ToolCollection, CodeAgent
from mcp import StdioServerParameters
from smolagents import HfApiModel
model = HfApiModel("Qwen/Qwen2.5-Coder-32B-Instruct")
server_parameters = StdioServerParameters(
command="uvx",
@@ -287,8 +292,8 @@ server_parameters = StdioServerParameters(
env={"UV_PYTHON": "3.12", **os.environ},
)
with ToolCollection.from_mcp(server_parameters) as tool_collection:
agent = CodeAgent(tools=[*tool_collection.tools], add_base_tools=True)
with ToolCollection.from_mcp(server_parameters, trust_remote_code=True) as tool_collection:
agent = CodeAgent(tools=[*tool_collection.tools], model=model, add_base_tools=True)
agent.run("Please find a remedy for hangover.")
```