# Docker Just Fixed 90% of AI Coding By Releasing This

Source: https://www.youtube.com/watch?v=ZOutBmRai2M
Recap page: https://rapidrecap.app/video/ZOutBmRai2M
Generated: 2025-12-02T13:03:22.89+00:00

---
## Quick Overview

Docker fixed a major inefficiency in AI agent tool usage by introducing the Model Context Protocol (MCP) Gateway with dynamic tool selection via code-mode, allowing agents to avoid sending definitions for hundreds of unused tools in the context window, leading to significant token savings (up to ~9,900 tokens per turn) and improved efficiency.

**Key Points:**
- The traditional method of using MCP tools involves sending definitions for all available tools (e.g., 47+ tools, totaling ~10,000+ tokens every turn) into the context window, which is inefficient.
- The new 'code-mode' approach, enabled by the MCP Gateway, allows agents to dynamically select and use only the necessary tools by writing JavaScript code that calls tools directly, reducing context load.
- A real example showed that using code-mode saves approximately 9,900 tokens per turn by only referencing a custom 'analyze_my_repos' tool (100 tokens) instead of including 50+ tool definitions.
- The code-mode tool is a JavaScript-enabled meta-tool that runs in a secure sandbox, exposing MCP tools as plain JS functions (like search_repositories()).
- The video demonstrated dynamically finding and adding the DuckDuckGo MCP server using 'mcp-find' and 'mcp-add' commands, solving the problem of which MCP servers to trust.
- State persistence is managed using volumes, ensuring that intermediate results and state are managed across tool calls without flooding the model's context window.
- The presenter successfully created a custom 'code-mode-multi-search-repos' tool to search GitHub using multiple keywords and output the clean results directly to a Notion page.

![Screenshot at 0:03: An announcement slide introducing the Model Context Protocol \(MCP\), which is presented as a new standard for connecting AI assistants to systems where data lives, aiming to help frontier models produce better, more relevant responses.](https://ss.rapidrecap.app/screens/ZOutBmRai2M/00-00-03.png)

**Context:** The video discusses significant improvements to the Model Context Protocol (MCP) for AI assistants, driven by the need to manage the explosion in the number of available tools (hundreds or thousands) without overwhelming the LLM's context window, which increases cost and latency. The core issue addressed is how to efficiently provide agents access to only the relevant tools for a given task, moving away from hardcoding every tool definition into the prompt.

## Detailed Analysis

The video introduces the Model Context Protocol (MCP) Gateway and the 'code-mode' feature as a solution to the problem of excessive token consumption caused by sending definitions for hundreds of available tools to the LLM on every turn. Traditionally, using multiple tools resulted in over 10,000 tokens per turn just for tool definitions. The new code-mode tool is a JavaScript-enabled meta-tool that runs in a secure sandbox, allowing agents to execute code that calls only the necessary MCP tools, effectively creating custom functions on the fly. This dramatically improves token efficiency; for example, reducing tool context from ~10,000 tokens to just 100 tokens for a complex search task. The architecture involves the agent using the MCP Gateway to access a catalog of trusted MCP servers dynamically, demonstrated by finding and adding the DuckDuckGo server. Furthermore, the code-mode approach enables state persistence using volumes, ensuring that large intermediate results (like a 5GB dataset download) are stored externally and only summary statistics are returned to the model, keeping the context window clean. The presenter demonstrates creating a custom tool, 'code-mode-multi-search-repos', which executes multiple GitHub searches with different keywords, deduplicates the 29 unique results found, sorts them by stars, and formats the output directly into a Notion page, showcasing the power of composing tools via code.

### MCP Evolution

- Introduction of Model Context Protocol (MCP) in Nov 2024
- Growth to thousands of MCP servers in six months
- Identification of key problems: trust, context overload, and autonomous tool usage

### Problems with Traditional Tool Usage

- Tool definitions overload context window (e.g., 50+ tools costing 10,000+ tokens every turn)
- Intermediate tool results consume additional tokens

### Code-Mode Solution Architecture

- Code-mode creates a JavaScript-enabled meta-tool
- It runs in a secure sandbox, exposing MCP tools as plain JS functions
- It combines/transforms results programmatically from multiple tool calls

### Dynamic MCP Management

- Docker implements 'mcp-find' and 'mcp-add' tools via the MCP Gateway
- Demonstrated finding and adding the 'duckduckgo' MCP server dynamically

### Token Efficiency Example

- Traditional method uses 6 separate tool calls resulting in ~10,000+ tokens/turn
- Code-mode creates a custom tool on Turn 1, references it on subsequent turns, saving ~9,900 tokens per turn

### Key Benefits of Code-Mode

- Secure by Design (runs in sandboxed containers)
- Token and Tool Efficiency (only sends necessary tool definitions)
- State Persistence (uses volumes to manage state across tool calls without sending intermediate results to the model)

### Practical Application

- Created a 'github-to-notion' code-mode tool
- Executed the tool to search GitHub for AI coding repos, deduplicate, sort, and write the clean results (name, description, URL) directly to a Notion database page

![Screenshot at 0:00: Title slide announcing the open-sourcing of the Model Context Protocol \(MCP\) on Nov 25, 2024.](https://ss.rapidrecap.app/screens/ZOutBmRai2M/00-00-00.png)
![Screenshot at 0:07: Terminal output showing a list of connected MCP servers \(mcp-hn, Notion, playwright, reddit\) and configuration file locations.](https://ss.rapidrecap.app/screens/ZOutBmRai2M/00-00-07.png)
![Screenshot at 0:18: Slide highlighting the core problem: 'Excessive token consumption from tools makes agents less efficient' due to tool definitions overloading the context window.](https://ss.rapidrecap.app/screens/ZOutBmRai2M/00-00-18.png)
![Screenshot at 0:37: Command-line comparison showing token savings: Traditional method uses ~10,000+ tokens every turn, while code-mode saves ~9,900 tokens per turn.](https://ss.rapidrecap.app/screens/ZOutBmRai2M/00-00-37.png)
![Screenshot at 2:15: Diagram illustrating Dynamic Tools in action: An Agent interacts with an MCP Gateway which selects only relevant tools \(Tool 1, Tool 6\) from the set of all available tools \(Tool 1 through Tool 6\) for the Agent Session.](https://ss.rapidrecap.app/screens/ZOutBmRai2M/00-02-15.png)
