# set_server_disabled

> **Function** in `deepagents_code`

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

Add or remove `server_name` from the persistent disabled set.

Refuses to write when the existing config cannot be parsed so a
corrupt or permission-denied file is not silently overwritten —
that would discard sibling sections such as model profiles.

## Signature

```python
set_server_disabled(
    server_name: str,
    disabled: bool,
    *,
    config_path: Path | None = None,
) -> tuple[bool, str | None]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `server_name` | `str` | Yes | MCP server name from `mcpServers` config. |
| `disabled` | `bool` | Yes | `True` to disable, `False` to re-enable. |
| `config_path` | `Path \| None` | No | Override the default config location; intended for tests. Passing a path also excludes managed policy from this read, so production callers must pass `None`. (default: `None`) |

## Returns

`bool`

Tuple of `(ok, detail)`. `detail` is a short user-facing string

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/1425cf0b7c5e88bff8735778af82cf5c90564085/libs/code/deepagents_code/mcp_disabled.py#L453)