mcp_kit.targets.multiplex
Multiplex target implementation for combining multiple MCP targets.
MultiplexTarget
class MultiplexTarget(Target)
Target that combines multiple targets into a single interface.
This target implementation allows multiple MCP targets to be accessed through a single interface. Tools from different targets are namespaced to avoid conflicts.
__init__
def __init__(name: str, *targets: Target) -> None
Initialize the multiplex target.
Arguments:
name
: Name of the multiplex targettargets
: Variable number of targets to multiplex
name
@property
def name() -> str
Get the target name.
Returns:
The target name
from_config
@classmethod
def from_config(cls, config: DictConfig) -> Self
Create MultiplexTarget from configuration.
Arguments:
config
: Target configuration from OmegaConf
Returns:
MultiplexTarget instance
initialize
async def initialize() -> None
Initialize all sub-targets concurrently.
list_tools
async def list_tools() -> list[Tool]
List all tools from all targets with namespace prefixes.
Each tool name is prefixed with the target name to ensure uniqueness across multiple targets.
Returns:
List of all namespaced tools from all targets
call_tool
async def call_tool(name: str,
arguments: dict[str, Any] | None = None) -> list[Content]
Call a tool on the appropriate target.
The tool name must be in the format 'target_name.tool_name' to identify which target should handle the call.
Arguments:
name
: Namespaced tool name (target_name.tool_name)arguments
: Arguments to pass to the tool
Raises:
McpError
: If the tool name is invalid or target not found
Returns:
List of content responses from the tool
close
async def close() -> None
Close all sub-targets concurrently.