如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
一个开源注册中心和代理,可联合MCP、A2A及REST/gRPC API,提供集中治理、发现和可观测性。优化智能体与工具调用,并支持插件。
ContextForge 是一个开源注册中心和代理,可将工具、智能体和API联合到一个简洁的端点,供您的AI客户端使用。它在整个AI基础设施中提供集中治理、发现和可观测性:
它作为完全兼容的MCP服务器运行,可通过PyPI或Docker部署,并能借助Redis支持的联合和缓存扩展到Kubernetes上的多集群环境。
| 资源 | 描述 |
|---|---|
| https://github.com/IBM/mcp-context-forge/issues/2503 | 快速开始 — uvx、Docker、Compose或本地开发 |
| https://github.com/IBM/mcp-context-forge/issues/2504 | 支持选项、常见问题、社区渠道 |
| https://github.com/IBM/mcp-context-forge/issues/2502 | 如何提交错误、请求功能、贡献代码 |
| https://ibm.github.io/mcp-context-forge/ | 完整指南、教程、API参考 |
| https://ibm.github.io/mcp-context-forge/deprecations/ | 已弃用的运行路径和迁移指南 |
ContextForge 是一个开源注册中心和代理,可联合任何[***] API,提供集中治理、发现和可观测性。它优化智能体和工具调用,并支持插件。更多详情请参见https://ibm.github.io/mcp-context-forge/architecture/roadmap/%E3%80%82
目前支持:
有关即将推出的功能列表,请查看https://ibm.github.io/mcp-context-forge/architecture/roadmap/
🔌 具有协议灵活性的网关层
2025-11-25)🧩 REST/gRPC服务的虚拟化
🔁 REST到MCP工具适配器
将REST API适配为工具,具备:
自动JSON Schema提取
支持标头、令牌和自定义身份验证
重试、超时和速率限制策略
🧠 统一注册中心
📈 管理UI、可观测性与开发体验
🔍 OpenTelemetry可观测性
有关Phoenix、Jaeger及其他后端的设置指南,请参见**https://ibm.github.io/mcp-context-forge/manage/observability/**%E3%80%82
ContextForge在https://pypi.org/project/mcp-contextforge-gateway/%E4%B8%8A%E5%8F%91%E5%B8%83%EF%BC%8C%E5%8C%85%E5%90%8D%E4%B8%BA%60mcp-contextforge-gateway%60%E3%80%82
概要;:(使用uv的单命令)
# 快速启动(带环境变量)
BASIC_AUTH_PASSWORD=pass \
MCPGATEWAY_UI_ENABLED=true \
MCPGATEWAY_ADMIN_API_ENABLED=true \
PLATFORM_ADMIN_EMAIL=admin@example.com \
PLATFORM_ADMIN_PASSWORD=changeme \
PLATFORM_ADMIN_FULL_NAME="Platform Administrator" \
uvx --from mcp-contextforge-gateway mcpgateway --host 0.0.0.0 --port 4444
# 更优方式:使用提供的.env.example
cp .env.example .env
# 编辑.env以自定义设置
uvx --from mcp-contextforge-gateway mcpgateway --host 0.0.0.0 --port 4444
📋 前提条件
# 1️⃣ 隔离环境 + 从pypi安装
mkdir mcpgateway && cd mcpgateway
python3 -m venv .venv && source .venv/bin/activate
pip install --upgrade pip
pip install mcp-contextforge-gateway
# 2️⃣ 复制并自定义配置
# 下载示例环境文件
curl -O https://raw.githubusercontent.com/IBM/mcp-context-forge/main/.env.example
cp .env.example .env
# 编辑.env以自定义设置(尤其是密码!)
# 1️⃣ 隔离环境 + 从PyPI安装
mkdir mcpgateway ; cd mcpgateway
python3 -m venv .venv ; .\.venv\Scripts\Activate.ps1
pip install --upgrade pip
pip install mcp-contextforge-gateway
# 2️⃣ 复制并自定义配置
# 下载示例环境文件
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/IBM/mcp-context-forge/main/.env.example" -OutFile ".env.example"
Copy-Item .env.example .env
# 编辑.env文件以自定义设置
# 或者设置环境变量(仅当前会话)
$Env:MCPGATEWAY_UI_ENABLED = "true"
$Env:MCPGATEWAY_ADMIN_API_ENABLED = "true"
#
> [!NOTE] API的基本认证默认禁用(API_ALLOW_BASIC_AUTH=false)
$Env:JWT_SECRET_KEY = "my-test-key-but-now-longer-than-32-bytes"
$Env:PLATFORM_ADMIN_EMAIL = "admin@example.com"
$Env:PLATFORM_ADMIN_PASSWORD = "changeme"
$Env:PLATFORM_ADMIN_FULL_NAME = "Platform Administrator"
# 3️⃣ 启动网关
mcpgateway.exe --host 0.0.0.0 --port 4444
# 可选:后台运行
# Start-Process -FilePath "mcpgateway.exe" -ArgumentList "--host 0.0.0.0 --port 4444"
# 4️⃣ 生成Bearer令牌并进行冒烟测试
$Env:MCPGATEWAY_BEARER_TOKEN = python3 -m mcpgateway.utils.create_jwt_token `
--username admin@example.com --exp 10080 --secret my-test-key-but-now-longer-than-32-bytes
curl -s -H "Authorization: Bearer $Env:MCPGATEWAY_BEARER_TOKEN" `
http://127.0.0.1:4444/version | jq
docker run -d --name mcpgateway \
-p 4444:4444 \
-e MCPGATEWAY_UI_ENABLED=true \
-e MCPGATEWAY_ADMIN_API_ENABLED=true \
-e HOST=0.0.0.0 \
-e JWT_SECRET_KEY=my-test-key-but-now-longer-than-32-bytes \
-e AUTH_REQUIRED=true \
-e PLATFORM_ADMIN_EMAIL=admin@example.com \
-e PLATFORM_ADMIN_PASSWORD=changeme \
-e PLATFORM_ADMIN_FULL_NAME="Platform Administrator" \
-e DATABASE_URL=sqlite:///./mcp.db \
-e SECURE_COOKIES=false \
ghcr.io/ibm/mcp-context-forge:1.0.0-RC-3
# 跟踪日志并生成API密钥
docker logs -f mcpgateway
docker run --rm -it ghcr.io/ibm/mcp-context-forge:1.0.0-RC-3 \
python3 -m mcpgateway.utils.create_jwt_token --username admin@example.com --exp 10080 --secret my-test-key-but-now-longer-than-32-bytes
浏览至 http://localhost:4444/admin 并使用 PLATFORM_ADMIN_EMAIL / PLATFORM_ADMIN_PASSWORD 登录。
高级用法:持久化存储、主机网络、离线部署
持久化SQLite数据库:
mkdir -p $(pwd)/data && touch $(pwd)/data/mcp.db && chmod 777 $(pwd)/data
docker run -d --name mcpgateway --restart unless-stopped \
-p 4444:4444 -v $(pwd)/data:/data \
-e DATABASE_URL=sqlite:////data/mcp.db \
-e MCPGATEWAY_UI_ENABLED=true -e MCPGATEWAY_ADMIN_API_ENABLED=true \
-e HOST=0.0.0.0 -e JWT_SECRET_KEY=my-test-key-but-now-longer-than-32-bytes \
-e PLATFORM_ADMIN_EMAIL=admin@example.com -e PLATFORM_ADMIN_PASSWORD=changeme \
ghcr.io/ibm/mcp-context-forge:1.0.0-RC-3
主机网络(访问本地MCP服务器):
docker run -d --name mcpgateway --network=host \
-v $(pwd)/data:/data -e DATABASE_URL=sqlite:////data/mcp.db \
-e MCPGATEWAY_UI_ENABLED=true -e HOST=0.0.0.0 -e PORT=4444 \
ghcr.io/ibm/mcp-context-forge:1.0.0-RC-3
离线部署(无互联网):
docker build -f Containerfile -t mcpgateway:airgapped .
docker run -d --name mcpgateway -p 4444:4444 \
-e MCPGATEWAY_UI_AIRGAPPED=true -e MCPGATEWAY_UI_ENABLED=true \
-e HOST=0.0.0.0 -e JWT_SECRET_KEY=my-test-key-but-now-longer-than-32-bytes \
mcpgateway:airgapped
有关升级说明、迁移指南和回滚流程,请参见:
服务器运行时提供交互式 API 文档:
快速认证:
# 生成 JWT 令牌
export TOKEN=$(python3 -m mcpgateway.utils.create_jwt_token \
--username admin@example.com --exp 10080 --secret my-test-key-but-now-longer-than-32-bytes)
# 测试 API 访问
curl -H "Authorization: Bearer $TOKEN" http://localhost:4444/health
有关涵盖所有端点的详细 curl 示例,请参阅 **https://ibm.github.io/mcp-context-forge/manage/api-usage/**%E3%80%82
make test # 运行单元测试
make lint # 运行所有代码检查工具
make doctest # 运行文档测试
make coverage # 生成覆盖率报告
有关文档测试的详细信息,请参阅 https://ibm.github.io/mcp-context-forge/development/doctest-coverage/%E3%80%82
有关详细的故障排除指南,请参阅 **https://ibm.github.io/mcp-context-forge/manage/troubleshooting/**%E3%80%82
make lint 并修复所有问题。make test 测试通过。git commit -s)。有关完整指南,请参阅 CONTRIBUTING.md;有关如何提交错误报告、请求功能以及查找可参与的问题,请参阅 **https://github.com/IBM/mcp-context-forge/issues/2502**%E3%80%82
完整的变更日志可在此处查看:CHANGELOG.md
根据 Apache License 2.0 许可 - 详见 LICENSE
特别感谢所有贡献者帮助我们改进 ContextForge:
来自真实用户的反馈,见证轩辕镜像的优质服务