mcpo码头
MCPO+对比安全集成指南
本指南将引导您使用模型上下文协议(MCP)在mcpo和对比安全之间设置完整的集成。如果您还没有完成环境设置,请查看 Mac开发-安装指南-初学者.md
概述
在本指南结束时,您将拥有:
- 与Contrast Security集成运行的MCP服务器(mcpo)
先决条件
- 已安装Docker和Docker Compose
- 基本熟悉命令行操作
- 对比安全帐户和API凭据
步骤3:设置具有对比安全性的MCP服务器
3.1创建项目目录
mkdir mcpo-contrast-integration
cd mcpo-contrast-integration3.2下载MCP对比JAR
从GitHub版本下载mcp对比的最新JAR文件:
# Download the JAR file directly from GitHub releases
curl -L -o mcp-contrast.jar https://github.com/Contrast-Security-OSS/mcp-contrast/releases/download/v0.0.14/mcp-contrast-0.0.14.jar替代方案:从源代码构建 如果您更喜欢从源代码构建:
# Clone the mcp-contrast repository
git clone https://github.com/Contrast-Security-OSS/mcp-contrast.git
# Navigate to the repository
cd mcp-contrast
# Build the JAR file using Docker
docker build -t mcp-contrast .
# Copy the JAR file to your project directory
cp target/mcp-contrast-*.jar ../mcp-contrast.jar
# Return to your project directory
cd ..3.3创建Dockerfile
FROM python:3.11-slim
LABEL org.opencontainers.image.title="mcpo"
LABEL org.opencontainers.image.description="Docker image for mcpo (Model Context Protocol OpenAPI Proxy)"
LABEL org.opencontainers.image.source="https://github.com/alephpiece/mcpo-docker"
LABEL org.opencontainers.image.licenses="MIT"
# install npx and OpenJDK JRE 21
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
nodejs \
npm \
openjdk-21-jre-headless \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="/usr/local/bin" sh
COPY ./mcp-contrast.jar /app/mcp-contrast.jar
COPY ./config.json /app/config.json
WORKDIR /app
EXPOSE 8000
ENTRYPOINT ["uvx", "mcpo"]
CMD ["--config", "/app/config.json"]3.4创建Docker编写文件
services:
mcpo:
build: .
container_name: mcpo
image: mcpo-docker
ports:
- "8000:8000"
volumes:
- ./config.json:/app/config.json
- ./mcp-contrast.jar:/app/mcp-contrast.jar3.5创建MCP配置
创建 config.json 使用您的对比度安全凭据:
{
"mcpServers": {
"sequential-thinking": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sequential-thinking"
]
},
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
]
},
"time": {
"command": "uvx",
"args": [
"mcp-server-time",
"--local-timezone=America/New_York"
]
},
"contrast-mcp": {
"command": "/usr/bin/java",
"args": ["-jar","/app/mcp-contrast.jar",
"--CONTRAST_HOST_NAME=https://your-contrast-server.com",
"--CONTRAST_API_KEY=your-api-key",
"--CONTRAST_SERVICE_KEY=your-service-key",
"--CONTRAST_USERNAME=your-username",
"--CONTRAST_ORG_ID=your-org-id"]
}
}
}⚠️ 重要:将占位符值替换为实际的对比度安全凭据:
your-contrast-server.com-您的对比度安全服务器URLyour-api-key-您的对比度API键your-service-key-您的对比度服务密钥your-username-您的对比度用户名your-org-id-您的对比组织ID
3.6添加对比度MCP JAR
如果你按照步骤3.2进行操作,你应该已经有了 mcp-contrast.jar 文件在您的目录中。如果没有,请复制您的 mcp-contrast.jar 文件到此目录。
3.7构建和运行MCP服务器
# Build the container
docker-compose build
# Start the MCP server
docker-compose up -d
# Verify it's running and connected
docker logs mcpo您应该看到显示与所有MCP服务器成功连接的日志,包括 contrast-mcp.
统一资源定位符: http://localhost:8000/contrast-mcp/openapi.json 或 http://mcpo:8000/contrast-mcp/openapi.json 无论你在哪里都可以访问你刚刚启动的容器。
