I'd be happy to translate your README.md file to English for your GitHub project. Here's the professional translation:
Thanks to @BigUncle for the pull request
This guide systematically outlines the build, deployment, troubleshooting, and best practices for the mcpo project in Docker container environments, reflecting the project's current state.
This project uses Docker and Docker Compose for containerized deployment of mcpo (Model Context Protocol OpenAPI Proxy). Core design principles include:
- Dynamic Dependency Installation: At container startup, the
start.shscript readsconfig.jsonand dynamically installs required Python (uvx) and Node.js (npx) tools based on definedmcpServers. - Non-Root User Execution: The container ultimately runs as non-root user
appuserto enhance security. - Dependency and Data Persistence: Through Docker Compose volume mounts, configuration, logs, data, and cache directories for
uvandnpmare persisted to the host machine. - Flexible Source Configuration: Supports dynamic configuration of
pipsources via build argument (PIP_SOURCE), and uses Aliyun mirror by default to accelerateapt. - Environment Isolation: In
start.sh, each MCP tool installation occurs in a sub-shell to avoid environment variable conflicts.
-
Docker & Docker Compose: Docker 24+ and Docker Compose 2.x recommended.
-
.envFile: Create an.envfile in the project root directory for sensitive information and configuration. IncludeMCPO_API_KEY. Refer to.env.example.# .env file example # pip source used during Docker build (optional, uses default source if empty) PIP_SOURCE=https://mirrors.aliyun.com/pypi/simple/ # API Key required for mcpo runtime (required) MCPO_API_KEY=your_mcpo_api_key_here # Other API Keys that may be needed for mcp servers (according to config.json) # AMAP_MAPS_API_KEY=your_amap_key # ... other required environment variables
-
config.json: Configure MCP servers to start. Refer toconfig.example.json. -
Network: Ensure access to Debian (Aliyun mirror), NodeSource, PyPI (or specified
PIP_SOURCE).
Dockerfile: Defines image build process.- Base image:
python:3.13-slim - Installs:
bash,curl,jq,nodejs(v22.x),git,uv(via pip) - User: Creates and runs as
appuser. - Configuration: Supports
PIP_SOURCEbuild argument.
- Base image:
start.sh: Container entrypoint script.- Sets
HOME,UV_CACHE_DIR,NPM_CONFIG_CACHE. - Creates persistence directories.
- Reads
config.jsonand dynamically installs MCP tools (usinguvxornpx). - Starts
mcpomain service.
- Sets
docker-compose.yml: Defines services, build parameters, volume mounts, environment variables.- Passes
PIP_SOURCEto Dockerfile. - Mounts
./config.json,./logs,./data,./node_modules,./.npm,./.uv_cache. - Loads
.envas runtime environment variables viaenv_file.
- Passes
readme-docker.md: This document.test_mcp_tools.sh: Basic functionality test script.
# Pass PIP_SOURCE (compose will automatically read from .env if defined)
docker-compose build [--no-cache]--no-cache: Forces rebuild of all layers to ensure latest changes take effect.- Build process uses
PIP_SOURCEfrom.envfile (if valid) to configurepipsource.
# Start service (run in background)
docker-compose up -ddocker-compose.ymlloads variables from.envas container runtime environment variables.start.shexecutes, dynamically installing MCP tools defined inconfig.json.mcpomain service starts.
- Cause:
npx(installed withnodejs) orgitnot installed or their paths not inappuser'sPATHenvironment variable. - Solution:
- Confirm
Dockerfile'sapt-get installincludesnodejsandgit. - Confirm
ENV PATHdirective includes/usr/bin(whereapt-installednodejsandgittypically reside). Dockerfile already includes/app/.local/bin:/usr/bin:/usr/local/bin:$PATH. - Use
docker-compose build --no-cacheto rebuild.
- Confirm
- Cause: Container runs as non-root user
appuser, but scripts or dependencies attempt to write to/rootdirectory (e.g., default cache paths). - Solution:
- All cache directories (
uv,npm) redirected to/appviaENVdirectives (UV_CACHE_DIR,NPM_CONFIG_CACHE,HOME). mkdir -pinstart.shonly operates on directories under/app.- Corresponding volume mount paths in
docker-compose.ymlupdated to/app/....
- All cache directories (
- Cause:
PIP_SOURCEnot correctly passed to Dockerfile during build. - Solution:
- Ensure
.envfile containsPIP_SOURCE=https://.... - Ensure
docker-compose.yml'sbuild.argssection includes- PIP_SOURCE=${PIP_SOURCE:-}. - Dockerfile receives with
ARG PIP_SOURCEand uses viaexport PIP_INDEX_URLinRUNlayers.
- Ensure
- Cause: Poor network connection, slow or timeout accessing official sources.
- Solution:
- Dockerfile configured to use Aliyun mirror to accelerate
apt. pipcan be configured with domestic mirrors viaPIP_SOURCEin.env.- Node.js (NodeSource) and uv (PyPI/Mirror) still depend on network; consider alternative solutions in extreme cases.
- Dockerfile configured to use Aliyun mirror to accelerate
- Non-Root User: Always run containers as
appuser. - Persistence: Explicitly mount
config.json,logs,data,node_modules,.npm,.uv_cacheto preserve state and dependencies. - Secrets: Manage API Keys and sensitive information with
.envfile, inject viaenv_file, neverCOPY.envinto the image or hardcode keys..envfile should be in.gitignore. - Dynamic Installation:
start.sh's dynamic installation mechanism provides flexibility, but means longer startup time on first launch or afterconfig.jsonchanges. - Version Pinning: For reproducibility, recommend pinning
uvversion inDockerfile(pip install --user uv==X.Y.Z) andnpxpackage versions inconfig.json(@amap/amap-maps-mcp-server@X.Y.Z). - Resource Limits: In production environments, consider setting memory and CPU limits for services in
docker-compose.yml. - Logs: Logs output to mounted
./logsdirectory for easy viewing and management. - Testing: Use
test_mcp_tools.shscript for basic functionality verification.
- Build image:
docker-compose build [--no-cache] - Start service (background):
docker-compose up -d