# `vllm_mlx.mcp.manager`

MCP Client Manager for handling multiple MCP server connections.

[View the complete module source at #L1-L301](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L1-L301).

## 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.manager
    options:
      members:
        - logger
        - MCPClientManager
      filters: []
      show_if_no_docstring: true

## 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.

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager</code> · class</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager(config: MCPConfig)
```

Manages multiple MCP server connections.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `config` | `MCPConfig` | `yes` | `none` | MCP configuration with server definitions |

**Returns**

- Constructs: `vllm_mlx.mcp.manager.MCPClientManager`

**Exceptions and behavior**

Class `MCPClientManager` declares 14 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L22-L301](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L22-L301).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.__init__" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.__init__</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager.__init__(config: MCPConfig) -> not annotated
```

Initialize MCP Client Manager.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `config` | `MCPConfig` | `yes` | `none` | MCP configuration with server definitions |

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Method `MCPClientManager.__init__` updates `self.config`, `self._clients`, `self._started`, `self._lock`; calls `asyncio.Lock`, `config.servers.items`, `MCPClient`.
No direct `raise` statement appears in this definition.

[View source #L33-L47](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L33-L47).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.is_started" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.is_started</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager.is_started() -> bool
```

Check if manager has been started.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `bool`
- Direct return expressions: `self._started`

**Exceptions and behavior**

Method `MCPClientManager.is_started` returns `self._started`.
No direct `raise` statement appears in this definition.

[View source #L50-L52](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L50-L52).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.start" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.start</code> · method</summary>

```python
async vllm_mlx.mcp.manager.MCPClientManager.start() -> not annotated
```

Start the manager and connect to all enabled servers.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`
- Direct return expressions: `None`

**Exceptions and behavior**

Method `MCPClientManager.start` updates `self._started`; calls `logger.info`, `len`, `client.connect`, `self._clients.values`; awaits asynchronous work; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L54-L96](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L54-L96).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.stop" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.stop</code> · method</summary>

```python
async vllm_mlx.mcp.manager.MCPClientManager.stop() -> not annotated
```

Stop the manager and disconnect from all servers.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`
- Direct return expressions: `None`

**Exceptions and behavior**

Method `MCPClientManager.stop` updates `self._started`; calls `logger.info`, `client.disconnect`, `self._clients.values`, `asyncio.gather`; awaits asynchronous work; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L98-L112](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L98-L112).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.get_all_tools" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.get_all_tools</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager.get_all_tools() -> List[MCPTool]
```

Get all tools from all connected servers.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `List[MCPTool]`
- Direct return expressions: `tools`

**Exceptions and behavior**

Method `MCPClientManager.get_all_tools` calls `self._clients.values`, `tools.extend`; returns `tools`.
No direct `raise` statement appears in this definition.

[View source #L114-L125](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L114-L125).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.get_all_tools_openai" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.get_all_tools_openai</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager.get_all_tools_openai() -> List[Dict[str, Any]]
```

Get all tools in OpenAI function calling format.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `List[Dict[str, Any]]`
- Direct return expressions: `mcp_tools_to_openai(self.get_all_tools())`

**Exceptions and behavior**

Method `MCPClientManager.get_all_tools_openai` calls `mcp_tools_to_openai`, `self.get_all_tools`; returns `mcp_tools_to_openai(self.get_all_tools())`.
No direct `raise` statement appears in this definition.

[View source #L127-L134](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L127-L134).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.get_merged_tools" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.get_merged_tools</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager.get_merged_tools(user_tools: Optional[List[Dict[str, Any]]] = None) -> List[Dict[str, Any]]
```

Get MCP tools merged with user-provided tools.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `user_tools` | `Optional[List[Dict[str, Any]]]` | `no` | `None` | Optional user-provided tools in OpenAI format |

**Returns**

- Type: `List[Dict[str, Any]]`
- Direct return expressions: `merge_tools(self.get_all_tools(), user_tools)`

**Exceptions and behavior**

Method `MCPClientManager.get_merged_tools` calls `merge_tools`, `self.get_all_tools`; returns `merge_tools(self.get_all_tools(), user_tools)`.
No direct `raise` statement appears in this definition.

[View source #L136-L151](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L136-L151).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.get_server_status" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.get_server_status</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager.get_server_status() -> List[MCPServerStatus]
```

Get status of all servers.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `List[MCPServerStatus]`
- Direct return expressions: `[client.get_status() for client in self._clients.values()]`

**Exceptions and behavior**

Method `MCPClientManager.get_server_status` calls `client.get_status`, `self._clients.values`; returns `[client.get_status() for client in self._clients.values()]`.
No direct `raise` statement appears in this definition.

[View source #L153-L160](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L153-L160).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.get_client" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.get_client</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager.get_client(server_name: str) -> Optional[MCPClient]
```

Get client for a specific server.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `server_name` | `str` | `yes` | `none` | Name of the server |

**Returns**

- Type: `Optional[MCPClient]`
- Direct return expressions: `self._clients.get(server_name)`

**Exceptions and behavior**

Method `MCPClientManager.get_client` calls `self._clients.get`; returns `self._clients.get(server_name)`.
No direct `raise` statement appears in this definition.

[View source #L162-L172](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L162-L172).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.execute_tool" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.execute_tool</code> · method</summary>

```python
async vllm_mlx.mcp.manager.MCPClientManager.execute_tool(full_name: str, arguments: Dict[str, Any], timeout: Optional[float] = None) -> MCPToolResult
```

Execute a tool by its full name (server__tool).

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `full_name` | `str` | `yes` | `none` | Full tool name with 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=full_name, content=None, is_error=True, error_message=f"Tool '{full_name}' not found in any con…`; `MCPToolResult(tool_name=full_name, content=None, is_error=True, error_message=f"Server '{server_name}' not found")`; `MCPToolResult(tool_name=full_name, content=None, is_error=True, error_message=f"Server '{server_name}' is not connected…`; `await client.call_tool(tool_name, arguments, timeout=timeout or self.config.default_timeout)`

**Exceptions and behavior**

Method `MCPClientManager.execute_tool` calls `openai_call_to_mcp`, `self._find_tool_server`, `MCPToolResult`, `self._clients.get`; awaits asynchronous work; has 4 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L174-L232](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L174-L232).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.execute_tool_call" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.execute_tool_call</code> · method</summary>

```python
async vllm_mlx.mcp.manager.MCPClientManager.execute_tool_call(tool_call: Dict[str, Any], timeout: Optional[float] = None) -> MCPToolResult
```

Execute a tool call from OpenAI format.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tool_call` | `Dict[str, Any]` | `yes` | `none` | OpenAI tool call object |
| `timeout` | `Optional[float]` | `no` | `None` | Optional timeout in seconds |

**Returns**

- Type: `MCPToolResult`
- Direct return expressions: `await self.execute_tool(full_name, arguments, timeout)`

**Exceptions and behavior**

Method `MCPClientManager.execute_tool_call` calls `openai_call_to_mcp`, `self.execute_tool`; awaits asynchronous work; returns `await self.execute_tool(full_name, arguments, timeout)`.
No direct `raise` statement appears in this definition.

[View source #L234-L256](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L234-L256).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager._find_tool_server" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager._find_tool_server</code> · method</summary>

```python
vllm_mlx.mcp.manager.MCPClientManager._find_tool_server(tool_name: str) -> Optional[str]
```

Find which server has a tool by name.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tool_name` | `str` | `yes` | `none` | Tool name (without server prefix) |

**Returns**

- Type: `Optional[str]`
- Direct return expressions: `client.name`; `None`

**Exceptions and behavior**

Method `MCPClientManager._find_tool_server` calls `self._clients.values`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L258-L273](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L258-L273).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.refresh_tools" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.refresh_tools</code> · method</summary>

```python
async vllm_mlx.mcp.manager.MCPClientManager.refresh_tools() -> not annotated
```

Refresh tools from all connected servers.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Method `MCPClientManager.refresh_tools` calls `client.refresh_tools`, `self._clients.values`, `asyncio.gather`; awaits asynchronous work.
No direct `raise` statement appears in this definition.

[View source #L275-L283](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L275-L283).

</details>

<details class="api-contract" id="contract-vllm_mlx.mcp.manager.MCPClientManager.reconnect" markdown="1">
<summary><code>vllm_mlx.mcp.manager.MCPClientManager.reconnect</code> · method</summary>

```python
async vllm_mlx.mcp.manager.MCPClientManager.reconnect(server_name: Optional[str] = None) -> not annotated
```

Reconnect to server(s).

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `server_name` | `Optional[str]` | `no` | `None` | Specific server to reconnect, or None for all |

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Method `MCPClientManager.reconnect` calls `self._clients.get`, `client.disconnect`, `client.connect`, `self._clients.values`; awaits asynchronous work.
No direct `raise` statement appears in this definition.

[View source #L285-L301](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L285-L301).

</details>

## 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 |
| --- | --- | --- | --- | --- |
| [`MCPClientManager`](#contract-vllm_mlx.mcp.manager.MCPClientManager) | class | `MCPClientManager(config: MCPConfig)` | Manages multiple MCP server connections. | [#L22-L301](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L22-L301) |
| [`MCPClientManager.__init__`](#contract-vllm_mlx.mcp.manager.MCPClientManager.__init__) | method | `MCPClientManager.__init__(config: MCPConfig) -> not annotated` | Initialize MCP Client Manager. | [#L33-L47](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L33-L47) |
| [`MCPClientManager.is_started`](#contract-vllm_mlx.mcp.manager.MCPClientManager.is_started) | method | `MCPClientManager.is_started() -> bool` | Check if manager has been started. | [#L50-L52](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L50-L52) |
| [`MCPClientManager.start`](#contract-vllm_mlx.mcp.manager.MCPClientManager.start) | method | `async MCPClientManager.start() -> not annotated` | Start the manager and connect to all enabled servers. | [#L54-L96](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L54-L96) |
| [`MCPClientManager.stop`](#contract-vllm_mlx.mcp.manager.MCPClientManager.stop) | method | `async MCPClientManager.stop() -> not annotated` | Stop the manager and disconnect from all servers. | [#L98-L112](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L98-L112) |
| [`MCPClientManager.get_all_tools`](#contract-vllm_mlx.mcp.manager.MCPClientManager.get_all_tools) | method | `MCPClientManager.get_all_tools() -> List[MCPTool]` | Get all tools from all connected servers. | [#L114-L125](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L114-L125) |
| [`MCPClientManager.get_all_tools_openai`](#contract-vllm_mlx.mcp.manager.MCPClientManager.get_all_tools_openai) | method | `MCPClientManager.get_all_tools_openai() -> List[Dict[str, Any]]` | Get all tools in OpenAI function calling format. | [#L127-L134](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L127-L134) |
| [`MCPClientManager.get_merged_tools`](#contract-vllm_mlx.mcp.manager.MCPClientManager.get_merged_tools) | method | `MCPClientManager.get_merged_tools(user_tools: Optional[List[Dict[str, Any]]] = None) -> List[Dict[str, Any]]` | Get MCP tools merged with user-provided tools. | [#L136-L151](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L136-L151) |
| [`MCPClientManager.get_server_status`](#contract-vllm_mlx.mcp.manager.MCPClientManager.get_server_status) | method | `MCPClientManager.get_server_status() -> List[MCPServerStatus]` | Get status of all servers. | [#L153-L160](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L153-L160) |
| [`MCPClientManager.get_client`](#contract-vllm_mlx.mcp.manager.MCPClientManager.get_client) | method | `MCPClientManager.get_client(server_name: str) -> Optional[MCPClient]` | Get client for a specific server. | [#L162-L172](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L162-L172) |
| [`MCPClientManager.execute_tool`](#contract-vllm_mlx.mcp.manager.MCPClientManager.execute_tool) | method | `async MCPClientManager.execute_tool(full_name: str, arguments: Dict[str, Any], timeout: Optional[float] = None) -> MCPToolResult` | Execute a tool by its full name (server__tool). | [#L174-L232](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L174-L232) |
| [`MCPClientManager.execute_tool_call`](#contract-vllm_mlx.mcp.manager.MCPClientManager.execute_tool_call) | method | `async MCPClientManager.execute_tool_call(tool_call: Dict[str, Any], timeout: Optional[float] = None) -> MCPToolResult` | Execute a tool call from OpenAI format. | [#L234-L256](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L234-L256) |
| [`MCPClientManager._find_tool_server`](#contract-vllm_mlx.mcp.manager.MCPClientManager._find_tool_server) | method | `MCPClientManager._find_tool_server(tool_name: str) -> Optional[str]` | Find which server has a tool by name. | [#L258-L273](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L258-L273) |
| [`MCPClientManager.refresh_tools`](#contract-vllm_mlx.mcp.manager.MCPClientManager.refresh_tools) | method | `async MCPClientManager.refresh_tools() -> not annotated` | Refresh tools from all connected servers. | [#L275-L283](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L275-L283) |
| [`MCPClientManager.reconnect`](#contract-vllm_mlx.mcp.manager.MCPClientManager.reconnect) | method | `async MCPClientManager.reconnect(server_name: Optional[str] = None) -> not annotated` | Reconnect to server(s). | [#L285-L301](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mcp/manager.py#L285-L301) |
