Skip to main content

Parameters

ParameterTypeDefaultDescription
handlerMCPHandler-The MCP handler instance
tool_infomcp_types.Tool-MCP tool information

Functions

execute

Execute the MCP tool. Parameters:
  • **kwargs (Any): Tool arguments
Returns:
  • Any: Tool execution result


title: MCPHandler sidebarTitle: MCPHandler

Parameters

ParameterTypeDefaultDescription
configType-Class with MCP configuration (url, command, args, env)
sessionOptional[ClientSession]NoneMCP client session
toolsList[MCPTool][]List of MCP tools
_connection_contextOptional[Any]NoneConnection context
_client_contextOptional[Any]NoneClient context
connection_typestr-Type of connection (‘sse’ or ‘stdio’)
server_namestr-Name of the MCP server

Functions

_extract_server_name

Extract server name from URL. Parameters:
  • url (str): The URL to extract server name from
Returns:
  • str: Server name

_create_session

Create a new session for MCP communication. Returns:
  • Any: MCP client session

_initialize_session

Initialize the MCP session and discover tools.

get_tools

Get all available tools from this MCP server. Returns:
  • List[MCPTool]: List of MCP tools

_discover_tools_async

Discover tools asynchronously. Returns:
  • List[MCPTool]: List of discovered tools

call_tool

Call a tool on the MCP server. Parameters:
  • tool_name (str): Name of the tool to call
  • arguments (Dict[str, Any]): Arguments to pass to the tool
Returns:
  • Any: Tool execution result

_convert_content

Convert MCP content to standard format. Parameters:
  • content (Any): MCP content to convert
Returns:
  • Any: Converted content

disconnect

Disconnect from the MCP server (no-op since we use on-demand connections).
I