Skip to content

Commit ea8a33c

Browse files
committed
revert client session group
1 parent 99856e8 commit ea8a33c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/mcp/client/session_group.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ class _ComponentNames(BaseModel):
9696
_tools: dict[str, types.Tool]
9797

9898
# Client-server connection management.
99-
_sessions: dict[mcp.ClientTransportSession, _ComponentNames]
100-
_tool_to_session: dict[str, mcp.ClientTransportSession]
99+
_sessions: dict[mcp.ClientSession, _ComponentNames]
100+
_tool_to_session: dict[str, mcp.ClientSession]
101101
_exit_stack: contextlib.AsyncExitStack
102-
_session_exit_stacks: dict[mcp.ClientTransportSession, contextlib.AsyncExitStack]
102+
_session_exit_stacks: dict[mcp.ClientSession, contextlib.AsyncExitStack]
103103

104104
# Optional fn consuming (component_name, serverInfo) for custom names.
105105
# This is provide a means to mitigate naming conflicts across servers.
@@ -153,7 +153,7 @@ async def __aexit__(
153153
tg.start_soon(exit_stack.aclose)
154154

155155
@property
156-
def sessions(self) -> list[mcp.ClientTransportSession]:
156+
def sessions(self) -> list[mcp.ClientSession]:
157157
"""Returns the list of sessions being managed."""
158158
return list(self._sessions.keys()) # pragma: no cover
159159

@@ -178,7 +178,7 @@ async def call_tool(self, name: str, args: dict[str, Any]) -> types.CallToolResu
178178
session_tool_name = self.tools[name].name
179179
return await session.call_tool(session_tool_name, args)
180180

181-
async def disconnect_from_server(self, session: mcp.ClientTransportSession) -> None:
181+
async def disconnect_from_server(self, session: mcp.ClientSession) -> None:
182182
"""Disconnects from a single MCP server."""
183183

184184
session_known_for_components = session in self._sessions
@@ -216,23 +216,23 @@ async def disconnect_from_server(self, session: mcp.ClientTransportSession) -> N
216216
await session_stack_to_close.aclose() # pragma: no cover
217217

218218
async def connect_with_session(
219-
self, server_info: types.Implementation, session: mcp.ClientTransportSession
220-
) -> mcp.ClientTransportSession:
219+
self, server_info: types.Implementation, session: mcp.ClientSession
220+
) -> mcp.ClientSession:
221221
"""Connects to a single MCP server."""
222222
await self._aggregate_components(server_info, session)
223223
return session
224224

225225
async def connect_to_server(
226226
self,
227227
server_params: ServerParameters,
228-
) -> mcp.ClientTransportSession:
228+
) -> mcp.ClientSession:
229229
"""Connects to a single MCP server."""
230230
server_info, session = await self._establish_session(server_params)
231231
return await self.connect_with_session(server_info, session)
232232

233233
async def _establish_session(
234234
self, server_params: ServerParameters
235-
) -> tuple[types.Implementation, mcp.ClientTransportSession]:
235+
) -> tuple[types.Implementation, mcp.ClientSession]:
236236
"""Establish a client session to an MCP server."""
237237

238238
session_stack = contextlib.AsyncExitStack()
@@ -277,7 +277,7 @@ async def _establish_session(
277277
raise
278278

279279
async def _aggregate_components(
280-
self, server_info: types.Implementation, session: mcp.ClientTransportSession
280+
self, server_info: types.Implementation, session: mcp.ClientSession
281281
) -> None:
282282
"""Aggregates prompts, resources, and tools from a given session."""
283283

@@ -291,7 +291,7 @@ async def _aggregate_components(
291291
prompts_temp: dict[str, types.Prompt] = {}
292292
resources_temp: dict[str, types.Resource] = {}
293293
tools_temp: dict[str, types.Tool] = {}
294-
tool_to_session_temp: dict[str, mcp.ClientTransportSession] = {}
294+
tool_to_session_temp: dict[str, mcp.ClientSession] = {}
295295

296296
# Query the server for its prompts and aggregate to list.
297297
try:

0 commit comments

Comments
 (0)