# run_mcp_login

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/client/commands/mcp/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
contribute only servers with matching scoped approvals (or the process-wide
`DANGEROUSLY_ENABLE_PROJECT_MCP_SERVERS` allowlist) and no deny-list entry.
Untrusted project-level server entries (for example, from a `.mcp.json`
in a cloned repo) are 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/e14e0adcbe78565ed3650e7f24b2a775d5437d25/libs/code/deepagents_code/client/commands/mcp.py#L88)