# MCPBackendMiddleware

> **Class** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/mcp_proxy/MCPBackendMiddleware)

Recover failed connections and preserve actionable login errors.

## Signature

```python
MCPBackendMiddleware(
    self,
    backend: StatefulProxyClient[ClientTransport],
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `backend` | `StatefulProxyClient[ClientTransport]` | Yes | Persistent client whose transport this proxy owns. |

## Extends

- `Middleware`

## Constructors

```python
__init__(
    self,
    backend: StatefulProxyClient[ClientTransport],
) -> None
```

| Name | Type |
|------|------|
| `backend` | `StatefulProxyClient[ClientTransport]` |


## Properties

- `backend`

## Methods

- [`on_call_tool()`](https://reference.langchain.com/python/deepagents-code/mcp_proxy/MCPBackendMiddleware/on_call_tool)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/2069079e09546060f5b52b2cd4f0e3c813e820f3/libs/code/deepagents_code/mcp_proxy.py#L71)