轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像
交易
充值流量¥8起我的订单
文档
工具
提交工单页面收录
mcp-gateway

hwdsl2/mcp-gateway

hwdsl2

Self-hosted MCP gateway with Bearer token auth. Multi-server hub, env-file config, multi-arch.

1 次收藏下载次数: 0状态:社区镜像维护者:hwdsl2仓库类型:镜像最近更新:8 天前
让 AI 帮你使用轩辕镜像? · 展开查看说明 · 点击收起说明

如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。

只需在 AI 对话中先发送下面这段话即可:

请先阅读并遵守:https://xuanyuan.cloud/agents.md

未读文档前不要生成 pull 命令或排错方案。

查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。

镜像简介
下载命令
镜像标签列表与下载命令
轩辕镜像,加速的不只是镜像。
点击查看

MCP Gateway on Docker

 

GitHub: https://github.com/hwdsl2/docker-mcp-gateway

Part of the https://github.com/hwdsl2/self-hosted-ai-stack — deploy a complete self-hosted AI stack with a single command.

Docker image to run a self-hosted https://modelcontextprotocol.io/ (Model Context Protocol) gateway, providing authenticated access to multiple MCP tool servers over HTTP from a single endpoint. Powered by https://github.com/samanhappy/mcphub with Caddy auth proxy. Designed to be simple and secure by default.

Features:

  • Secure by default — all API requests require a Bearer token (auto-generated on first start)
  • Auto-generates an API key on first start, stored in the persistent volume
  • Multi-server gateway — run multiple MCP tool servers behind a single HTTP endpoint
  • Path-based routing — access all servers at /mcp or individual servers at /mcp/<name>
  • Streamable HTTP + SSE — both MCP transport modes supported
  • Dashboard — web UI at / for monitoring MCP server status
  • Env-file configuration — simple mcp.env file; no JSON editing
  • Built-in MCP servers: filesystem, fetch, GitHub, Brave Search, Git, PostgreSQL, memory, sequential-thinking
  • Caddy reverse proxy enforces Bearer token auth on all API requests (except /health health check)
  • Works with https://github.com/hwdsl2/docker-litellm to give any LLM access to MCP tools
  • Automatically built and published via https://github.com/hwdsl2/docker-mcp-gateway/actions
  • Persistent configuration via a Docker volume
  • Multi-arch: linux/amd64, linux/arm64

📘 New book: The Self-Hosted AI Builder’s Guide. A practical guide to building, securing, and operating your own private AI stack.

Also available:

  • Related AI services: https://github.com/hwdsl2/docker-whisper, https://github.com/hwdsl2/docker-kokoro, https://github.com/hwdsl2/docker-embeddings, https://github.com/hwdsl2/docker-litellm, https://github.com/hwdsl2/docker-ollama, https://github.com/hwdsl2/docker-docling

Security note

MCP servers have no built-in authentication. Exposing them publicly without auth is the same class of problem as the ~175,000 unauthenticated Ollama servers found publicly exposed (source). This image enforces Bearer token authentication on all API requests via a built-in Caddy auth proxy, so unauthorized access is blocked even if the port is accidentally exposed.

Quick start

Step 1. Start the MCP Gateway:

bash
docker run \
    --name mcp \
    --restart=always \
    -v mcp-data:/var/lib/mcp \
    -p 3000:3000/tcp \
    -d hwdsl2/mcp-gateway

On first start, an API key is auto-generated and displayed in the container logs. All API requests require this key.

Note: For internet-facing deployments, using a reverse proxy to add HTTPS is strongly recommended. In that case, also replace -p 3000:3000/tcp with -p 127.0.0.1:3000:3000/tcp in the docker run command above, to prevent direct access to the unencrypted port.

Step 2. Get the API key:

bash
# View the key in the container logs
docker logs mcp

# Or retrieve it for use in scripts
MCP_KEY=$(docker exec mcp mcp_manage --getkey)

The API key is displayed in a box labeled MCP Gateway API key. To display it again at any time:

bash
docker exec mcp mcp_manage --showkey

Step 3. Test with the API:

bash
MCP_KEY=$(docker exec mcp mcp_manage --getkey)

# Test the MCP endpoint (fetch server is enabled by default)
curl http://localhost:3000/mcp \
  -H "Authorization: Bearer $MCP_KEY"

# Check gateway health (no auth required)
curl http://localhost:3000/health

Note: The docker exec management commands (mcp_manage) do not require the API key.

To learn more about how to use this image, read the sections below.

Community

  • 📬 Get project updates and free deployment guides (1–2 emails/month)
  • 💬 Join the r/selfhostedstack community for discussions and showcases
  • ⭐ Star the repository if you find it useful — it helps others discover it
Self-hosted *** & networking projects
  • https://github.com/hwdsl2/setup-ipsec-***
  • https://github.com/hwdsl2/docker-ipsec-***-server
  • https://github.com/hwdsl2/docker-***
  • https://github.com/hwdsl2/docker-open***
  • https://github.com/hwdsl2/docker-***

Requirements

  • A Linux server (local or cloud) with Docker installed
  • At least 512 MB of available RAM
  • TCP port 3000 (or your configured port) accessible

Download

Get the trusted build from the https://hub.docker.com/r/hwdsl2/mcp-gateway/:

bash
docker pull hwdsl2/mcp-gateway

Alternatively, you may download from https://quay.io/repository/hwdsl2/mcp-gateway:

bash
docker pull quay.io/hwdsl2/mcp-gateway
docker image tag quay.io/hwdsl2/mcp-gateway hwdsl2/mcp-gateway

Supported platforms: linux/amd64 and linux/arm64.

Environment variables

All variables are optional. If not set, secure defaults are used automatically.

This Docker image uses the following variables, that can be declared in an env file (see https://github.com/hwdsl2/docker-mcp-gateway/blob/main/mcp.env.example):

VariableDescriptionDefault
MCP_API_KEYAPI key for authenticating requests (auto-generated if not set)Auto-generated
MCP_PORTTCP port for the gateway (1–65535)3000
MCP_HOSTHostname or IP shown in startup info and --showkey outputAuto-detected
MCP_SERVERSComma-separated list of MCP servers to enablefetch
MCP_ADMIN_PASSWORDPassword for the MCPHub dashboard admin account (auto-generated on first start if not set)Auto-generated
MCP_DISABLE_USAGE_COUNTSSet to 1 to disable anonymous aggregate usage counts.(not set)

Note: In your env file, you may enclose values in single quotes, e.g. VAR='value'. Do not add spaces around =. If you change MCP_PORT, update the -p flag in the docker run command accordingly.

Example using an env file:

bash
cp mcp.env.example mcp.env
# Edit mcp.env and set your values, then:
docker run \
    --name mcp \
    --restart=always \
    -v mcp-data:/var/lib/mcp \
    -v ./mcp.env:/mcp.env:ro \
    -p 3000:3000/tcp \
    -d hwdsl2/mcp-gateway

Available MCP servers

Enable servers by listing them in MCP_SERVERS (comma-separated):

ServerRequired configDescription
fetch—Fetch URLs and extract content
filesystemMCP_FILESYSTEM_DIRSRead/write files in allowed directories
githubMCP_GITHUB_TOKENGitHub API access (repos, issues, PRs)
brave-searchMCP_BRAVE_API_KEYWeb search via Brave Search API
gitMCP_GIT_REPOGit repository tools (status, diff, commit, log)
postgresMCP_POSTGRES_URLQuery PostgreSQL databases
memory—Knowledge graph / persistent memory
sequential-thinking—Structured thinking and reasoning

Example:

bash
# Enable filesystem, fetch, and GitHub servers
MCP_SERVERS=filesystem,fetch,github
MCP_FILESYSTEM_DIRS=/data/docs,/data/projects
MCP_GITHUB_TOKEN=ghp_your_token_here

For the filesystem server, bind-mount host directories into the container:

bash
docker run \
    --name mcp \
    --restart=always \
    -v mcp-data:/var/lib/mcp \
    -v ./mcp.env:/mcp.env:ro \
    -v /home/user/documents:/data/docs:ro \
    -v /home/user/projects:/data/projects \
    -p 3000:3000/tcp \
    -d hwdsl2/mcp-gateway

For the git server, bind-mount the repository into the container and set MCP_GIT_REPO:

bash
MCP_SERVERS=git
MCP_GIT_REPO=/repo
bash
docker run \
    --name mcp \
    --restart=always \
    -v mcp-data:/var/lib/mcp \
    -v ./mcp.env:/mcp.env:ro \
    -v /home/user/myrepo:/repo \
    -p 3000:3000/tcp \
    -d hwdsl2/mcp-gateway

Managing MCP servers

Use docker exec to manage the gateway with the mcp_manage helper script.

List enabled servers:

bash
docker exec mcp mcp_manage --list

Test a specific server:

bash
docker exec mcp mcp_manage --test fetch
docker exec mcp mcp_manage --test github

Show gateway status:

bash
docker exec mcp mcp_manage --status

Show the API key:

bash
docker exec mcp mcp_manage --showkey

Get the API key (machine-readable, for use in scripts):

bash
MCP_KEY=$(docker exec mcp mcp_manage --getkey)

Add or remove servers at runtime:

Use the MCPHub dashboard at http://<server>:3000/ to add, configure, or remove MCP servers without restarting the container. Changes are saved to the persistent volume and survive restarts.

Note: MCP_SERVERS only applies on the first run when mcp_settings.json is created. After that, the dashboard is the way to manage servers. To re-apply MCP_SERVERS from scratch, remove the config file and restart:

bash
docker exec mcp rm /var/lib/mcp/mcp_settings.json
docker restart mcp

Using the API

All API requests require a Bearer token. Retrieve the API key first:

bash
MCP_KEY=$(docker exec mcp mcp_manage --getkey)

MCP endpoint (all enabled servers):

bash
curl http://localhost:3000/mcp \
  -H "Authorization: Bearer $MCP_KEY"

MCP endpoint (specific server):

bash
curl http://localhost:3000/mcp/fetch \
  -H "Authorization: Bearer $MCP_KEY"

Dashboard (web UI):

Open http://localhost:3000/ in a browser with Authorization: Bearer <key>, or use a client that supports header injection.

Health check (no auth required):

bash
curl http://localhost:3000/health

Connecting AI clients

Cline (VS Code) — in Cline's MCP settings:

json
{
  "mcpServers": {
    "gateway": {
      "url": "http://localhost:3000/mcp",
      "transport": "streamable-http",
      "headers": {
        "Authorization": "Bearer <api_key>"
      }
    }
  }
}

Claude Desktop — in claude_desktop_config.json:

json
{
  "mcpServers": {
    "gateway": {
      "url": "http://localhost:3000/mcp",
      "transport": "streamable-http",
      "headers": {
        "Authorization": "Bearer <api_key>"
      }
    }
  }
}

Persistent data

All gateway data is stored in the Docker volume (/var/lib/mcp inside the container):

/var/lib/mcp/
├── mcp_settings.json   # Generated MCPHub configuration
├── .api_key            # API key (auto-generated, or synced from MCP_API_KEY)
├── .initialized        # First-run marker
├── .port               # Saved port (used by mcp_manage)
├── .servers            # Enabled servers list (used by mcp_manage)
└── .Caddyfile          # Generated Caddy config (auth proxy)

mcp_settings.json is generated from MCP_SERVERS on first run only. Subsequent restarts reuse the existing file, preserving any changes made via the dashboard.

Back up the Docker volume to preserve your configuration and API key.

Using docker-compose

bash
cp mcp.env.example mcp.env
# Edit mcp.env and set your values, then:
docker compose up -d
docker logs mcp

Example docker-compose.yml (already included):

yaml
services:
  mcp:
    image: hwdsl2/mcp-gateway
    container_name: mcp
    restart: always
    ports:
      - "3000:3000/tcp"  # For a host-based reverse proxy, change to "127.0.0.1:3000:3000/tcp"
    volumes:
      - mcp-data:/var/lib/mcp
      - ./mcp.env:/mcp.env:ro
      # Mount host directories for the filesystem MCP server (optional):
      # - /path/to/docs:/data/docs:ro
      # - /path/to/code:/data/code:ro

volumes:
  mcp-data:
    name: mcp-data

Note: For internet-facing deployments, using a reverse proxy to add HTTPS is strongly recommended. In that case, also change "3000:3000/tcp" to "127.0.0.1:3000:3000/tcp" in docker-compose.yml, to prevent direct access to the unencrypted port.

Using a reverse proxy

For internet-facing deployments, place a reverse proxy in front of MCP Gateway to handle HTTPS termination. The server works without HTTPS on a local or trusted network, but HTTPS is recommended when the API endpoint is exposed to the internet.

Use one of the following addresses to reach the MCP Gateway container from your reverse proxy:

  • mcp:3000 — if your reverse proxy runs as a container in the same Docker network as MCP Gateway (e.g. defined in the same docker-compose.yml).
  • 127.0.0.1:3000 — if your reverse proxy runs on the host and port 3000 is published (the default docker-compose.yml publishes it).

Note: The Authorization: Bearer header passes through reverse proxies automatically — no special configuration needed.

Example with https://caddyserver.com/docs/ (https://hub.docker.com/_/caddy) (automatic TLS via Let's Encrypt, reverse proxy in the same Docker network):

Caddyfile:

mcp.example.com {
  reverse_proxy mcp:3000
}

Example with nginx (reverse proxy on the host):

nginx
server {
    listen 443 ssl;
    server_name mcp.example.com;

    ssl_certificate     /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;

    location / {
        proxy_pass         http://127.0.0.1:3000;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;       # required for SSE and WebSocket
        proxy_read_timeout 300s;
        proxy_buffering    off;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
    }
}

After setting up a reverse proxy, set MCP_HOST=mcp.example.com in your env file so that the correct endpoint URL is shown in the startup logs and mcp_manage --showkey output.

Update Docker image

To update the Docker image and container, first download the latest version:

bash
docker pull hwdsl2/mcp-gateway

If the Docker image is already up to date, you should see:

Status: Image is up to date for hwdsl2/mcp-gateway:latest

Otherwise, it will download the latest version. Remove and re-create the container:

bash
docker rm -f mcp
# Then re-run the docker run command from Quick start with the same volume.

Your configuration and API key are preserved in the mcp-data volume.

Using with other AI services

MCP Gateway can be used as the MCP tool gateway in a broader self-hosted AI setup.

For full and lightweight Docker Compose stacks, manual docker run examples, and voice/RAG/MCP pipeline examples with Kokoro, Embeddings, LiteLLM, Ollama, Docling, and MCP Gateway, see https://github.com/hwdsl2/self-hosted-ai-stack.

Connect MCP Gateway to LiteLLM:

yaml
# In your LiteLLM config, add the MCP gateway as a tool source:
mcp_servers:
  - url: http://mcp:3000/mcp
    transport: http
    headers:
      Authorization: "Bearer <mcp_api_key>"

Usage counts

See https://github.com/hwdsl2/docker-mcp-gateway#usage-counts.

Technical details

  • Base image: samanhappy/mcphub (Python 3.13 + Node.js 22)
  • Auth proxy: https://caddyserver.com (always active, enforces Bearer token auth)
  • Gateway: https://github.com/samanhappy/mcphub (multi-server MCP hub)
  • MCPHub internal port: 3001 (not published; Caddy proxies from MCP_PORT)
  • Data directory: /var/lib/mcp (Docker volume)
  • Gateway API: http://localhost:3000 (or your configured port)
  • MCP endpoint: http://localhost:3000/mcp
  • Multi-arch: linux/amd64, linux/arm64

License

Note: The software components inside the pre-built image (such as MCPHub, Caddy, and their dependencies) are under the respective licenses chosen by their respective copyright holders. As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Copyright (C) 2026 Lin Song
This work is licensed under the https://opensource.org/licenses/MIT.

MCPHub is Copyright (C) 2025 samanhappy, and is distributed under the https://github.com/samanhappy/mcphub/blob/main/LICENSE.

Caddy is Copyright (C) 2015 Matthew Holt and The Caddy Authors, and is distributed under the https://github.com/caddyserver/caddy/blob/master/LICENSE.

This project is an independent Docker setup for MCPHub and is not affiliated with, endorsed by, or sponsored by MCPHub.

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 mcp-gateway 镜像标签

docker pull docker.xuanyuan.run/hwdsl2/mcp-gateway:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull hwdsl2/mcp-gateway:<标签>

轩辕镜像配置手册

按平台快速找到配置文档

一键安装

一键安装 Docker

Linux Docker 一键安装

AI

用 AI 使用轩辕镜像

agents.md · AI 对话 · 提示词

Docker

登录仓库拉取

登录认证 · 私有仓库

专属域名拉取

免登录 · 高速拉取

Linux

Docker 镜像配置

Windows / Mac

Docker Desktop 配置

MacOS OrbStack

OrbStack 容器

Apple Container

macOS 原生容器

Docker Compose

Compose 项目配置

NAS

群晖

Synology 配置

飞牛

fnOS 镜像配置

绿联

绿联 NAS

威联通

QNAP 配置

极空间

极空间 NAS

Unraid

Unraid NAS

企业仓库

其他仓库

ghcr · Quay · nvcr

Harbor 镜像源

Proxy Repository 对接

Portainer 镜像源

Registries 配置

Nexus 镜像源

Docker Proxy 缓存

开发工具

Dev Containers

VS Code 开发容器

Podman

Podman 配置指南

Singularity / Apptainer

HPC 科学计算容器

Kubernetes

K8s Containerd

Kubernetes · Containerd

K3s

轻量级集群

面板 / 网络

爱快路由

爱快 4.0 · iKuai 镜像加速

宝塔面板

一键配置镜像源

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

功能

版本功能对比

功能对比 · 版本选择

支持的镜像仓库

Docker Hub · GCR · GHCR

专属域名用法

专属域名 · 开启停用 · 多仓库

新手拉取配置

登录 · 专属域名 · 配置

docker search 限制

专属域名 · Hub 搜索

不支持 push

仅支持 pull · 不支持

拉取速度原因

带宽 · 缓存 · 冷热镜像

错误码

402 与流量用尽

402 · 流量包 · 充值

401 认证失败

401 · docker login

manifest unknown

标签错误 · 镜像不存在

410 Gone 排查

410 · Docker 升级

429 限流

免费版 · 专业版 · 企业版 · 请求频率

其他报错

DNS 超时

DNS 解析 · 网络超时

TLS 证书失败

no matching manifest(架构)

docker.sock / daemon

账号

失败是否计费

manifest · blob · 计费

申请开票(企业 / 个人)

开票 · 发票 · 工单

修改登录密码

网站 · 仓库 · 重置

注销账户

工单 · 数据 · 注销

原理

mirrors 不生效

daemon.json · 重启

去掉域名前缀

docker tag · 重命名

指定架构拉取

ARM64 · AMD64 · 多架构

latest 与「最新」

digest · 版本号 · 标签

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
hwdsl2/mcp-gateway
定价查看流量套餐与价格
博客Docker 镜像公告与技术博客
专业版 · 高速稳定拉取镜像
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
50GB 仅 ¥8/年
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
用户协议·隐私政策·增值电信业务经营许可证:浙B2-20261007·©2024-2026 源码跳动©2024-2026 杭州源码跳动科技有限公司·商务合作:点击复制邮箱

更多 mcp-gateway 镜像推荐

hwdsl2/whisper-server logo

hwdsl2/whisper-server

hwdsl2
Self-hosted Whisper speech-to-text server with an OpenAI-compatible API. Powered by faster-whisper.
3 次收藏5万+ 次下载
8 天前更新
hwdsl2/kokoro-server logo

hwdsl2/kokoro-server

hwdsl2
Docker镜像用于运行Kokoro文本转语音服务器,提供与OpenAI兼容的音频语音API,支持多语言高质量语音合成,可私有化部署,数据本地存储保障隐私安全。
2 次收藏1万+ 次下载
8 天前更新
hwdsl2/litellm-server logo

hwdsl2/litellm-server

hwdsl2
私有自托管的LiteLLM AI网关,提供OpenAI兼容API,支持100+大语言模型提供商,帮助用户统一管理和调用不同来源的LLM服务。
1 次收藏1万+ 次下载
8 天前更新
hwdsl2/docling-server logo

hwdsl2/docling-server

hwdsl2
自托管Docling文档解析服务器,支持PDF、DOCX等多种格式转换为结构化Markdown/JSON,可选NVIDIA GPU加速,数据本地存储保障隐私,适用于RAG应用等场景。
2 次收藏1万+ 次下载
8 天前更新
hwdsl2/embeddings-server logo

hwdsl2/embeddings-server

hwdsl2
基于Hugging Face TEI的自托管文本嵌入与重排序服务器,提供OpenAI兼容API,支持隐私优先的本地部署,数据不发送至第三方,可灵活切换模型并启用重排序功能。
1 次收藏1万+ 次下载
8 天前更新
hwdsl2/ollama-server logo

hwdsl2/ollama-server

hwdsl2
这是一个默认安全的Ollama本地大语言模型服务器镜像,提供OpenAI兼容API和Bearer token认证,支持模型预拉取、管理及GPU加速,适合本地私有部署。
2 次收藏1万+ 次下载
8 天前更新

查看更多 mcp-gateway 相关镜像