Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
26ef2ef
1
Parent(s): ad2e1e9
Unpack tuple properly
Browse files
src/fastmcp/client/transports.py
CHANGED
|
@@ -18,8 +18,8 @@ from mcp.client.session import (
|
|
| 18 |
)
|
| 19 |
from mcp.client.sse import sse_client
|
| 20 |
from mcp.client.stdio import stdio_client
|
| 21 |
-
from mcp.client.websocket import websocket_client
|
| 22 |
from mcp.client.streamable_http import streamablehttp_client
|
|
|
|
| 23 |
from mcp.shared.memory import create_connected_server_and_client_session
|
| 24 |
from pydantic import AnyUrl
|
| 25 |
from typing_extensions import Unpack
|
|
@@ -125,6 +125,7 @@ class SSETransport(ClientTransport):
|
|
| 125 |
def __repr__(self) -> str:
|
| 126 |
return f"<SSE(url='{self.url}')>"
|
| 127 |
|
|
|
|
| 128 |
class StreamableHttpTransport(ClientTransport):
|
| 129 |
"""Transport implementation that connects to an MCP server via Streamable HTTP Requests."""
|
| 130 |
|
|
@@ -141,7 +142,7 @@ class StreamableHttpTransport(ClientTransport):
|
|
| 141 |
self, **session_kwargs: Unpack[SessionKwargs]
|
| 142 |
) -> AsyncIterator[ClientSession]:
|
| 143 |
async with streamablehttp_client(self.url, headers=self.headers) as transport:
|
| 144 |
-
read_stream, write_stream = transport
|
| 145 |
async with ClientSession(
|
| 146 |
read_stream, write_stream, **session_kwargs
|
| 147 |
) as session:
|
|
@@ -152,7 +153,6 @@ class StreamableHttpTransport(ClientTransport):
|
|
| 152 |
return f"<StreamableHttp(url='{self.url}')>"
|
| 153 |
|
| 154 |
|
| 155 |
-
|
| 156 |
class StdioTransport(ClientTransport):
|
| 157 |
"""
|
| 158 |
Base transport for connecting to an MCP server via subprocess with stdio.
|
|
|
|
| 18 |
)
|
| 19 |
from mcp.client.sse import sse_client
|
| 20 |
from mcp.client.stdio import stdio_client
|
|
|
|
| 21 |
from mcp.client.streamable_http import streamablehttp_client
|
| 22 |
+
from mcp.client.websocket import websocket_client
|
| 23 |
from mcp.shared.memory import create_connected_server_and_client_session
|
| 24 |
from pydantic import AnyUrl
|
| 25 |
from typing_extensions import Unpack
|
|
|
|
| 125 |
def __repr__(self) -> str:
|
| 126 |
return f"<SSE(url='{self.url}')>"
|
| 127 |
|
| 128 |
+
|
| 129 |
class StreamableHttpTransport(ClientTransport):
|
| 130 |
"""Transport implementation that connects to an MCP server via Streamable HTTP Requests."""
|
| 131 |
|
|
|
|
| 142 |
self, **session_kwargs: Unpack[SessionKwargs]
|
| 143 |
) -> AsyncIterator[ClientSession]:
|
| 144 |
async with streamablehttp_client(self.url, headers=self.headers) as transport:
|
| 145 |
+
read_stream, write_stream, _ = transport
|
| 146 |
async with ClientSession(
|
| 147 |
read_stream, write_stream, **session_kwargs
|
| 148 |
) as session:
|
|
|
|
| 153 |
return f"<StreamableHttp(url='{self.url}')>"
|
| 154 |
|
| 155 |
|
|
|
|
| 156 |
class StdioTransport(ClientTransport):
|
| 157 |
"""
|
| 158 |
Base transport for connecting to an MCP server via subprocess with stdio.
|