vllm_mlx.mcp.client¶
MCP client for connecting to individual MCP servers.
View the complete module source at #L1-L328.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
vllm_mlx.mcp.client
¶
MCP client for connecting to individual MCP servers.
vllm_mlx.mcp.client.MCPClient
¶
MCPClient(config: MCPServerConfig)
Client for connecting to a single MCP server.
Supports both stdio and SSE transports.
Initialize MCP client.
Parameters:
-
config(MCPServerConfig) –Server configuration
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient._last_connected
instance-attribute
¶
vllm_mlx.mcp.client.MCPClient.is_connected
property
¶
Check if connected to server.
vllm_mlx.mcp.client.MCPClient.get_status
¶
get_status() -> MCPServerStatus
Get server status.
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient.connect
async
¶
Connect to the MCP server.
Returns:
-
bool–True if connection successful, False otherwise
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient._connect_stdio
async
¶
Connect via stdio transport.
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient._connect_sse
async
¶
Connect via SSE transport.
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient._initialize_session
async
¶
Initialize the MCP session.
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient._discover_tools
async
¶
Discover available tools from the server.
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient.disconnect
async
¶
Disconnect from the MCP server.
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient.call_tool
async
¶
call_tool(tool_name: str, arguments: Dict[str, Any], timeout: Optional[float] = None) -> MCPToolResult
Call a tool on the MCP server.
Parameters:
-
tool_name(str) –Name of the tool (without server prefix)
-
arguments(Dict[str, Any]) –Tool arguments
-
timeout(Optional[float], default:None) –Optional timeout in seconds
Returns:
-
MCPToolResult–MCPToolResult with the result or error
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient._extract_content
¶
Extract content from MCP tool result.
Source code in vllm_mlx/mcp/client.py
vllm_mlx.mcp.client.MCPClient.refresh_tools
async
¶
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
vllm_mlx.mcp.client.MCPClient · class
Client for connecting to a single MCP server.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
config |
MCPServerConfig |
yes |
none |
Server configuration |
Returns
- Constructs:
vllm_mlx.mcp.client.MCPClient
Exceptions and behavior
Class MCPClient declares 15 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.__init__ · method
Initialize MCP client.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
config |
MCPServerConfig |
yes |
none |
Server configuration |
Returns
- Type:
not annotated
Exceptions and behavior
Method MCPClient.__init__ updates self.config, self._session, self._read, self._write; calls asyncio.Lock.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.name · method
Get server name.
Parameters
This callable has no explicit inputs.
Returns
- Type:
str - Direct return expressions:
self.config.name
Exceptions and behavior
Method MCPClient.name returns self.config.name.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.state · method
Get current connection state.
Parameters
This callable has no explicit inputs.
Returns
- Type:
MCPServerState - Direct return expressions:
self._state
Exceptions and behavior
Method MCPClient.state returns self._state.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.is_connected · method
Check if connected to server.
Parameters
This callable has no explicit inputs.
Returns
- Type:
bool - Direct return expressions:
self._state == MCPServerState.CONNECTED
Exceptions and behavior
Method MCPClient.is_connected returns self._state == MCPServerState.CONNECTED.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.tools · method
Get discovered tools.
Parameters
This callable has no explicit inputs.
Returns
- Type:
List[MCPTool] - Direct return expressions:
self._tools
Exceptions and behavior
Method MCPClient.tools returns self._tools.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.get_status · method
Get server status.
Parameters
This callable has no explicit inputs.
Returns
- Type:
MCPServerStatus - Direct return expressions:
MCPServerStatus(name=self.name, state=self._state, transport=self.config.transport, tools_count=len(self._tools), error…
Exceptions and behavior
Method MCPClient.get_status calls MCPServerStatus, len; returns MCPServerStatus(name=self.name, state=self._state, transport=self.config.transport, tools_count=len(self._tools), error….
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.connect · method
Connect to the MCP server.
Parameters
This callable has no explicit inputs.
Returns
- Type:
bool - Direct return expressions:
True;False
Exceptions and behavior
Method MCPClient.connect updates self._state, self._error, self._last_connected; calls logger.info, self._connect_stdio, self._connect_sse, ValueError; awaits asynchronous work; can raise ValueError; has 2 explicit return paths.
Directly raised exceptions: ValueError.
vllm_mlx.mcp.client.MCPClient._connect_stdio · method
Connect via stdio transport.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method MCPClient._connect_stdio updates self._stdio_client, self._read, self._write, self._session; calls ImportError, logger.info, ' '.join, StdioServerParameters; awaits asynchronous work; can raise ImportError.
Directly raised exceptions: ImportError.
vllm_mlx.mcp.client.MCPClient._connect_sse · method
Connect via SSE transport.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method MCPClient._connect_sse updates self._sse_client, self._read, self._write, self._session; calls ImportError, sse_client, self._sse_client.__aenter__, ClientSession; awaits asynchronous work; can raise ImportError.
Directly raised exceptions: ImportError.
vllm_mlx.mcp.client.MCPClient._initialize_session · method
Initialize the MCP session.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method MCPClient._initialize_session calls RuntimeError, self._session.initialize, logger.debug; awaits asynchronous work; can raise RuntimeError.
Directly raised exceptions: RuntimeError.
vllm_mlx.mcp.client.MCPClient._discover_tools · method
Discover available tools from the server.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method MCPClient._discover_tools updates self._tools; calls RuntimeError, self._session.list_tools, MCPTool, hasattr; awaits asynchronous work; can raise RuntimeError.
Directly raised exceptions: RuntimeError.
vllm_mlx.mcp.client.MCPClient.disconnect · method
Disconnect from the MCP server.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated - Direct return expressions:
None
Exceptions and behavior
Method MCPClient.disconnect updates self._session, self._stdio_client, self._sse_client, self._state; calls self._session.__aexit__, hasattr, self._stdio_client.__aexit__, self._sse_client.__aexit__; awaits asynchronous work; returns None.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.call_tool · method
async vllm_mlx.mcp.client.MCPClient.call_tool(tool_name: str, arguments: Dict[str, Any], timeout: Optional[float] = None) -> MCPToolResult
Call a tool on the MCP server.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
tool_name |
str |
yes |
none |
Name of the tool (without server prefix) |
arguments |
Dict[str, Any] |
yes |
none |
Tool arguments |
timeout |
Optional[float] |
no |
None |
Optional timeout in seconds |
Returns
- Type:
MCPToolResult - Direct return expressions:
MCPToolResult(tool_name=tool_name, content=None, is_error=True, error_message=f"Not connected to server '{self.name}'");MCPToolResult(tool_name=tool_name, content=None, is_error=True, error_message='Session not initialized');MCPToolResult(tool_name=tool_name, content=content, is_error=result.isError if hasattr(result, 'isError') else False);MCPToolResult(tool_name=tool_name, content=None, is_error=True, error_message=f'Tool call timed out after {timeout}s');MCPToolResult(tool_name=tool_name, content=None, is_error=True, error_message=str(e))
Exceptions and behavior
Method MCPClient.call_tool calls MCPToolResult, asyncio.wait_for, self._session.call_tool, self._extract_content; awaits asynchronous work; has 5 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient._extract_content · method
Extract content from MCP tool result.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
result |
not annotated |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
Any - Direct return expressions:
None;contents[0];contents
Exceptions and behavior
Method MCPClient._extract_content calls hasattr, contents.append, str, len; has 3 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.mcp.client.MCPClient.refresh_tools · method
Refresh the list of available tools.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated - Direct return expressions:
None
Exceptions and behavior
Method MCPClient.refresh_tools calls self._discover_tools; awaits asynchronous work; returns None.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
MCPClient |
class | MCPClient(config: MCPServerConfig) |
Client for connecting to a single MCP server. | #L23-L328 |
MCPClient.__init__ |
method | MCPClient.__init__(config: MCPServerConfig) -> not annotated |
Initialize MCP client. | #L30-L45 |
MCPClient.name |
method | MCPClient.name() -> str |
Get server name. | #L48-L50 |
MCPClient.state |
method | MCPClient.state() -> MCPServerState |
Get current connection state. | #L53-L55 |
MCPClient.is_connected |
method | MCPClient.is_connected() -> bool |
Check if connected to server. | #L58-L60 |
MCPClient.tools |
method | MCPClient.tools() -> List[MCPTool] |
Get discovered tools. | #L63-L65 |
MCPClient.get_status |
method | MCPClient.get_status() -> MCPServerStatus |
Get server status. | #L67-L76 |
MCPClient.connect |
method | async MCPClient.connect() -> bool |
Connect to the MCP server. | #L78-L122 |
MCPClient._connect_stdio |
method | async MCPClient._connect_stdio() -> not annotated |
Connect via stdio transport. | #L124-L152 |
MCPClient._connect_sse |
method | async MCPClient._connect_sse() -> not annotated |
Connect via SSE transport. | #L154-L170 |
MCPClient._initialize_session |
method | async MCPClient._initialize_session() -> not annotated |
Initialize the MCP session. | #L172-L183 |
MCPClient._discover_tools |
method | async MCPClient._discover_tools() -> not annotated |
Discover available tools from the server. | #L185-L208 |
MCPClient.disconnect |
method | async MCPClient.disconnect() -> not annotated |
Disconnect from the MCP server. | #L210-L235 |
MCPClient.call_tool |
method | async MCPClient.call_tool(tool_name: str, arguments: Dict[str, Any], timeout: Optional[float] = None) -> MCPToolResult |
Call a tool on the MCP server. | #L237-L301 |
MCPClient._extract_content |
method | MCPClient._extract_content(result) -> Any |
Extract content from MCP tool result. | #L303-L321 |
MCPClient.refresh_tools |
method | async MCPClient.refresh_tools() -> not annotated |
Refresh the list of available tools. | #L323-L328 |