Skip to content

Commit f4594db

Browse files
authored
Merge pull request #75 from huggingface/update-abidlabs-space-in-unit2
update abidlabs space
2 parents 45465e1 + 3b87be4 commit f4594db

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
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

units/vi/unit1/mcp-clients.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Chúng ta cũng có thể kết nối đến Server MCP được host trên máy
302302
from smolagents.mcp_client import MCPClient
303303

304304
with MCPClient(
305-
{"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse"}
305+
{"url": "https://abidlabs-mcp-tools2.hf.space/gradio_api/mcp/sse"}
306306
) as tools:
307307
# Tools from the remote server are available
308308
print("\n".join(f"{t.name}: {t.description}" for t in tools))
@@ -312,7 +312,7 @@ with MCPClient(
312312
from smolagents.mcp_client import MCPClient
313313

314314
with MCPClient(
315-
{"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse"}
315+
{"url": "https://abidlabs-mcp-tools2.hf.space/gradio_api/mcp/sse"}
316316
) as tools:
317317
# Tools from the remote server are available
318318
print("\n".join(f"{t.name}: {t.description}" for t in tools))
@@ -419,4 +419,4 @@ Giờ bạn đã hiểu về MCP Client, hãy sẵn sàng để:
419419
* Tìm hiểu về cách tạo MCP Client tùy chỉnh
420420
* Đi sâu vào các mẫu tích hợp MCP nâng cao
421421

422-
Hãy tiếp tục hành trình của chúng ta vào thế giới của Giao Thức Ngữ Cảnh Mô Hình!
422+
Hãy tiếp tục hành trình của chúng ta vào thế giới của Giao Thức Ngữ Cảnh Mô Hình!

0 commit comments

Comments
 (0)