본문으로 건너뛰기
cccskills
무료GitHub에 공개

containerize-mcp-server

Containerize an R-based MCP (Model Context Protocol) server using Docker. Covers mcptools integration, port exposure, stdio vs HTTP transport, and connecting Claude Code to the containerized server. Use when deploying an R MCP server without requiring a local R installation, creating a reproducible MCP server environment, running MCP servers alongside other containerized services, or distributing an MCP server to other developers.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Docker
설치 방법 보기

포함된 파일(1)

  • SKILL.md6.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Containerize MCP Server

Package an R MCP server into a Docker container for portable deployment.

When to Use

  • Deploying an R MCP server without requiring a local R installation
  • Creating a reproducible MCP server environment
  • Running MCP servers alongside other containerized services
  • Distributing an MCP server to other developers

Inputs

  • Required: R MCP server implementation (mcptools-based or custom)
  • Required: Docker installed and running
  • Optional: Additional R packages the server needs
  • Optional: Transport mode (stdio or HTTP)

Procedure

Step 1: Create Dockerfile for MCP Server

FROM rocker/r-ver:4.5.0

# Install system dependencies
RUN apt-get update && apt-get install -y \
    libcurl4-openssl-dev \
    libssl-dev \
    libxml2-dev \
    libgit2-dev \
    libssh2-1-dev \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install R packages
RUN R -e "install.packages(c( \
    'remotes', \
    'ellmer' \
    ), repos='https://cloud.r-project.org/')"

# Install mcptools
RUN R -e "remotes::install_github('posit-dev/mcptools')"

# Set working directory
WORKDIR /workspace

# Expose MCP server ports
EXPOSE 3000 3001 3002

# Environment variables
ENV R_LIBS_USER=/workspace/renv/library
ENV RENV_PATHS_CACHE=/workspace/renv/cache

# Default: start MCP server
CMD ["R", "-e", "mcptools::mcp_server()"]

Expected: A Dockerfile exists in the project root with rocker/r-ver base image, system dependencies, mcptools installation, and the MCP server as the default command.

On failure: Verify the base image tag matches your R version. If remotes::install_github fails, check that git and libgit2-dev are in the system dependencies layer.

Step 2: Create docker-compose.yml

version: '3.8'

services:
  mcp-server:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: r-mcp-server
    image: r-mcp-server:latest

    volumes:
      - /path/to/projects:/workspace
      - renv-cache:/workspace/renv/cache

    stdin_open: true
    tty: true

    network_mode: "host"

    environment:
      - TERM=xterm-256color
      - R_LIBS_USER=/workspace/renv/library

    restart: unless-stopped

volumes:
  renv-cache:
    driver: local

Using network_mode: "host" ensures the MCP server ports are accessible on localhost.

Expected: A docker-compose.yml file in the project root with the MCP server service, volume mounts for project files and renv cache, and stdin_open/tty enabled for stdio transport.

On failure: If volume paths are invalid, adjust /path/to/projects to the actual project directory. On Windows/WSL, use /mnt/c/... or /mnt/d/... paths.

Step 3: Build and Start

docker compose build
docker compose up -d

Expected: Container starts with MCP server running.

On failure: Check logs with docker compose logs mcp-server. Common issues:

  • Missing R packages: Add to Dockerfile RUN install step
  • Port already in use: Change exposed port or stop conflicting service

Step 4: Connect Claude Code to Container

For stdio transport (container must stay running with stdin):

claude mcp add r-mcp-docker stdio "docker" "exec" "-i" "r-mcp-server" "R" "-e" "mcptools::mcp_server()"

For HTTP transport (if the MCP server supports it):

{
  "mcpServers": {
    "r-mcp-docker": {
      "type": "http",
      "url": "http://localhost:3000/mcp"
    }
  }
}

Expected: Claude Code's MCP configuration includes the r-mcp-docker server entry, and claude mcp list shows the new server.

On failure: For stdio transport, ensure the container name matches (r-mcp-server) and that the container is running with docker ps. For HTTP transport, verify the port is exposed and reachable with curl http://localhost:3000/mcp.

Step 5: Verify Connection

# Check container is running
docker ps | grep mcp-server

# Test R session inside container
docker exec -it r-mcp-server R -e "sessionInfo()"

# Verify mcptools is available
docker exec -it r-mcp-server R -e "library(mcptools)"

Expected: docker ps shows the r-mcp-server container running, sessionInfo() returns the expected R version, and library(mcptools) loads without error.

On failure: If the container is not running, check docker compose logs mcp-server for startup errors. If mcptools fails to load, rebuild the image to ensure the package installed correctly.

Step 6: Add Custom MCP Tools

To add project-specific MCP tools, mount your R scripts:

volumes:
  - ./mcp-tools:/mcp-tools

And load them in the CMD:

CMD ["R", "-e", "source('/mcp-tools/custom_tools.R'); mcptools::mcp_server()"]

Expected: Custom R scripts are accessible inside the container at /mcp-tools/, and the MCP server loads them on startup alongside the default tools.

On failure: Verify the volume mount path is correct with docker exec -it r-mcp-server ls /mcp-tools/. If scripts fail to source, check for missing package dependencies in the custom tools.

Validation

  • Container builds without errors
  • MCP server starts inside the container
  • Claude Code can connect to the containerized server
  • MCP tools respond correctly to requests
  • Container restarts cleanly
  • Volume mounts allow access to project files

Common Pitfalls

  • stdin/tty requirements: MCP stdio transport requires stdin_open: true and tty: true
  • Network isolation: Default Docker networking may prevent localhost access. Use network_mode: "host" or expose specific ports.
  • Package versions: Pin mcptools to a specific commit for reproducibility
  • Large image size: mcptools + dependencies can be large. Consider multi-stage builds for production.
  • Windows Docker paths: When running Docker Desktop on Windows with WSL, path mapping differs

Related Skills

  • create-r-dockerfile - base Dockerfile patterns for R
  • setup-docker-compose - compose configuration details
  • configure-mcp-server - MCP server configuration without Docker
  • troubleshoot-mcp-connection - debugging MCP connectivity issues

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation. Covers transformation planning, parallel running, progressive cutover, rollback design, and post-metamorphosis stabilization for system architecture evolution. Use when assess-form has classified the system as READY for transformation, when migrating from monolith to microservices, when replacing a core subsystem while dependents continue operating, or when any architectural change must be gradual rather than big-bang.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

pjt222/agent-almanac422026년 10월 15일 업데이트

adaptic

무료

Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains. Orchestrates meditate, expand-awareness, observe, awareness, integrate-gestalt, and express-insight into a coherent process that produces unified understanding rather than sequential compromise. Use when a problem genuinely spans 3+ domains and the interactions between domains matter more than depth in any one, when sequential analysis feels like compromise rather than integration, or before major architectural decisions affecting multiple stakeholders.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

pjt222/agent-almanac422026년 10월 15일 업데이트

Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR. Creates the core puzzle module, wires it into the unified pipeline (generation, positioning, rendering, adjacency), adds ggpuzzle geom/stat layers, updates DESCRIPTION and config.yml, extends the Shiny app, and creates a comprehensive test suite. Use when adding a completely new puzzle type to the package or following the 10-point integration checklist to ensure nothing is missed end-to-end.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

pjt222/agent-almanac422026년 10월 15일 업데이트

Add Rcpp or RcppArmadillo integration to an R package for high-performance C++ code. Covers setup, writing C++ functions, RcppExports generation, testing compiled code, and debugging. Use when an R function is too slow and profiling confirms a bottleneck, when you need to interface with existing C/C++ libraries, or when implementing algorithms (loops, recursion, linear algebra) that benefit from compiled code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

pjt222/agent-almanac422026년 10월 15일 업데이트

aikido

무료

Practice aikido as a defensive martial art emphasizing harmony, redirection, and controlled resolution. Covers centering and grounding, ukemi (safe falling and rolling), core techniques (irimi-nage, shiho-nage, kote-gaeshi, ikkyo), blending and tai sabaki (body movement), randori (multiple attacker practice), weapons awareness, and applying principles off the mat. Use when learning a defensive martial art that prioritizes de-escalation, developing the ability to redirect aggression without causing unnecessary harm, building safe falling skills, or cultivating calm centeredness under physical pressure.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

pjt222/agent-almanac422026년 10월 15일 업데이트

Analyze an arbitrary codebase to identify functions, APIs, and data sources suitable for exposure as MCP tools, producing a tool specification document. Use when planning an MCP server for an existing project, auditing a codebase before wrapping it as an AI-accessible tool surface, comparing what a codebase can do versus what is already exposed via MCP, or generating a tool spec to hand off to scaffold-mcp-server.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

pjt222/agent-almanac422026년 10월 15일 업데이트

pjt222의 스킬 모두 보기

이 스킬의 문제 신고