You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: units/en/unit1/mcp-clients.mdx
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,7 +219,7 @@ In the next section, we'll explore the ecosystem of MCP servers available on Hug
219
219
220
220
## Code Clients
221
221
222
-
You can also use the MCP Client within code so that the tools are available to the LLM. Let's explore some examples in `smolagents`.
222
+
You can also use the MCP Client within code so that the tools are available to the LLM. Let's explore some examples in `smolagents`. To run these examples you will need to add `mcp[cli]`, `smolagents[toolkit]`, and `smolagents[mcp]` to your `uv` virtual environment.
223
223
224
224
First, let's explore our weather server from the previous page. In `smolagents`, we can use the `ToolCollection` class to automatically discover and register tools from an MCP server. This is done by passing the `StdioServerParameters` or `SSEServerParameters` to the `ToolCollection.from_mcp` method. We can then print the tools to the console.
225
225
@@ -307,17 +307,19 @@ We can also connect to an MCP package. Here's an example of connecting to the `p
307
307
308
308
```python
309
309
import os
310
-
from smolagents import ToolCollection, CodeAgent
311
-
from mcp import StdioServerParameters
310
+
from smolagents import ToolCollection, CodeAgent, InferenceClientModel
311
+
from mcp.client.stdio import StdioServerParameters
0 commit comments