|
| 1 | +--- |
| 2 | +title: Dynamic MCP |
| 3 | +linkTitle: Dynamic MCP |
| 4 | +description: Discover and add MCP servers on-demand using natural language with Dynamic MCP servers |
| 5 | +keywords: dynamic mcps, mcp discovery, mcp-find, mcp-add, code-mode, ai agents, model context protocol |
| 6 | +weight: 35 |
| 7 | +params: |
| 8 | + sidebar: |
| 9 | + badge: |
| 10 | + color: green |
| 11 | + text: New |
| 12 | +--- |
| 13 | + |
| 14 | +Dynamic MCP enables AI agents to discover, add, and compose MCP servers |
| 15 | +on-demand during a conversation, without manual configuration. Instead of |
| 16 | +pre-configuring every MCP server before starting your agent session, clients |
| 17 | +can search the [MCP Catalog](/manuals/ai/mcp-catalog-and-toolkit/catalog.md), |
| 18 | +add servers as needed, and even create new tools that combine multiple MCP |
| 19 | +servers together. |
| 20 | + |
| 21 | +This capability is enabled automatically when you connect an MCP client to the |
| 22 | +[MCP Toolkit](/manuals/ai/mcp-catalog-and-toolkit/toolkit.md). The gateway |
| 23 | +provides a set of primordial tools that agents use to discover and manage |
| 24 | +servers during runtime. |
| 25 | + |
| 26 | +{{% experimental %}} |
| 27 | + |
| 28 | +Dynamic MCP is an experimental feature in early development. While you're |
| 29 | +welcome to try it out and explore its capabilities, you may encounter |
| 30 | +unexpected behavior or limitations. |
| 31 | + |
| 32 | +{{% /experimental %}} |
| 33 | + |
| 34 | +## How it works |
| 35 | + |
| 36 | +When you connect a client to the MCP Gateway, the gateway exposes a small set |
| 37 | +of management tools alongside any MCP servers you've already enabled. These |
| 38 | +management tools let agents interact with the gateway's configuration: |
| 39 | + |
| 40 | +| Tool | Description | |
| 41 | +| ---------------- | ------------------------------------------------------------------------ | |
| 42 | +| `mcp-find` | Search for MCP servers in the catalog by name or description | |
| 43 | +| `mcp-add` | Add a new MCP server to the current session | |
| 44 | +| `mcp-config-set` | Configure settings for an MCP server | |
| 45 | +| `mcp-remove` | Remove an MCP server from the session | |
| 46 | +| `code-mode` | Create a JavaScript-enabled tool that combines multiple MCP server tools | |
| 47 | + |
| 48 | +With these tools available, an agent can search the catalog, add servers, |
| 49 | +handle authentication, and use newly added tools directly without requiring a |
| 50 | +restart or manual configuration. |
| 51 | + |
| 52 | +Dynamically added servers and tools are associated with your _current session |
| 53 | +only_. When you start a new session, previously added servers are not |
| 54 | +automatically included. |
| 55 | + |
| 56 | +## Prerequisites |
| 57 | + |
| 58 | +To use Dynamic MCP, you need: |
| 59 | + |
| 60 | +- Docker Desktop version 4.50 or later, with [MCP Toolkit](/manuals/ai/mcp-catalog-and-toolkit/toolkit.md) enabled |
| 61 | +- An LLM application that supports MCP (such as Claude Desktop, Visual Studio Code, or Claude Code) |
| 62 | +- Your client configured to connect to the MCP Gateway |
| 63 | + |
| 64 | +See [Get started with Docker MCP Toolkit](/manuals/ai/mcp-catalog-and-toolkit/get-started.md) |
| 65 | +for setup instructions. |
| 66 | + |
| 67 | +## Usage |
| 68 | + |
| 69 | +Dynamic MCP is enabled automatically when you use the MCP Toolkit. Your |
| 70 | +connected clients can now use `mcp-find`, `mcp-add`, and other management tools |
| 71 | +during conversations. |
| 72 | + |
| 73 | +To see Dynamic MCP in action, connect your AI client to the Docker MCP Toolkit |
| 74 | +and try this prompt: |
| 75 | + |
| 76 | +```plaintext |
| 77 | +What MCP servers can I use for working with SQL databases? |
| 78 | +``` |
| 79 | + |
| 80 | +Given this prompt, your agent will use the `mcp-find` tool provided by MCP |
| 81 | +Toolkit to search for SQL-related servers in the [MCP Catalog](./catalog.md). |
| 82 | + |
| 83 | +And to add a server to a session, simply write a prompt and the MCP Toolkit |
| 84 | +takes care of installing and running the server: |
| 85 | + |
| 86 | +```plaintext |
| 87 | +Add the postgres mcp server |
| 88 | +``` |
| 89 | + |
| 90 | +## Tool composition with code mode |
| 91 | + |
| 92 | +Beyond discovering and adding servers individually, agents can use |
| 93 | +`code-mode` to create new tools that combine multiple MCP servers. This |
| 94 | +enables sophisticated workflows that coordinate multiple services in a single |
| 95 | +operation. |
| 96 | + |
| 97 | +When you invoke `code-mode`, you specify which servers should be available |
| 98 | +in a sandboxed JavaScript environment. The agent can then write code that calls |
| 99 | +multiple tools, processes their results, and returns unified output. |
| 100 | + |
| 101 | +### How code mode works |
| 102 | + |
| 103 | +1. The agent calls `code-mode` with a list of server names |
| 104 | +2. The gateway creates a sandbox with access to those servers' tools |
| 105 | +3. The agent writes JavaScript code that uses the available tools |
| 106 | +4. The code runs in the sandbox, isolated from your host system |
| 107 | +5. Results are returned to the agent |
| 108 | + |
| 109 | +The agent's code can only interact with the outside world through MCP tools, |
| 110 | +which are already running in isolated containers with restricted privileges. |
| 111 | + |
| 112 | +## Security considerations |
| 113 | + |
| 114 | +Dynamic MCP maintains the same security model as static MCP server |
| 115 | +configuration in MCP Toolkit: |
| 116 | + |
| 117 | +- All servers in the MCP Catalog are built, signed, and maintained by Docker |
| 118 | +- Servers run in isolated containers with restricted resources |
| 119 | +- Code mode runs agent-written JavaScript in an isolated sandbox that can only |
| 120 | + interact through MCP tools |
| 121 | +- Credentials are managed by the gateway and injected securely into containers |
| 122 | + |
| 123 | +The key difference with dynamic capabilities is that agents can add new tools |
| 124 | +during runtime. |
| 125 | + |
| 126 | +## Disabling Dynamic MCP |
| 127 | + |
| 128 | +Dynamic MCP is enabled by default in the MCP Toolkit. If you prefer to use only |
| 129 | +statically configured MCP servers, you can disable the dynamic tools feature: |
| 130 | + |
| 131 | +```console |
| 132 | +$ docker mcp feature disable dynamic-tools |
| 133 | +``` |
| 134 | + |
| 135 | +To re-enable the feature later: |
| 136 | + |
| 137 | +```console |
| 138 | +$ docker mcp feature enable dynamic-tools |
| 139 | +``` |
| 140 | + |
| 141 | +After changing this setting, you may need to restart any connected MCP clients. |
| 142 | + |
| 143 | +## Further reading |
| 144 | + |
| 145 | +Check out the [Dynamic MCP servers with Docker](https://docker.com/blog) blog |
| 146 | +post for more examples and inspiration on how you can use dynamic tools. |
0 commit comments