Skip to main content
Connect a managed deep agent to remote Model Context Protocol (MCP) servers to add their tools to the agent. Managed Deep Agents creates the MCP client and loads the tools. Most remote MCP servers require authentication. A connection supplies it, and declaring the connection as user-owned makes each caller authorize their own account. For tools your workspace already manages in Tool Gateway, see Use Tool Gateway tools.
Managed Deep Agents is in beta on LangSmith Cloud and Bring Your Own Cloud (BYOC). Use Managed Deep Agents CLI and SDK v0.10 or later for BYOC.
Declare MCP servers in tools/mcp.ts:
For the full project layout, see Project structure. To implement application logic in the project instead, use an authored tool.

Add MCP servers

Use an MCP server when tools already live on a remote MCP server and you want MDA to load them without importing them into the agent definition.
1

Declare the servers

Use defineMcp to declare one or more remote servers:
tools/mcp.ts
The module must export a named mcp. A project has one MCP declaration, so declare every server in it. The file name also accepts the .tsx, .mts, or .cts variants.Managed Deep Agents supports Streamable HTTP ("http") and legacy SSE ("sse") transports. Stdio MCP servers are not supported. Expose a stdio server over HTTP or implement its operation as an authored tool instead.For connection options, see Manage connections.
2

Select tools (Optional)

By default, Managed Deep Agents exposes every tool from each server. To expose only selected tools, set an allowlist inside that server’s configuration:
To expose every tool except selected tools, replace includeTools with excludeTools.You can use both options together. The denylist applies after the allowlist, and the same tool cannot appear in both lists.Selection uses raw MCP tool names before Managed Deep Agents prefixes them. Tool names are prefixed with the server name by default to avoid collisions. For example, the search_docs_by_lang_chain tool from the langchainDocs server is exposed as langchainDocs_search_docs_by_lang_chain.
3

Pass credentials (Optional)

If an MCP server requires credentials, declare a connection on the server config and create that connection in the workspace.
  • MCP OAuth: For servers that advertise OAuth and support automatic client registration, create with mda connections create <slug> (inferred from the MCP declaration) or mda connections create <slug> --mcp <url>. You do not supply a client ID or secret.
  • Opaque secret or general OAuth: For a static API key, or for a BYOT OAuth app you register yourself, create an opaque secret or general OAuth connection, then set the server’s connection option to connections.get(...).
For create modes, owners, and runtime authorization, see Manage connections.For a Tool Gateway server or tool kit, set auth instead of a connection. See Use Tool Gateway tools.

Use Tool Gateway tools

Tool Gateway serves the tools and connected accounts your LangSmith workspace manages. Declare a Tool Gateway kit or server with "auth": "langsmith", and the agent calls its tools with the credentials of the person running the agent, or of the agent in an agent-owned schedule, with no connection to create.
Using Tool Gateway with Managed Deep Agents requires managed-deepagents version 0.10.5 or later, in both the Python and TypeScript packages.
For example, to give the agent every tool the caller can use, declare the me kit in search mode:
tools/mcp.ts
The URL must be on your deployment’s LangSmith API origin. For a saved kit, profiles, version requirements, and local development, see Connect Managed Deep Agents to Tool Gateway.

Configure MCP servers

Each server supports the following core options: The MCP definition also accepts these options:

Deployment

mda dev and mda deploy discover the MCP declaration under tools/ and include it in the managed configuration. The declaration is not synced to Context Hub.

When to use MCP connectors

For more information, see Project structure.