# collect_mcp_catalog

> **Function** in `deepagents_code`

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

Discover MCP servers, split into tool groups and unavailable servers.

Best-effort: if discovery itself raises (no config, offline, load error),
the technical detail is logged and a generic `mcp_error` message is
returned so `dcode tools list` still renders the built-in tools while
telling the user discovery failed. Servers that loaded but expose no tools
are reported as `UnavailableServer`s (errored, needing login, or disabled)
rather than silently dropped — surfacing exactly what a user running this
command to debug a missing tool needs to see.

## Signature

```python
collect_mcp_catalog(
    *,
    mcp_config_path: str | None = None,
    trust_project_mcp: bool | None = None,
) -> tuple[list[ToolGroup], list[UnavailableServer], str | None]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `mcp_config_path` | `str \| None` | No | Explicit MCP config path (`--mcp-config`), or `None` to rely on auto-discovery. (default: `None`) |
| `trust_project_mcp` | `bool \| None` | No | Project-level stdio trust decision (`--trust-project-mcp`), forwarded to discovery unchanged. (default: `None`) |

## Returns

`list[ToolGroup]`

`(groups, unavailable, mcp_error)`: per-server tool groups, discovered

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/7794b61a6e76230e8c7a49bdce808b3728305914/libs/code/deepagents_code/tool_catalog.py#L336)