Skip to main content

mcp_kit.adapters.client_session

Client session adapter for MCP targets.

ClientSessionAdapter

class ClientSessionAdapter()

Adapter class to convert the target MCP server to a ClientSession.

This adapter provides a client session interface for interacting with MCP targets, wrapping tool calls and error handling.

__init__

def __init__(target: Target)

Initialize the client session adapter.

Arguments:

  • target: The MCP target to adapt

list_tools

async def list_tools() -> ListToolsResult

List all available tools from the target.

Returns:

Result containing the list of available tools

call_tool

async def call_tool(name: str,
arguments: dict[str, Any] | None = None) -> CallToolResult

Call a tool on the target with error handling.

Arguments:

  • name: Name of the tool to call
  • arguments: Arguments to pass to the tool

Returns:

Result containing the tool response or error information