# run_mcp_login

> **Function** in `deepagents_code`

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

Handle `dcode mcp login <server>`.

When `config_path` is omitted, auto-discovered MCP configs are merged in
the same precedence order as the runtime loader, with matching trust
gating: user-level configs are always included, but project-level configs
are only included when the trust store has a fingerprint match. An
untrusted project-level config (for example, a `.mcp.json` in a cloned
repo) is skipped so attacker-controlled `headers` entries cannot exfiltrate
local secrets during the OAuth handshake. When `config_path` is set, that
file alone is loaded and treated as explicitly trusted.

## Signature

```python
run_mcp_login(
    *,
    server: str,
    config_path: str | None,
) -> int
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `server` | `str` | Yes | Target server name from `mcpServers`. |
| `config_path` | `str \| None` | Yes | Optional explicit MCP config path. |

## Returns

`int`

Process exit code: 0 on success, 1 on config or login failure,

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/d1c6946218b4f0f86ab7b02b6bb6af1e4b75cede/libs/code/deepagents_code/mcp_commands.py#L88)