Skip to content

Bypass Docker MCP secret store; pass secrets from environment variables instead #317

@skyzyx

Description

@skyzyx

Summary

Inside my project's mcp.json file, I want to configure a process to execute before docker mcp gateway run.

  1. Process A generates environment variables (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY).
  2. Using -- after process A, it tells process A to run the next command in a subshell containing the environment variables.
  3. The next command is docker mcp gateway run (with parameters).
  4. One of the parameters is --servers aws-api (link).
  5. In mcpServers.envs, set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY so that they get passed to the AWS API MCP server.

Unfortunately, this doesn't seem to be working. According to the debug logs, it's trying to read from config.yaml and docker mcp secret. When it finds nothing, it overwrites AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with empty values.

Context

AWS is kind of a special beast. It has specific ways of accepting AWS credentials, and the credentials themselves come in many forms — (a) long-lived credentials, (b) short-lived STS credentials, and (c) even the use of a credential server (a la on-board EC2 Metadata API).

When you work with several/dozens/hundreds of accounts, and are exploring the use of AWS MCP servers across an entire AWS Organization of accounts, the use of Docker MCP Toolkit becomes a bottleneck as the servers request specific configurations read from config.yaml and Docker MCP secrets. If you want change accounts, you need to manually update the secrets store and config.yaml with the new credentials.

What I'm trying to get to is as close to a 100% ephemeral, project-specific config as possible for integrating Docker MCP Toolkit with my projects in VS Code, Cursor, and Kiro.

Practical code

This uses AWS Vault to provide an ECS-like credential server to other processes (including credential rotation). In this case, I'm passing AWS_CONTAINER_AUTHORIZATION_TOKEN and AWS_CONTAINER_CREDENTIALS_FULL_URI directly to the docker mcp gateway run process.

The underlying AWS CLI and SDKs know how to leverage these environment variables to fetch valid credentials. However there's something about how Docker MCP Toolkit works that seems to be intercepting/interfering with that process.

mcp.json

{
  "mcpServers": {
    "MCP_DOCKER": {
      "disabled": false,
      "command": "executable-shell-script-on-the-path",
      "args": [],
      "env": {
        "AWS_CONTAINER_AUTHORIZATION_TOKEN": "${AWS_CONTAINER_AUTHORIZATION_TOKEN}",
        "AWS_CONTAINER_CREDENTIALS_FULL_URI": "${AWS_CONTAINER_CREDENTIALS_FULL_URI}",
        "AWS_PROFILE": "${AWS_VAULT}",
        "AWS_REGION": "${AWS_REGION}"
      },
      "autoApprove": [],
      "disabledTools": []
    }
  }
}

executable-shell-script-on-the-path

#!/bin/bash
set -euo pipefail

aws-vault exec --duration=15m --ecs-server --region=us-east-2 --lazy {PROFILE} -- \
  docker mcp gateway run \
    --servers=aws-api \
    --servers=aws-core-mcp-server \
    --servers=aws-documentation \
    --servers=aws-terraform \
    --tools=call_aws \
    --tools=fetch_agentcore_doc \
    --tools=manage_agentcore_gateway \
    --tools=manage_agentcore_memory \
    --tools=manage_agentcore_runtime \
    --tools=mcp-add \
    --tools=mcp-create-profile \
    --tools=mcp-find \
    --tools=prompt_understanding \
    --tools=recommend \
    --tools=search_agentcore_docs \
    --tools=suggest_aws_commands \
;

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions