Join our Discord Server
Docker Cagent

Docker cagent Integration with MCP

Estimated reading: 4 minutes 727 views

One of cagent’s most powerful features is its integration with the Model Context Protocol (MCP). cagent supports MCP servers, enabling agents to use a wide variety of external tools and services. This enables agents to:

  • Search the web using DuckDuckGo
  • Access GitHub repositories for code analysis
  • Read and write files on the local system
  • Query databases for data retrieval
  • Integrate with APIs for external services
  • Send emails and notifications

Available MCP Tools

Common MCP tools include:

  • Filesystem: Read/write files
  • Shell: Execute shell commands
  • Database: Query databases
  • Web: Make HTTP requests
  • Git: Version control operations
  • Browser: Web browsing and automation
  • Code: Programming language specific tools
  • API: REST API integration tools

Configuring MCP Tools

It supports three transport types: 

  • Local (studio) MCP Server:

toolsets:
  - type: mcp # Model Context Protocol
    command: string # Command to execute
    args: [] # Command arguments
    tools: [] # Optional: List of specific tools to enable
    env: [] # Environment variables for this tool
    env_file: [] # Environment variable files

Example:

toolsets:
  - type: mcp
    command: rust-mcp-filesystem
    args: ["--allow-write", "."]
    tools: ["read_file", "write_file"] # Optional: specific tools only
    env:
      - "RUST_LOG=debug"
  • Remote (SSE) MCP Server:
toolsets:
  - type: mcp # Model Context Protocol
    remote:
      url: string # Base URL to connect to
      transport_type: string # Type of MCP transport (sse or streamable)
      headers:
        key: value # HTTP headers. Mainly used for auth
    tools: [] # Optional: List of specific tools to enable

Example:

toolsets:
  - type: mcp
    remote:
      url: "https://mcp-server.example.com"
      transport_type: "sse"
      headers:
        Authorization: "Bearer your-token-here"
    tools: ["search_web", "fetch_url"]

Using tools via the Docker MCP Gateway

It is recommended to run containerized MCP tools, for security and resource isolation. Under the hood, cagent will run them with the Docker MCP Gateway so that all the tools in the Docker MCP Catalog can be accessed through a single endpoint.

In this example, lets configure duckduckgo to give our agents the ability to search the web:

toolsets:
  - type: mcp
    ref: docker:duckduckgo

Installing MCP Tools

Example installation of local tools with cargo or npm:

# Install Rust-based MCP filesystem tool
cargo install rust-mcp-filesystem

# Install other popular MCP tools
npm install -g @modelcontextprotocol/server-filesystem
npm install -g @modelcontextprotocol/server-git
npm install -g @modelcontextprotocol/server-web

Built-in Tools

Included in cagent are a series of built-in tools that can greatly enhance the capabilities of your agents without needing to configure any external MCP tools.

Configuration Example

toolsets:
  - type: filesystem # Grants the agent filesystem access
  - type: think # Enables the think tool
  - type: todo # Enable the todo list tool
    shared: boolean # Should the todo list be shared between agents (optional)
  - type: memory # Allows the agent to store memories to a local sqlite db
    path: ./mem.db # Path to the sqlite database for memory storage (optional)

Giving an agent access to tools via MCP is a quick way to greatly improve its capabilities, the quality of its results and its general useful-ness.

Get started quickly with the Docker MCP Toolkit and Catalog

Here’s the same basic agent from the example above access to a containerized duckduckgo mcp server and it’s tools by using Docker’s MCP Gateway:

agents:
  root:
    model: openai/gpt-5-mini
    description: A helpful AI assistant
    instruction: |
      You are a knowledgeable assistant that helps users with various tasks.
      Be helpful, accurate, and concise in your responses.
    toolset:
      - type: mcp
        ref: docker:duckduckgo # stdio transport

When using a containerized server via the Docker MCP gateway, you can configure any required settings/secrets/authentication using the Docker MCP Toolkit in Docker Desktop.

Aside from the containerized MCP severs the Docker MCP Gateway provides, any standard MCP server can be used with cagent!

Here’s an example similar to the above but adding read_file and write_file tools from the rust-mcp-filesystem MCP server:

agents:
  root:
    model: openai/gpt-5-mini
    description: A helpful AI assistant
    instruction: |
      You are a knowledgeable assistant that helps users with various tasks.
      Be helpful, accurate, and concise in your responses. Write your search results to disk.
    toolset:
      - type: mcp
        ref: docker:duckduckgo
      - type: mcp
        command: rust-mcp-filesystem # installed with `cargo install rust-mcp-filesystem`
        args: ["--allow-write", "."]
        tools: ["read_file", "write_file"] # Optional: specific tools only
        env:
          - "RUST_LOG=debug"

Leave a Reply

Share this Doc

Docker cagent Integration with MCP

Or copy link

CONTENTS
Join our Discord Server