Skip to content

Commit 1578e8c

Browse files
committed
update abidlabs space
Co-authored-by: neonwatty
1 parent 45465e1 commit 1578e8c

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

units/en/unit1/mcp-clients.mdx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ For local servers using stdio transport, the configuration includes the command
9090
"transport": {
9191
"type": "stdio",
9292
"command": "python",
93-
"args": ["/path/to/file_explorer_server.py"]
93+
"args": ["/path/to/file_explorer_server.py"] // This is an example, we'll use a real server in the next unit
9494
}
9595
}
9696
]
@@ -237,26 +237,32 @@ Tiny Agent can run MCP servers with a command line environment. To do this, we w
237237

238238
Let's install `npx` with `npm`. If you don't have `npm` installed, check out the [npm documentation](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
239239

240+
### Setup
241+
242+
First, we will need to install `npx` if you don't have it installed. You can do this with the following command:
243+
240244
```bash
241245
# install npx
242246
npm install -g npx
243247
```
244248

245-
<hfoptions id="language">
246-
<hfoption id="python">
247-
248-
First, install the tiny agents package:
249+
Then, we will need to install the huggingface_hub package with the MCP support. This will allow us to run MCP servers and clients.
249250

250251
```bash
251252
pip install "huggingface_hub[mcp]>=0.32.0"
252253
```
253254

254-
First, let's login to the Hugging Face Hub. You will need a [login token](https://huggingface.co/docs/huggingface_hub/v0.32.3/en/quick-start#authentication) to do this.
255+
Then, we will need to log in to the Hugging Face Hub to access the MCP servers. You can do this with the `huggingface-cli` command line tool. You will need a [login token](https://huggingface.co/docs/huggingface_hub/v0.32.3/en/quick-start#authentication) to do this.
255256

256257
```bash
257258
huggingface-cli login
258259
```
259260

261+
<hfoptions id="language">
262+
<hfoption id="python">
263+
264+
### Connecting to MCP Servers
265+
260266
Now, let's create an agent configuration file `agent.json`.
261267

262268
```json
@@ -291,6 +297,8 @@ First, install the tiny agents package with [npm](https://docs.npmjs.com/downloa
291297
npm install @huggingface/tiny-agents
292298
```
293299

300+
### Connecting to MCP Servers
301+
294302
Make an agent project directory and create an `agent.json` file.
295303

296304
```bash

units/en/unit2/gradio-client.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,38 @@ We'll connect to the MCP server we created in the previous section and use it to
1212

1313
## MCP Client in Gradio
1414

15-
First, we need to install the `smolagents`, gradio and mcp-client libraries, if we haven't already:
15+
### Connect to an example MCP Server
16+
17+
Let's connect to an example MCP Server that is already running on Hugging Face. We'll use [this one](https://huggingface.co/spaces/abidlabs/mcp-tools2) for this example. It's a space that contains a collection of MCP tools.
18+
19+
```python
20+
from smolagents.mcp_client import MCPClient
21+
22+
with MCPClient(
23+
{"url": "https://abidlabs-mcp-tools2.hf.space/gradio_api/mcp/sse"}
24+
) as tools:
25+
# Tools from the remote server are available
26+
print("\n".join(f"{t.name}: {t.description}" for t in tools))
27+
28+
```
29+
30+
<details>
31+
<summary>Output</summary>
32+
<pre>
33+
<code>
34+
prime_factors: Compute the prime factorization of a positive integer.
35+
generate_cheetah_image: Generate a cheetah image.
36+
image_orientation: Returns whether image is portrait or landscape.
37+
sepia: Apply a sepia filter to the input image.
38+
</code>
39+
</pre>
40+
</details>
41+
42+
### Connect to your MCP Server from Gradio
43+
44+
Great, now that you've connected to an example MCP Server, let's connect to your own MCP Server from Gradio.
45+
46+
First, we need to install the `smolagents`, Gradio and mcp-client libraries, if we haven't already:
1647

1748
```bash
1849
pip install "smolagents[mcp]" "gradio[mcp]" mcp fastmcp

0 commit comments

Comments
 (0)