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
+49-1Lines changed: 49 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,6 +236,18 @@ with ToolCollection.from_mcp(
236
236
237
237
```
238
238
239
+
<details>
240
+
<summary>
241
+
Output
242
+
</summary>
243
+
244
+
```sh
245
+
Weather API: Get the weather in a specific location
246
+
247
+
```
248
+
249
+
</details>
250
+
239
251
We can also connect to an MCP server that is hosted on a remote machine. In this case, we need to pass the `SSEServerParameters` to the `ToolCollection.from_mcp` method.
240
252
241
253
```python
@@ -248,6 +260,20 @@ with MCPClient(
248
260
print("\n".join(f"{t.name}: {t.description}"for t in tools))
249
261
```
250
262
263
+
<details>
264
+
<summary>
265
+
Output
266
+
</summary>
267
+
268
+
```sh
269
+
prime_factors: Compute the prime factorization of a positive integer.
270
+
generate_cheetah_image: Generate a cheetah image.
271
+
image_orientation: Returns whether image is portrait or landscape.
272
+
sepia: Apply a sepia filter to the input image.
273
+
```
274
+
275
+
</details>
276
+
251
277
Now, let's see how we can use the MCP Client in a code agent.
252
278
253
279
```python
@@ -267,6 +293,17 @@ with ToolCollection.from_mcp(
267
293
268
294
```
269
295
296
+
<details>
297
+
<summary>
298
+
Output
299
+
</summary>
300
+
301
+
```sh
302
+
The weather in Tokyo is sunny with a temperature of 20 degrees Celsius.
303
+
```
304
+
305
+
</details>
306
+
270
307
We can also connect to an MCP packages. Here's an example of connecting to the `pubmedmcp` package.
0 commit comments