Token导航 LogoToken导航TokenDH.com
mcpware (Delexw) logo
开发工具stdio官方级别未说明来源级核验

mcpware (Delexw)

MCP Server

Gateway MCP Server - Routes tool calls to Docker-based MCP backends

工具数

0

提示词数

0

GitHub Stars

4

资源数

0
进程管理Docker容器Python工具集成

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

delexw

提供方

delexw

最后核验

2026/5/18 04:03

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python scripts/check_docker_socket.py

详细介绍

网关MCP服务器

![Tests](https://github.com/delexw/mcpware/actions/workflows/tests.yml) ![Coverage](https://github.com/delexw/mcpware) ![Python](https://www.python.org/downloads/) ![License: MIT](https://opensource.org/licenses/MIT)

智能地将MCP请求路由到多个后端服务器。

🎯 主要特点

🚀 绕过工具限制

  • 挑战:MCP客户端通常对一次可以加载的工具数量有限制
  • 解决方案:mcpware仅公开2个路由工具,同时提供对无限后端工具的访问
  • 结果:通过单一网关连接到GitHub(50多种工具)、数据库等!

🔧 其他好处

  • 单一入口点 适用于多个MCP服务器
  • 自动化流程管理 用于后端服务器
  • 基于Docker 隔离和部署

快速开始

# Clone the repository
git clone https://github.com/delexw/mcpware.git
cd mcpware

# Build the Docker image
docker build -t mcpware . --no-cache

# Configure MCP client (see Installation section)

然后按照所示配置MCP客户端 安装 部分。

原理

mcpware作为Docker容器运行,它:

  1. 通过stdio接收MCP客户端的请求
  2. 将它们路由到相应的后端MCP服务器(也在Docker中运行)
  3. 将响应返回给MCP客户端

重要:后端服务器可以使用任何命令(docker, npx, node, python等等)。在Docker中运行mcpware时,后端使用本地命令,如 npxnode 将在mcpware容器内执行。

安装

先决条件

  • 码头工人
  • MCP客户端(光标等)

使用MCP客户端进行设置

  1. 克隆此存储库:
   git clone https://github.com/delexw/mcpware.git
   cd mcpware
  1. 在中配置后端 config.json (见下面的配置部分)
  1. 设置环境变量:

1. 复制示例文件: cp env.example .env 1. 编辑 .env 根据您的实际值:

      GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token_here
      BUILDKITE_API_TOKEN=your_buildkite_token_here
      # Add other environment variables as needed
  1. 添加到MCP客户端配置:

注: 您可以将机密或令牌直接配置到mcpware中 config.json

配置(直接运行Docker):

   {
     "mcpServers": {
       "mcpware": {
         "command": "docker",
         "args": [
           "run",
           "-i",
           "--rm",
           "-v",
           "/path/to/mcpware/config.json:/app/config.json:ro",
           "-v",
           "/var/run/docker.sock:/var/run/docker.sock",
           "--env-file",
           "/path/to/mcpware/.env",
           "mcpware"
         ]
       }
     }
   }

重要:

- 替换 /path/to/mcpware 带有克隆存储库的绝对路径 - Docker套接字挂载(/var/run/docker.sock)mcpware需要启动基于Docker的后端,否则您不需要

为什么要挂载Docker套接字?

- mcpware需要为后端MCP服务器启动Docker容器(如 ghcr.io/github/github-mcp-server) - Docker套接字挂载允许mcpware与Docker通信 - 没有这个挂载,mcpware无法启动作为Docker容器运行的后端服务器

特定于平台的Docker套接字配置

网关需要访问Docker套接字才能启动后端容器。安装路径因平台而异:

为什么需要Docker套接字访问? mcpware充当启动后端MCP服务器的进程管理器。当后端被配置为作为Docker容器运行时(例如。, ghcr.io/github/github-mcp-server),mcpware需要:

  • 创建并启动Docker容器
  • 管理其生命周期(停止/重新启动)
  • 通过stdio与他们沟通

没有Docker套接字访问,mcpware无法启动基于Docker的后端,并将因权限错误而失败。

快速检查

运行此脚本检查Docker配置:

python scripts/check_docker_socket.py

Linux/macOS/WSL2

无需更改。默认配置有效:

volumes:
  - /var/run/docker.sock:/var/run/docker.sock

Windows(本机容器)

更新Docker套接字路径:

{
  "mcpServers": {
    "mcpware": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "/path/to/mcpware/config.json:/app/config.json:ro",
        "-v",
        "//./pipe/docker_engine://./pipe/docker_engine",
        "--env-file",
        "/path/to/mcpware/.env",
        "mcpware"
      ]
    }
  }
}

注意不同的Docker套接字路径: //./pipe/docker_engine 而不是 /var/run/docker.sock

检查你的Docker类型

要验证您在Windows上使用的是哪个Docker后端:

docker version --format '{{.Server.Os}}'
  • linux =WSL2/H-V-后端(使用默认配置)
  • windows =Windows容器(使用覆盖文件)

配置

创建一个 config.json 使用后端服务器:

{
  "backends": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
      },
      "description": "GitHub MCP Server",
      "timeout": 60
    },
    "database": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "bytebase/dbhub", "--transport", "stdio"],
      "description": "Database MCP Server"
    }
  }
}

配置说明:

  • 后端命令可以是任何可执行文件(docker, npx, node, python等等)
  • 使用时 docker 命令,确保Docker套接字已挂载(请参阅安装说明)

config.example.json 更多后端示例(数据库、API等)。

用法

网关公开了两个主要工具:

使用工具

将工具调用路由到特定的后端服务器。

参数:

  • backend_server:后端服务器的名称
  • server_tool:要调用的工具的名称
  • tool_arguments:要传递给工具的参数

例子:

{
  "backend_server": "github",
  "server_tool": "create_issue",
  "tool_arguments": {
    "owner": "myorg",
    "repo": "myrepo",
    "title": "New issue",
    "body": "Issue description"
  }
}

discover_backend_tools

发现可用的后端及其工具。

参数:

  • backend_name:(可选)要查询的特定后端

与其他MCP服务器一起使用mcpware

mcpware旨在与MCP客户端配置中的其他MCP服务器协同工作。你可以:

  1. 使用mcpware作为网关 适用于多个后端服务器
  2. 将一些MCP服务器分开 用于直接访问
  3. 混搭 根据您的需求

混合配置示例:

{
  "mcpServers": {
    "mcpware": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/path/to/mcpware/config.json:/app/config.json:ro",
        "-v", "/var/run/docker.sock:/var/run/docker.sock",
        "--env-file", "/path/to/mcpware/.env",
        "mcpware"
      ]
    },
    "redis-direct": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-e", "REDIS_HOST=localhost", "mcp/redis"]
    }
  }
}

这使您能够:

  • 需要路由时,通过mcpware访问多个服务器
  • 当您需要专用访问时,直接连接到特定服务器
  • 根据您的工作流程组织MCP服务器

发展

先决条件

请确保您已安装Python 3.10+:

python --version  # Should show Python 3.10 or higher

开发设置

  1. 克隆存储库:
   git clone https://github.com/delexw/mcpware.git
   cd mcpware
  1. 创建虚拟环境(推荐):
   python -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. 安装开发依赖项:
   pip install -r requirements.txt

发展依赖性

该项目使用最小的依赖关系。所有核心功能都是使用Python标准库实现的。

测试依赖关系 (包含在requirements.txt中):

  • pytest -测试框架
  • pytest-asyncio -异步测试支持
  • pytest-cov -代码覆盖率报告

可选开发工具 (必要时单独安装):

# Code formatting
pip install black isort

# Linting
pip install flake8 pylint mypy

# Development convenience
pip install pytest-watch  # Auto-run tests on file changes

本地运行

# Run the gateway server
python gateway_server.py --config config.json

# Run with debug logging
python gateway_server.py --config config.json --log-level DEBUG

代码的风格

在提交之前格式化代码:

# Format with black (if installed)
black src/ tests/ gateway_server.py

# Sort imports (if installed)
isort src/ tests/ gateway_server.py

# Run linting (if installed)
flake8 src/ tests/ gateway_server.py --max-line-length=120

运行测试

# Run all tests
pytest

# Run with coverage report
pytest --cov=src --cov=gateway_server --cov-report=html

# Run specific test file
pytest tests/test_config.py

# Run tests in watch mode (requires pytest-watch)
pytest-watch

码头工人

使用Docker构建和运行:

# Build the image
docker build -t mcpware .

# Run interactively (for testing)
docker run -it --rm \
  -v $(pwd)/config.json:/app/config.json:ro \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e GITHUB_PERSONAL_ACCESS_TOKEN \
  mcpware

# Run with specific config file
docker run -it --rm \
  -v /path/to/your/config.json:/app/config.json:ro \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e GITHUB_PERSONAL_ACCESS_TOKEN \
  mcpware

环境变量

网关支持在后端配置中替换环境变量。将这些设置在您的 .env 文件:

# Example .env file
GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxxxxxxxxxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx
# Add other tokens as needed

引用的环境变量 config.json 使用 ${VAR_NAME} 语法将被自动替换。

测试

该项目包括综合单元和集成测试。

运行测试

  1. 安装测试依赖项:
   pip install -r requirements.txt
  1. 运行所有测试:
   pytest
  1. 运行覆盖率测试:
   pytest --cov=src --cov=gateway_server --cov-report=html
  1. 运行特定的测试模块:
   pytest tests/test_config.py
   pytest tests/test_backend.py
   pytest tests/test_protocol.py
  1. 在监视模式下运行测试:
   pytest-watch

许可证

麻省理工学院

目录标签

目录标签

进程管理Docker容器Python工具集成developer-toolsmcpwaregatewaydockerMCP路由本地部署

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononeremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP