MCP (Model Context Protocol) lets you extend the Deep Agents CLI with tools from external servers—file systems, APIs, databases, and more—without modifying the agent itself. The CLI connects to MCP servers at startup, discovers their tools, and makes them available to the agent alongside the built-in tools.Documentation Index
Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-mdrxyo-1777658790-7be347c.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Quickstart
Create a config file
Create a
.mcp.json file at your project root. The format follows the Claude Desktop convention:.mcp.json
Auto-discovery
The CLI automatically searches for.mcp.json files in standard locations. No flags are needed—just place a config file and it gets picked up.
Discovery locations
Configs are checked in this order (lowest to highest precedence):| Priority | Location | Scope |
|---|---|---|
| 1 (lowest) | ~/.deepagents/.mcp.json | User-level—applies to all projects |
| 2 | <project>/.deepagents/.mcp.json | Project-level—.deepagents subdirectory |
| 3 (highest) | <project>/.mcp.json | Project-level—root (Claude Code compatible) |
.git folder, falling back to the current working directory.
When multiple config files exist, their mcpServers entries are merged. If the same server name appears in more than one file, the higher-precedence config wins.
Flags
| Flag | Behavior |
|---|---|
--mcp-config PATH | Add an explicit config as the highest-precedence source (merged on top of auto-discovered configs) |
--no-mcp | Disable MCP entirely—no servers are loaded |
--mcp-config and --no-mcp are mutually exclusive.Claude Code compatibility
If you already have a.mcp.json at your project root for Claude Code, the Deep Agents CLI picks it up automatically—no extra setup needed.
Configuration format
Each key undermcpServers is a server name. The server’s fields determine how the CLI connects to it.
stdio servers (default)
stdio servers are spawned as child processes. The CLI communicates with them over stdin/stdout.mcp-config.json
SSE and HTTP servers
For remote MCP servers, settype to "sse" or "http" and provide a url:
mcp-config.json
Field reference
stdio (default)
stdio (default)
Required:
command. Optional: args, env, plus the shared tool-filter fields.The executable to run.
Arguments passed to the command.
Environment variables set for the subprocess. Use this to pass API keys and other credentials without exposing them in shell history.
sse
sse
Required:
type: "sse", url. Optional: headers, auth, plus the shared tool-filter fields.Transport type. Use
"sse" for Server-Sent Events.The server endpoint URL.
HTTP headers sent with every request. Commonly used for authentication. Values support
${VAR} references to parent-shell environment variables (resolved when the server activates).Set to
"oauth" to drive an OAuth login flow with deepagents mcp login instead of supplying an Authorization header. Cannot be combined with an Authorization header. See OAuth login.http
http
Required:
type: "http", url. Optional: headers, auth, plus the shared tool-filter fields.Transport type. Use
"http" for streamable HTTP. streamable_http and streamable-http are accepted as aliases.The server endpoint URL.
HTTP headers sent with every request. Commonly used for authentication. Values support
${VAR} references to parent-shell environment variables (resolved when the server activates).Set to
"oauth" to drive an OAuth login flow with deepagents mcp login instead of supplying an Authorization header. Cannot be combined with an Authorization header. See OAuth login.The
type field can also be written as transport for compatibility with other MCP clients.Server names must match
[A-Za-z0-9_-]+. Names are used as on-disk basenames for OAuth token files, so path separators and other shell metacharacters are rejected at config load.Header environment variables
Header values support${VAR} substitution from the parent shell, resolved at server activation rather than at config load. One unset variable only fails the server that needs it; the rest still come up.
.mcp.json
Multiple servers
You can configure as many servers as you need. Tools from all servers are merged and available to the agent:mcp-config.json
Tool filtering
Each server may narrow the tools it exposes to the agent with one of two optional fields:allowedTools: keep only the listed tools; drop everything else.disabledTools: drop the listed tools; keep everything else.
- Setting
allowedToolsanddisabledToolson the same server. - Setting either field to an empty list (would silently strip every tool, or be a no-op). Omit the field instead.
.mcp.json
Match rules
Each entry is a literal tool name or anfnmatch-style glob (any entry containing *, ?, or [ is treated as a pattern). Entries are matched against both the bare MCP tool name and the server-prefixed form ({server}_{tool}), so either form works:
Entries that match no loaded tool are logged as a warning, not an error — the underlying MCP server can evolve its tool list across versions without breaking your config.
Tool names or
fnmatch glob patterns to keep. All other tools from this server are dropped. Mutually exclusive with disabledTools.Tool names or
fnmatch glob patterns to drop. All other tools from this server are kept. Mutually exclusive with allowedTools.OAuth login
For remote MCP servers that require OAuth (Slack, GitHub, Notion, Linear, and other hosted MCP endpoints), set"auth": "oauth" on the server entry and run the login subcommand once. Tokens are persisted to disk and refreshed automatically.
OAuth login requires
deepagents-cli>=0.0.46.Configure the server
.mcp.json
auth: "oauth" is mutually exclusive with an Authorization header on the same entry, and cannot be set on a stdio server.
Run the login flow
- Spec-compliant servers (the default): the CLI performs Dynamic Client Registration, opens an Authorization Code + PKCE flow in your browser, and asks you to paste the redirected URL back into the terminal.
- Slack (
slack.com,*.slack.com): same paste-back flow, but with Slack’s public client preseeded. You’re prompted for an optional team ID (e.g.,T01234567) so the app installs into the right workspace. - GitHub (
api.githubcopilot.com): RFC 8628 Device Authorization Grant. The CLI prints a verification URL and a user code; you enter the code in your browser and the CLI polls for completion.
deepagents mcp login reads the same auto-discovered configs the CLI uses at runtime (subject to project-level trust gating). Pass --config <path> to use a specific file:
Token storage
Tokens are written to:<sha256-16(url)> segment is the first 16 hex characters of the SHA-256 of the server URL. The directory is locked to mode 0700 and each token file is mode 0600. Files include the OAuth access token, refresh token, and the dynamically registered client info, all in a schema-versioned payload that’s written atomically (write-to-temp + rename).
Hashing the URL into the filename means the same server name pointing at different URLs (for example, dev vs. prod) gets independent token files and can’t trample each other.
Re-authentication
When refresh fails at runtime (the refresh token expired or was revoked), the CLI marks the server asunauthenticated instead of crashing the agent. The welcome banner shows the count of unauthenticated servers, and /mcp reports the reason per server. Re-run deepagents mcp login <server> to refresh credentials — your conversation continues without restarting.
Server status
Each configured server lands in one of three states after startup:| Status | Meaning |
|---|---|
ok | Connected; tools are loaded and available to the agent |
unauthenticated | OAuth login required or refresh failed — run deepagents mcp login <server> |
error | Pre-flight, discovery, or transport setup failed; an error message is attached |
/mcp in an interactive session to see per-server status, transport, tool list, and the failure reason for non-ok entries. The viewer live-updates as servers connect and supports tab/shift+tab navigation.
Project-level trust
Project-level configs can contain stdio servers that execute local commands and remote servers whoseheaders may interpolate ${VAR} from your environment. To prevent untrusted repositories from running arbitrary code or exfiltrating local secrets on CLI startup, the CLI enforces a default-deny policy for project-level entries.
How it works
- Interactive mode: The CLI prompts for approval before activating project servers, showing each stdio command and remote URL. Approval is persisted using a SHA-256 content fingerprint—if the config changes, you are prompted again.
- Non-interactive mode (
-n): Project servers are silently skipped unless--trust-project-mcpis passed. - Trust covers stdio and remote entries alike — remote servers can SSRF into localhost or cloud-metadata endpoints during the pre-flight probe and exfiltrate
${VAR}values via headers, so they’re gated the same way as stdio. - User-level configs (
~/.deepagents/.mcp.json) are always trusted—the same trust model asconfig.tomlandhooks.json. deepagents mcp loginalso honors project trust: an untrusted project-level config is skipped during login discovery so an attacker-controlled remote entry cannot pull secrets into the OAuth handshake.
Flags
| Flag | Behavior |
|---|---|
--trust-project-mcp | Trust all project-level stdio servers without prompting (for CI and automation) |
Trust store
Trust decisions are stored in~/.deepagents/config.toml:
.mcp.json (which invalidates the fingerprint automatically).
System prompt awareness
Connected MCP servers and their tools are automatically listed in the agent’s system prompt, grouped by server name and transport type. This helps the model reason about tool provenance and failure domains without requiring manual context.Troubleshooting
Server fails to start (stdio)
Server fails to start (stdio)
Verify the command works outside the CLI:Common causes: the package isn’t installed,
npx isn’t on PATH, or required environment variables are missing.Connection refused (SSE/HTTP)
Connection refused (SSE/HTTP)
Check that the remote server is running and the URL is correct. If the server requires authentication, make sure
headers includes the correct credentials.Tools not appearing
Tools not appearing
The CLI prints the number of tools loaded at startup (e.g.,
✓ Loaded 3 MCP tools). If you see 0, the server started successfully but didn’t advertise any tools—check the server’s own logs or documentation.Server shows `unauthenticated` in /mcp
Server shows `unauthenticated` in /mcp
Either you haven’t run
deepagents mcp login <server> yet, or the persisted refresh token expired or was revoked server-side. Run the login command again — your session keeps running and the server will re-attach once tokens are refreshed.`Invalid MCP config at ...`
`Invalid MCP config at ...`
A pre-flight validation rejected
--mcp-config (or an auto-discovered .mcp.json). Common causes: an unsupported server name (must match [A-Za-z0-9_-]+), auth: oauth on a stdio server, both command and url set on the same entry, or a header value that isn’t a string. Fix the highlighted reason and relaunch — the CLI no longer dumps a multi-page subprocess trace for config errors.`${VAR}` header references fail
`${VAR}` header references fail
Header interpolation runs at activation time, so an unset variable only fails the server that needs it. Export the variable in the parent shell or add it to
~/.deepagents/.env. To debug, set DEEPAGENTS_CLI_DEBUG=1 and inspect the per-session log path printed to stderr on shutdown.Further reading
- LangChain MCP guide: protocol details, building custom servers, and using
langchain-mcp-adaptersprogrammatically - MCP specification: the official protocol spec and server registry
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

