Skip to content

Add top-level mcps section for reusable MCP server definitions#1947

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/mcp-definitions-a6c70ae4
Mar 6, 2026
Merged

Add top-level mcps section for reusable MCP server definitions#1947
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/mcp-definitions-a6c70ae4

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 5, 2026

Summary

Adds a top-level mcps section to the agent config for defining MCP server configurations once and referencing them by name from agent toolsets. This eliminates duplication when multiple agents use the same MCP server.

Before

agents:
  root:
    toolsets:
      - type: mcp
        ref: docker:context7
  frontend:
    toolsets:
      - type: mcp
        ref: docker:context7  # duplicated
  backend:
    toolsets:
      - type: mcp
        ref: docker:context7  # duplicated

After

mcps:
  context7:
    ref: docker:context7

agents:
  root:
    toolsets:
      - type: mcp
        ref: context7
  frontend:
    toolsets:
      - type: mcp
        ref: context7
  backend:
    toolsets:
      - type: mcp
        ref: context7

Override semantics

  • Toolset fields take precedence over definition fields
  • env maps are merged (toolset values win on key conflicts)
  • Definitions support all MCP sources: command, remote, and ref (docker refs)

Changes

  • pkg/config/latest/types.goMCPToolset type (wraps Toolset, validates at parse time), MCPs field on Config
  • pkg/config/latest/validate.go — Removed docker: prefix restriction from Toolset.validate() (now checked during MCP definition validation)
  • pkg/config/mcps.go — Resolution logic: resolveMCPDefinitions, validateMCPDefinition, applyMCPDefaults
  • pkg/config/config.go — Call resolveMCPDefinitions in validateConfig
  • agent-schema.jsonmcps property and MCPToolset definition
  • examples/mcp-definitions.yaml — Example config
  • pkg/config/mcps_test.go — 9 test cases

Closes #1667

@dgageot dgageot requested a review from a team as a code owner March 5, 2026 18:34
docker-agent[bot]

This comment was marked as outdated.

@dgageot dgageot force-pushed the board/mcp-definitions-a6c70ae4 branch from 55df367 to 812f7a7 Compare March 6, 2026 06:32
rumpl
rumpl previously approved these changes Mar 6, 2026
docker-agent[bot]

This comment was marked as outdated.

Introduce a top-level 'mcps' section in the agent config that allows
defining MCP server configurations once and referencing them by name
from agent toolsets. This eliminates duplication when multiple agents
use the same MCP server.

Agent toolsets reference definitions via 'ref: <name>'. Fields set on
the toolset override the definition; env maps are merged with toolset
values taking precedence on conflicts.

Definitions are validated at parse time using the existing Toolset
validation, rejecting nonsensical fields (e.g. shared, path) and
invalid source combinations.

Closes docker#1667

Assisted-By: cagent
@dgageot dgageot force-pushed the board/mcp-definitions-a6c70ae4 branch from 812f7a7 to 164e679 Compare March 6, 2026 09:36
@dgageot
Copy link
Member Author

dgageot commented Mar 6, 2026

/review

Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Assessment: 🔴 CRITICAL

Found 2 confirmed bugs in the MCP definition resolution logic:

  1. HIGH: The applyMCPDefaults function incorrectly clears the ref field for command-based definitions, losing the definition name
  2. MEDIUM: The Remote struct merge logic only checks the URL field, which can cause Header values to be lost during override operations

Both issues are in newly added code and affect the core functionality of MCP definition resolution.

@dgageot dgageot merged commit 477cff7 into docker:main Mar 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support shared MCP definitions to reduce duplication and enable consistency

3 participants