diff --git a/python/packages/core/agent_framework/_mcp.py b/python/packages/core/agent_framework/_mcp.py index d4d5d515dd..88be517bf2 100644 --- a/python/packages/core/agent_framework/_mcp.py +++ b/python/packages/core/agent_framework/_mcp.py @@ -228,7 +228,11 @@ class MCPTool: name: The name of the MCP tool. description: A description of the MCP tool. approval_mode: Whether approval is required to run tools. - allowed_tools: A collection of tool names to allow. + allowed_tools: Optional allow-list of MCP tool names to expose as functions. + ``None`` (the default) exposes every tool advertised by the MCP server. + An empty collection (``[]``) exposes no tools, which is useful when the + server is being used only for prompts or other capabilities. A non-empty + collection exposes only the tools whose names appear in it. tool_name_prefix: Optional prefix to prepend to exposed MCP function names. load_tools: Whether to load tools from the MCP server. parse_tool_results: An optional callable with signature @@ -1592,7 +1596,11 @@ class MCPStdioTool(MCPTool): - A dict with keys `always_require_approval` or `never_require_approval`, followed by a sequence of strings with the names of the relevant tools. A tool should not be listed in both, if so, it will require approval. - allowed_tools: A list of tools that are allowed to use this tool. + allowed_tools: Optional allow-list of MCP tool names to expose as functions. + ``None`` (the default) exposes every tool advertised by the MCP server. + An empty collection (``[]``) exposes no tools, which is useful when the + server is being used only for prompts or other capabilities. A non-empty + collection exposes only the tools whose names appear in it. additional_properties: Additional properties. args: The arguments to pass to the command. env: The environment variables to set for the command. @@ -1726,7 +1734,11 @@ class MCPStreamableHTTPTool(MCPTool): - A dict with keys `always_require_approval` or `never_require_approval`, followed by a sequence of strings with the names of the relevant tools. A tool should not be listed in both, if so, it will require approval. - allowed_tools: A list of tools that are allowed to use this tool. + allowed_tools: Optional allow-list of MCP tool names to expose as functions. + ``None`` (the default) exposes every tool advertised by the MCP server. + An empty collection (``[]``) exposes no tools, which is useful when the + server is being used only for prompts or other capabilities. A non-empty + collection exposes only the tools whose names appear in it. additional_properties: Additional properties. terminate_on_close: Close the transport when the MCP client is terminated. client: The chat client to use for sampling. @@ -1901,7 +1913,11 @@ class MCPWebsocketTool(MCPTool): - A dict with keys `always_require_approval` or `never_require_approval`, followed by a sequence of strings with the names of the relevant tools. A tool should not be listed in both, if so, it will require approval. - allowed_tools: A list of tools that are allowed to use this tool. + allowed_tools: Optional allow-list of MCP tool names to expose as functions. + ``None`` (the default) exposes every tool advertised by the MCP server. + An empty collection (``[]``) exposes no tools, which is useful when the + server is being used only for prompts or other capabilities. A non-empty + collection exposes only the tools whose names appear in it. additional_properties: Additional properties. client: The chat client to use for sampling. kwargs: Any extra arguments to pass to the WebSocket client.