8000 chore: add more comments to MCPTooset and MCPSessionManager · NSFWExpert/adk-python@af2180c · GitHub
[go: up one dir, main page]

Skip to content

Commit af2180c

Browse files
seanzhougooglecopybara-github
authored andcommitted
chore: add more comments to MCPTooset and MCPSessionManager
PiperOrigin-RevId: 765448413
1 parent 5d29716 commit af2180c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/google/adk/tools/mcp_tool/mcp_session_manager.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def __init__(
150150
151151
Args:
152152
connection_params: Parameters for the MCP connection (Stdio, SSE or
153-
Streamable HTTP).
153+
Streamable HTTP). Stdio by default also has a 5s read timeout as other
154+
parameters but it's not configurable for now.
154155
errlog: (Optional) TextIO stream for error logging. Use only for
155156
initializing a local stdio MCP session.
156157
"""
@@ -174,6 +175,9 @@ async def create_session(self) -> ClientSession:
174175

175176
try:
176177
if isinstance(self._connection_params, StdioServerParameters):
178+
# So far timeout is not configurable. Given MCP is still evolving, we
179+
# would expect stdio_client to evolve to accept timeout parameter like
180+
# other client.
177181
client = stdio_client(
178182
server=self._connection_params, errlog=self._errlog
179183
)
@@ -211,6 +215,13 @@ async def create_session(self) -> ClientSession:
211215
if isinstance(self._connection_params, StdioServerParameters):
212216
# Default timeout for MCP session is 5 seconds, same as SseServerParams
213217
# and StreamableHTTPServerParams.
218+
# TODO :
219+
# 1. make timeout configurable
220+
# 2. Add StdioConnectionParams to include StdioServerParameters as a
221+
# field and rename other two params to XXXXConnetionParams. Ohter
222+
# two params are actually connection params, while stdio is
223+
# special, stdio_client takes the resposibility of starting the
224+
# server and working as a client.
214225
session = await self._exit_stack.enter_async_context(
215226
ClientSession(
216227
*transports[:2],

src/google/adk/tools/mcp_tool/mcp_toolset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ def __init__(
9898
`StdioServerParameters` for using local mcp server (e.g. using `npx` or
9999
`python3`); or `SseServerParams` for a local/remote SSE server; or
100100
`StreamableHTTPServerParams` for local/remote Streamable http server.
101-
tool_filter: Optional filter to select specific tools. Can be either: - A
102-
list of tool names to include - A ToolPredicate function for custom
103-
filtering logic
101+
tool_filter: Optional filter to select specific tools. Can be either:
102+
- A list of tool names to include
103+
- A ToolPredicate function for custom filtering logic
104104
errlog: TextIO stream for error logging.
105105
"""
106106
super().__init__(tool_filter=tool_filter)

0 commit comments

Comments
 (0)
0