mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-16 04:02:55 -06:00
chore: add more comments to MCPTooset and MCPSessionManager
PiperOrigin-RevId: 765448413
This commit is contained in:
parent
5d297169d0
commit
af2180c6d0
@ -150,7 +150,8 @@ class MCPSessionManager:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
connection_params: Parameters for the MCP connection (Stdio, SSE or
|
connection_params: Parameters for the MCP connection (Stdio, SSE or
|
||||||
Streamable HTTP).
|
Streamable HTTP). Stdio by default also has a 5s read timeout as other
|
||||||
|
parameters but it's not configurable for now.
|
||||||
errlog: (Optional) TextIO stream for error logging. Use only for
|
errlog: (Optional) TextIO stream for error logging. Use only for
|
||||||
initializing a local stdio MCP session.
|
initializing a local stdio MCP session.
|
||||||
"""
|
"""
|
||||||
@ -174,6 +175,9 @@ class MCPSessionManager:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(self._connection_params, StdioServerParameters):
|
if isinstance(self._connection_params, StdioServerParameters):
|
||||||
|
# So far timeout is not configurable. Given MCP is still evolving, we
|
||||||
|
# would expect stdio_client to evolve to accept timeout parameter like
|
||||||
|
# other client.
|
||||||
client = stdio_client(
|
client = stdio_client(
|
||||||
server=self._connection_params, errlog=self._errlog
|
server=self._connection_params, errlog=self._errlog
|
||||||
)
|
)
|
||||||
@ -211,6 +215,13 @@ class MCPSessionManager:
|
|||||||
if isinstance(self._connection_params, StdioServerParameters):
|
if isinstance(self._connection_params, StdioServerParameters):
|
||||||
# Default timeout for MCP session is 5 seconds, same as SseServerParams
|
# Default timeout for MCP session is 5 seconds, same as SseServerParams
|
||||||
# and StreamableHTTPServerParams.
|
# and StreamableHTTPServerParams.
|
||||||
|
# TODO :
|
||||||
|
# 1. make timeout configurable
|
||||||
|
# 2. Add StdioConnectionParams to include StdioServerParameters as a
|
||||||
|
# field and rename other two params to XXXXConnetionParams. Ohter
|
||||||
|
# two params are actually connection params, while stdio is
|
||||||
|
# special, stdio_client takes the resposibility of starting the
|
||||||
|
# server and working as a client.
|
||||||
session = await self._exit_stack.enter_async_context(
|
session = await self._exit_stack.enter_async_context(
|
||||||
ClientSession(
|
ClientSession(
|
||||||
*transports[:2],
|
*transports[:2],
|
||||||
|
@ -98,9 +98,9 @@ class MCPToolset(BaseToolset):
|
|||||||
`StdioServerParameters` for using local mcp server (e.g. using `npx` or
|
`StdioServerParameters` for using local mcp server (e.g. using `npx` or
|
||||||
`python3`); or `SseServerParams` for a local/remote SSE server; or
|
`python3`); or `SseServerParams` for a local/remote SSE server; or
|
||||||
`StreamableHTTPServerParams` for local/remote Streamable http server.
|
`StreamableHTTPServerParams` for local/remote Streamable http server.
|
||||||
tool_filter: Optional filter to select specific tools. Can be either: - A
|
tool_filter: Optional filter to select specific tools. Can be either:
|
||||||
list of tool names to include - A ToolPredicate function for custom
|
- A list of tool names to include
|
||||||
filtering logic
|
- A ToolPredicate function for custom filtering logic
|
||||||
errlog: TextIO stream for error logging.
|
errlog: TextIO stream for error logging.
|
||||||
"""
|
"""
|
||||||
super().__init__(tool_filter=tool_filter)
|
super().__init__(tool_filter=tool_filter)
|
||||||
|
Loading…
Reference in New Issue
Block a user