Docker Container Execution 标志

Docker Container Execution

社区
kenforthewin

Add agentic coding capabilities to any AI that supports MCP

发布者kenforthewin
代码仓库docker-mcp-server
语言TypeScript
复刻数
2
星标数
6
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Docker Container Execution 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 6 个 Star 和 2 个 Fork。

Docker MCP Server

A Model Context Protocol (MCP) server that runs entirely inside a Docker container, providing secure command execution and file operations through HTTP with bearer token authentication.

🚀 Features

  • Containerized MCP Server: Runs entirely inside Docker with no host dependencies
  • HTTP Transport: Network-based communication with bearer token authentication
  • Secure Command Execution: Run shell commands in isolated container environment
  • File Operations: Read, write, edit, and search files within container workspace
  • Process Management: Track long-running processes with unique IDs
  • Interactive Input: Send input to running processes
  • Smart Timeouts: Intelligent process timeout handling based on output activity

🏗️ Architecture

The MCP server runs inside a Docker container and communicates with clients over HTTP:

MCP Client (via HTTP) ↔ Docker Container (Port 3000)
                              ↓
                        MCP Server (Node.js)
                              ↓
                    Workspace (/app/workspace)
                              ↓
                    Host ./tmp directory (mounted)

Core Components

  • Containerized MCP Server - TypeScript server using @modelcontextprotocol/sdk with StreamableHTTPServerTransport
  • HTTP API - Network-based communication on port 3000
  • Bearer Token Auth - Secure authentication for all requests
  • Docker Container - Debian-based with Node.js, Playwright, and development tools
  • Workspace Mount - Host ./tmp directory mounted to /app/workspace
  • Process Tracking - Background process management with unique IDs

Key Differences from Traditional MCP Servers

  • No Host Installation: Server runs entirely in container
  • Network Access: HTTP-based instead of stdio transport
  • Authentication Required: Bearer token for all requests
  • Self-Contained: All dependencies bundled in container image
  • Direct Execution: No docker exec overhead

📋 Prerequisites

🚀 Quick Start

1. Clone and Setup

bash
git clone <your-repository-url>
cd docker-mcp

2. Start the Server

bash
# Quick start: reset environment and start server
./reset-docker.sh

# Or manually:
npm run docker:build    # Build container with server code
npm run docker:up       # Start container
npm run docker:logs     # View logs and get auth token

3. Get Connection Info

The server logs display the authentication token and connection details:

bash
npm run docker:logs

Look for output like:

============================================================
Docker MCP Server Starting
============================================================
Port: 3000
Auth Token: abc123-def456-ghi789
============================================================

4. Test Connection

bash
# Test with curl
curl -H "Authorization: Bearer YOUR_TOKEN_HERE" \
     http://localhost:3000

# View server logs
npm run docker:logs

🔧 Development Commands

Docker Operations

bash
# Build the container image with server code
npm run docker:build

# Start the containerized MCP server
npm run docker:up

# Stop the container
npm run docker:down

# View server logs (includes auth token)
npm run docker:logs

# Rebuild and restart (after code changes)
npm run docker:restart

# Open bash shell in container
npm run docker:shell

# Complete reset (clean workspace and rebuild)
./reset-docker.sh

Local Development

bash
# Build TypeScript (for development/testing only)
npm run build

# Install/update dependencies
npm install

⚙️ MCP Client Configuration

Configuration Format

MCP clients need to connect via HTTP with bearer token authentication:

json
{
  "url": "http://localhost:3000",
  "headers": {
    "Authorization": "Bearer YOUR_TOKEN_FROM_LOGS"
  }
}

Important:

  • Get the auth token from container logs: npm run docker:logs
  • Token is auto-generated on each container start
  • Token must be included in the Authorization header with Bearer prefix

Claude Desktop Configuration

Add to your Claude Desktop configuration file:

Location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

Configuration:

json
{
  "mcpServers": {
    "docker-mcp": {
      "url": "http://localhost:3000",
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN_FROM_LOGS"
      }
    }
  }
}

Note: Replace YOUR_TOKEN_FROM_LOGS with the actual token from npm run docker:logs

Getting Your Authentication Token

  1. Start the server: npm run docker:up
  2. View logs: npm run docker:logs
  3. Copy the token from the output
  4. Update your client configuration with the token
  5. Restart your MCP client

Verification

After configuration:

  1. Restart your MCP client (e.g., Claude Desktop)
  2. Check that the Docker MCP server shows as connected
  3. Verify access to all available tools

🛠️ Available MCP Tools

🚀 Command Execution

execute_command

Execute shell commands inside the container

Execute any shell command within the container environment with intelligent process tracking.

Parameters:

  • command (string) - The shell command to execute
  • rationale (string) - Explanation of why this command is being executed
  • maxWaitTime (number, optional) - Maximum seconds to wait before returning (default: 20)

Features:

  • Automatic backgrounding for long-running processes
  • Smart timeout based on output activity
  • Process ID returned for monitoring
  • Real-time output capture

check_process

Monitor background processes by ID

Check the status and output of background processes started by execute_command.

Parameters:

  • processId (string) - The process ID returned by a long-running command
  • rationale (string) - Explanation of why you need to check this process

Returns:

  • Process status (running/completed)
  • Current output (stdout/stderr)
  • Exit code (if completed)
  • Runtime duration

send_input

Send input to running background processes

Send input data to interactive processes waiting for user input.

Parameters:

  • processId (string) - The process ID of the running process
  • input (string) - The input to send to the process
  • rationale (string) - Explanation of why you need to send input
  • autoNewline (boolean, optional) - Auto-add newline (default: true)

📁 File Operations

All file operations work within /app/workspace which is mounted from host ./tmp.

file_read

Read files from container filesystem

Read file contents with support for large files through pagination.

Parameters:

  • filePath (string) - Path relative to /app/workspace
  • rationale (string) - Explanation of why you need to read this file
  • offset (number, optional) - Starting line number (default: 0)
  • limit (number, optional) - Maximum lines to read (default: 2000)

file_write

Create or overwrite files

Write content to files with automatic directory creation.

Parameters:

  • filePath (string) - Path relative to /app/workspace
  • content (string) - The content to write
  • rationale (string) - Explanation of why you need to write this file

Important: Use file_read first to understand current state.

file_edit

Perform exact string replacements

Edit files using precise string matching with backup protection.

Parameters:

  • filePath (string) - Path relative to /app/workspace
  • oldString (string) - The exact text to replace
  • newString (string) - The replacement text
  • rationale (string) - Explanation of why you need to edit this file
  • replaceAll (boolean, optional) - Replace all occurrences (default: false)

Important: Use file_read first to get the exact text to match.

file_ls

List directory contents

List files and directories with intelligent filtering.

Parameters:

  • path (string, optional) - Directory path (default: current directory)
  • rationale (string) - Explanation of why you need to list this directory
  • ignore (array, optional) - Glob patterns to ignore

file_grep

Search file contents

Search for patterns in files using grep with regex support.

Parameters:

  • pattern (string) - Search pattern (supports regex)
  • rationale (string) - Explanation of why you need to search
  • path (string, optional) - Directory to search (default: current)
  • include (string, optional) - File pattern filter (e.g., '*.js')
  • caseInsensitive (boolean, optional) - Case insensitive (default: false)
  • maxResults (number, optional) - Result limit (default: 100)

📊 Process Management

Commands run with intelligent timeout handling:

  • Default timeout: 20 seconds of inactivity before backgrounding
  • Maximum timeout: 10 minutes absolute limit
  • Process tracking: Background processes get unique IDs for monitoring
  • Smart waiting: Based on output activity, not fixed intervals

Example Process Flow

javascript
// Long-running command gets backgrounded automatically
const result1 = execute_command({
  command: "npm install",
  rationale: "Installing dependencies"
});
// Returns process ID if backgrounded

// Check status later
const result2 = check_process({
  processId: result1.processId,
  rationale: "Checking installation progress"
});

// Send input to interactive processes
send_input({
  processId: result1.processId,
  input: "y",
  rationale: "Confirming prompt"
});

🔒 Security Considerations

Authentication

  • Bearer Token Required: All requests must include valid bearer token
  • Auto-Generated Token: New token generated on each container start
  • Token Rotation: Restart container to generate new token
  • CORS Enabled: Allows cross-origin requests (consider restricting in production)

Container Isolation

  • Network Isolation: Container exposed only on port 3000
  • Workspace Mount: Only ./tmp directory accessible from host
  • User Permissions: Commands run with container-level permissions
  • No Host Access: Server cannot access host filesystem outside mount

Recommended Security Practices

  1. Token Management: Keep authentication tokens secure and private
  2. Network Restrictions: Use firewall rules to limit access to port 3000
  3. Workspace Isolation: Regularly audit ./tmp directory contents
  4. Resource Limits: Add CPU and memory constraints in docker-compose.yml
  5. Access Logs: Monitor container logs for suspicious activity

🚨 Troubleshooting

Server Won't Start

bash
# Check Docker is running
docker info

# View container logs for errors
npm run docker:logs

# Verify port 3000 is available
lsof -i :3000  # macOS/Linux
netstat -ano | findstr :3000  # Windows

# Complete reset
npm run docker:down
./reset-docker.sh

Can't Connect to Server

bash
# Verify container is running
docker ps | grep mcp-container

# Check server logs for auth token
npm run docker:logs

# Ensure correct URL
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:3000

# Restart container
npm run docker:restart

Code Changes Not Reflected

bash
# Remember: server code is built into container image
# After changing TypeScript code, you MUST rebuild:
npm run docker:restart

# Or manually:
npm run docker:down
npm run docker:build
npm run docker:up

Authentication Failed

bash
# Get current auth token from logs
npm run docker:logs

# Verify token format in client config
# Must be: "Bearer YOUR_TOKEN" (with "Bearer " prefix)

# Token changes on restart - update client config

Permission Errors in Workspace

bash
# Ensure tmp directory exists and is writable
mkdir -p tmp
chmod 755 tmp

# Reset workspace
rm -rf tmp && mkdir tmp

Process Timeout Issues

  • Increase maxWaitTime parameter in execute_command
  • Use check_process to monitor long-running operations
  • Break complex operations into smaller steps
  • Check container resources: docker stats mcp-container

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes in src/
  4. Test with npm run docker:restart
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Add comprehensive error handling
  • Include rationale parameters for all tool operations
  • Test with both quick and long-running commands
  • Document any new MCP tools or capabilities
  • Test authentication and security features

📦 Deployment

Local Deployment

bash
# Production deployment
docker-compose up -d

# View production logs
docker-compose logs -f mcp-container

# Auto-restart on failure
# (already configured with restart: unless-stopped)

Custom Configuration

yaml
# docker-compose.yml
services:
  mcp-container:
    environment:
      - NODE_ENV=production
      - AUTH_TOKEN=your-custom-token  # Optional: set custom token
    ports:
      - "3000:3000"  # Change port mapping if needed
    volumes:
      - ./custom-workspace:/app/workspace

Environment Variables

  • NODE_ENV: Set to production for production deployment
  • Port: Configure via CLI flag --port 3000
  • Token: Set via CLI flag --token your-token (auto-generated if not set)

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙋‍♂️ Support

  • 🐛 Bug Reports: Open an issue with detailed reproduction steps
  • 💡 Feature Requests: Open an issue with your use case
  • 📖 Documentation: Check CLAUDE.md for AI assistant specific guidance
  • 💬 Questions: Open a discussion for general questions

📚 Additional Resources


Built for the Model Context Protocol ecosystem 🤖

Features:

  • ✅ HTTP Transport with Bearer Token Auth
  • ✅ Containerized Architecture
  • ✅ Process Management
  • ✅ File Operations
  • ✅ Network Accessible
  • ✅ Production Ready

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "docker-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "docker-mcp-server@latest"
      ]
    }
  }
}

将 Docker Container Execution MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Docker Container Execution 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 Docker Container Execution 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Docker Container Execution MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "docker-container-execution": {
      "command": "npx",
      "args": [
        "-y",
        "docker-mcp-server"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Docker Container Execution MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Docker Container Execution MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Docker Container Execution 帮我完成这项任务吗?
Docker Container Execution
当然。我已阅读。
以下是我使用 Docker Container Execution 得到的结果。

常见问题

Docker Container Execution MCP 服务器有什么用途?

Docker Container Execution 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Docker Container Execution MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 Docker Container Execution,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 Docker Container Execution MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 Docker Container Execution 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Docker Container Execution MCP 连接到 TypingMind?

Docker Container Execution 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Docker Container Execution MCP 在 TypingMind 中提供哪些工具?

Docker Container Execution 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Docker Container Execution MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 Docker Container Execution 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇