Dynamic MCP: Teaching AI Agents to Configure Themselves

What if your AI chatbot could configure itself based on what customers ask, without developers editing config files? That's Dynamic MCP.

Dynamic MCP: Teaching AI Agents to Configure Themselves

Remember the early days of Docker when you had to manually pull images, configure networks, and set up volumes for every single container? Those days feel archaic now. We're experiencing a similar evolution with AI agents and the Model Context Protocol (MCP).

For months, I've been experimenting with various MCP servers, and the configuration dance became all too familiar: edit a JSON file, restart the agent, test if it works, realize you need another MCP server, rinse and repeat. As someone who manages the Collabnix community and regularly demos Docker's AI capabilities at conferences, I kept thinking: "Why can't agents just configure themselves?"

Well, they can now. Let me show you Dynamic MCP.

The Problem: MCP Configuration Isn't Agentic (Yet)

Here's what a typical MCP workflow looked like until recently:

  1. Discover a new MCP server you need (probably by browsing GitHub)
  2. Context switch out of your agent session
  3. Edit your configuration file (usually claude_desktop_config.json)
  4. Restart your AI application
  5. Test if it works
  6. Repeat when you need another tool

Now multiply this by the 270+ MCP servers available in the Docker MCP Catalog. See the problem?

As the MCP ecosystem explodes (and it is exploding—we've gone from a handful of servers to thousands in less than a year), this manual approach doesn't scale. More importantly, it breaks the agentic flow. Your AI assistant should be able to help you discover and configure the tools it needs, not the other way around.

Enter Dynamic MCP: Agents That Configure Themselves

Dynamic MCP introduces a paradigm shift: agents can now discover, add, and configure MCP servers on-demand during conversations—no manual configuration required.

Think of it as "just-in-time tooling" for AI agents.

Here's what becomes possible:

You: "I need to query my PostgreSQL database"

Agent: [Searches the MCP catalog]
Agent: [Finds and adds the PostgreSQL MCP server]
Agent: [Prompts you for database credentials]
Agent: "Connected! What would you like to query?"

All of this happens within the conversation flow, without you touching a single configuration file.

How It Works: The Primordial Tools

When you connect an AI client to the Docker MCP Gateway, it automatically gets access to a set of "primordial tools"—management capabilities that let agents control their own tooling:

ToolWhat It Does
mcp-findSearch the MCP Catalog by name or description
mcp-addAdd an MCP server to the current session
mcp-config-setConfigure server settings
mcp-removeRemove a server from the session
mcp-execExecute tools from the current session
code-modeCompose multiple MCP tools into JavaScript functions

These tools transform your agent from a passive tool consumer into an active tool manager.

Let me show you how this works in practice. I connected Claude Desktop to the Docker MCP Gateway and had this conversation:

Me: "Can you search the web for the latest Docker security best practices?"

Claude: "I don't currently have web search capabilities, but I can find and add the DuckDuckGo MCP server. Let me do that."

Behind the scenes, Claude:

  1. Called mcp-find with query "search"
  2. Found the DuckDuckGo MCP server
  3. Called mcp-add to install and run it
  4. Performed the search using the newly added tool

The entire process took seconds, and I never left the chat interface.

Handling OAuth Flows Gracefully

Some MCP servers require authentication. Dynamic MCP handles this elegantly through MCP elicitations—a standardized way for servers to request user input.

Here's what happens when you add a server that needs OAuth (like Notion or Google Drive):

You: "Add the Notion MCP server"

Agent: [Searches and finds Notion MCP]
Agent: [Attempts to add it]
Gateway: [Detects OAuth requirement]
Agent: "This server requires authorization. Please click the link below to connect your Notion account:"

The agent pauses, waits for you to complete OAuth, then continues automatically. The configuration flow is guided by the agent, not buried in documentation.

Tool Composition with Code Mode (Experimental)

Here's where things get really interesting. Dynamic MCP includes an experimental code-mode tool that lets agents write JavaScript code to compose multiple MCP tools into custom workflows.

Why This Matters

Standard MCP usage involves:

  • Tool definitions sent with every request (token heavy)
  • Individual tool calls for each operation (slow)
  • Results returned after each step (context bloat)

Code mode changes this by:

  • Writing code that uses multiple tools internally
  • Running that code in a secure Docker container
  • Returning only the final result

Example: GitHub + Markdown Workflow

I asked Claude to "Create a summary of all open issues in my repository and format it as markdown."

With code mode, Claude:

  1. Wrote JavaScript that calls the GitHub MCP to fetch issues
  2. Called the Markdownify MCP to format the output
  3. Ran everything in a sandboxed container
  4. Returned the final formatted markdown

Result: One tool call instead of dozens, dramatically fewer tokens, and the same security guarantees (everything runs in isolated containers).

Security: Same Guarantees, Dynamic Discovery

Dynamic MCP maintains Docker's security-first approach:

Catalog Curation: All servers in the Docker MCP Catalog are built, signed, and maintained by Docker
Container Isolation: Every MCP server runs in its own isolated container
Sandboxed Execution: Code mode runs in a restricted sandbox that can only interact through MCP tools
Credential Management: The gateway handles secrets securely without exposing them to agents

The only difference? Agents can now add these secure tools dynamically instead of requiring manual pre-configuration.

Getting Started: Try It Yourself

Dynamic MCP is available now in Docker Desktop 4.50+. Here's how to start:

Step 1: Enable MCP Toolkit

If you haven't already:

# Check your Docker Desktop version
docker version

# MCP Toolkit should be enabled by default in 4.50+
# If not, enable it in Docker Desktop Settings → Features

Dynamic MCP is enabled by default in the MCP Toolkit. If you prefer to use only statically configured MCP servers, you can disable the dynamic tools feature:

docker mcp feature
Docker MCP Toolkit's CLI - Manage your MCP servers and clients.

Usage: docker mcp feature

Available Commands:
  disable     Disable an experimental feature
  enable      Enable an experimental feature
  ls          List all available features and their status
docker mcp feature enable dynamic-tools
Feature 'dynamic-tools' enabled successfully.

This feature enables dynamic tool discovery and execution capabilities.
When enabled, the gateway provides internal tools for managing MCP servers:
  - mcp-find: search for available MCP servers in the catalog
  - mcp-add: add MCP servers to the registry and reload configuration
  - mcp-remove: remove MCP servers from the registry and reload configuration

No additional flags are needed - this applies to all gateway runs.

Step 2: Connect Your AI Client

Using Claude Code:

# Connect Claude Desktop to the MCP Gateway
docker mcp client connect claude-code


=== Project-wide MCP Configurations (/Users/ajeetsraina/catalog-service-node-chatbot) ===
 ● claude-code: connected
   MCP_DOCKER: Docker MCP Catalog (gateway server) (stdio)
 ● cursor: no mcp configured
 ● vscode: no mcp configured
You might have to restart 'claude-code'.
Tip: Your client is now connected! Use docker mcp tools ls to see your available tools
docker mcp tools ls
89 tools:
 - add_comment_to_pending_review - Add review comment to the requester's latest pending pull request review
 - add_issue_comment - Add comment to issue
 - aggregate - aggregate
 - assign_copilot_to_issue - Assign Copilot to issue
 - code-mode - Create a JavaScript-enabled tool that combines multiple MCP server tools.
 - collection-indexes - collection-indexes
 - collection-schema - collection-schema
 - collection-storage-size - collection-storage-size
 - connect - connect
 - count - count
 - create-collection - create-collection
 - create-index - create-index
 - create_branch - Create branch
 - create_or_update_file - Create or update file
 - create_pull_request - Open new pull request
 - create_repository - Create repository
 - db-stats - db-stats
 - delete-many - delete-many
 - delete_file - Delete file
 - download_paper - Download and convert an arXiv paper to readable markdown format for analysis and reading.
 - drop-collection - drop-collection
 - drop-database - drop-database
 - drop-index - drop-index
 - explain - explain
 - export - export
 - fetch - Fetches a URL from the internet and optionally extracts its contents as markdown.
 - find - find
 - firecrawl_check_crawl_status - Check the status of a crawl job.
 - firecrawl_crawl - Starts a crawl job on a website and extracts content from all pages.
 - firecrawl_extract - Extract structured information from web pages using LLM capabilities.
 - firecrawl_map - Map a website to discover all indexed URLs on the site.
 - firecrawl_scrape - Scrape content from a single URL with advanced options.
 - firecrawl_search - Search the web and optionally extract content from search results.
 - fork_repository - Fork repository
 - get-library-docs - Fetches up-to-date documentation for a library.
 - get_commit - Get commit details
 - get_dependency_types - Given an array of npm package names (and optional versions), fetch whether each package ships its own TypeScript definitions or has a corresponding @types/… package, and return the raw .d.ts text.
 - get_file_contents - Get file or directory contents
 - get_label - Get a specific label from a repository.
 - get_latest_release - Get latest release
 - get_me - Get my user profile
 - get_release_by_tag - Get a release by tag name
 - get_tag - Get tag details
 - get_team_members - Get team members
 - get_teams - Get teams
 - insert-many - insert-many
 - issue_read - Get issue details
 - issue_write - Create or update issue.
 - list-collections - list-collections
 - list-databases - list-databases
 - list_branches - List branches
 - list_commits - List commits
 - list_issue_types - List available issue types
 - list_issues - List issues
 - list_papers - List all previously downloaded and converted papers that are available in local storage for immediate reading and analysis.
 - list_pull_requests - List pull requests
 - list_releases - List releases
 - list_tags - List tags
 - mcp-add - Add a new MCP server to the session.
 - mcp-config-set - Set configuration values for MCP servers.
 - mcp-exec - Execute a tool that exists in the current session.
 - mcp-find - Find MCP servers in the current catalog by name, title, or description.
 - mcp-remove - Remove an MCP server from the registry and reload the configuration.
 - merge_pull_request - Merge pull request
 - mongodb-logs - mongodb-logs
 - pull_request_read - Get details for a single pull request
 - pull_request_review_write - Write operations (create, submit, delete) on pull request reviews.
 - push_files - Push files to repository
 - read_paper - Read the full text content of a previously downloaded and converted research paper in clean markdown format.
 - rename-collection - rename-collection
 - request_copilot_review - Request Copilot review
 - resolve-library-id - Resolves a package/product name to a Context7-compatible library ID and returns a list of matching libraries.
 - run_js - Install npm dependencies and run JavaScript code inside a running sandbox container.
 - run_js_ephemeral - Run a JavaScript snippet in a temporary disposable container with optional npm dependencies, then automatically clean up.
 - sandbox_exec - Execute one or more shell commands inside a running sandbox container.
 - sandbox_initialize - Start a new isolated Docker container running Node.js.
 - sandbox_stop - Terminate and remove a running sandbox container.
 - search_code - Search code
 - search_issues - Search issues
 - search_npm_packages - Search for npm packages by a search term and get their name, description, and a README snippet.
 - search_papers - Search for papers on arXiv with advanced filtering and query optimization.
 - search_pull_requests - Search pull requests
 - search_repositories - Search repositories
 - search_users - Search users
 - sequentialthinking - A detailed tool for dynamic and reflective problem-solving through thoughts.
 - sub_issue_write - Change sub-issue
 - update-many - update-many
 - update_pull_request - Edit pull request
 - update_pull_request_branch - Update pull request branch
Tip: For tool details, use docker mcp tools inspect <tool-name>. To test the tool, use docker mcp tools call <tool-name>

Excellent! Dynamic MCP is working! You can see the key tools:

  • mcp-find - Find MCP servers in catalog
  • mcp-add - Add MCP servers dynamically
  • mcp-remove - Remove MCP servers
  • mcp-config-set - Configure servers
  • mcp-exec - Execute tools
  • code-mode - Compose multiple MCPs

We already have 89 tools loaded! This includes GitHub, MongoDB, Firecrawl, ArXiv, and more. These were likely pre-configured in your project.

Let's Test Dynamic Discovery Now!

Test 1: Inspect mcp-find


docker mcp tools inspect mcp-find
Name: mcp-find
Description: Find MCP servers in the current catalog by name, title, or description. Returns matching servers with their details.
Input schema: Complex schema (detailed inspection not yet implemented)

Test 2: Search for PostgreSQL MCP

# Method 1: Using claude-code

claude-code "use mcp-find to search for 'postgres' or 'postgresql' servers in the catalog"

What I've Built With Dynamic MCP

As someone who creates technical content daily, Dynamic MCP has changed my workflow:

1. Conference Demo Prep

I recently used Dynamic MCP to prepare for a Meetup event. Instead of pre-configuring servers, I let the agent discover and add them on stage—making demos more interactive and showing the "magic" of self-configuring agents.

2. Content Creation Pipeline

I built a workflow where Claude:

  • Searches GitHub for trending Docker projects (using GitHub MCP)
  • Fetches their READMEs (using code mode)
  • Drafts blog posts for Collabnix.com (using Notion MCP)
  • All added dynamically based on what's needed

3. Community Support

In the Collabnix Slack/Discord channels, members often ask "how do I connect to X service?" Now I can demo Dynamic MCP—showing how agents can discover and configure integrations themselves.

The Token Efficiency Win

Here's a stat that shocked me: A typical session with 10+ pre-configured MCP servers can consume hundreds of thousands of tokens just in tool definitions—before you even start the conversation.

With Dynamic MCP:

  • Only the management tools are loaded initially (~few thousand tokens)
  • Servers are added only when needed
  • Code mode reduces multi-step workflows to single calls

In my testing with a GitHub analysis workflow, I saw token usage drop by 60-70% compared to pre-loading all tools.

Current Limitations and What's Coming

Dynamic MCP is marked as experimental, and for good reason. Here's what to know:

Currently Working Well:

  • mcp-find, mcp-add, mcp-remove are reliable
  • OAuth flows with supported services
  • Basic server management

Still Maturing:

  • code-mode is experimental and can be unpredictable
  • Not all MCP servers support dynamic configuration yet
  • Session state doesn't persist across restarts

The Docker team is actively developing this. I'm in regular contact with them, and the roadmap includes:

  • Persistent sessions
  • Improved code mode reliability
  • More sophisticated tool composition
  • Better state management

Looking Ahead: The Agentic Future

Dynamic MCP is a glimpse into where AI tooling is headed. We're moving from:

Static Configuration → Dynamic Discovery
Manual Setup → Agent-Guided Workflows
Pre-Loaded Tools → Just-In-Time Tooling
Individual Tool Calls → Composable Workflows

This isn't just about convenience—it's about empowering agents to be truly autonomous. The future isn't agents that use the tools we give them; it's agents that find, configure, and compose the tools they need.

Resources and Next Steps

Try Dynamic MCP:

Learn More:

Get Help:

Your Turn

I want to hear about your experiences:

  • What MCP servers are you using dynamically?
  • What workflows have you automated with code mode?
  • What's still missing for your use case?

Drop a comment below or find me on Twitter/X and LinkedIn. I'm always excited to see what the community builds with these tools.

And if you're attending WeAreDevelopers or other tech conferences where I'm speaking, come say hi—I'll be demoing Dynamic MCP live.

Until then, happy building! 🚀