Skip to content

Commit 3941975

Browse files
authored
MCPClient Specify "transport"
Newer versions of `smolagents` defaults to "streamable-http" (SSE) is deprecated. Therefore, the transport type must be specified explicitly for the client connection to work.
1 parent 2ce8294 commit 3941975

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

units/en/unit2/gradio-client.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Let's connect to an example MCP Server that is already running on Hugging Face.
2020
from smolagents.mcp_client import MCPClient
2121

2222
with MCPClient(
23-
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse"}
23+
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse", "transport": "sse",}
2424
) as tools:
2525
# Tools from the remote server are available
2626
print("\n".join(f"{t.name}: {t.description}" for t in tools))
@@ -64,7 +64,7 @@ Next, we'll connect to the MCP Server and get the tools that we can use to answe
6464

6565
```python
6666
mcp_client = MCPClient(
67-
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse"} # This is the MCP Client we created in the previous section
67+
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse", "transport": "sse",} # This is the MCP Client we created in the previous section
6868
)
6969
tools = mcp_client.get_tools()
7070
```
@@ -115,7 +115,7 @@ from smolagents import InferenceClientModel, CodeAgent, MCPClient
115115

116116
try:
117117
mcp_client = MCPClient(
118-
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse"}
118+
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse", "transport": "sse",}
119119
)
120120
tools = mcp_client.get_tools()
121121

@@ -152,7 +152,7 @@ To deploy your Gradio MCP client to Hugging Face Spaces:
152152

153153
```python
154154
mcp_client = MCPClient(
155-
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse"}
155+
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse", "transport": "sse"}
156156
)
157157
```
158158

0 commit comments

Comments
 (0)