Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ test/serena-mcp-tests/results-gateway/
test/serena-mcp-tests/**/__pycache__/
test/serena-mcp-tests/**/*.pyc
scripts/rebase-github-difc.sh

# Serena cache directories
.serena/
69 changes: 23 additions & 46 deletions containers/serena-mcp-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Serena MCP Server Container Image
# Provides AI-powered code intelligence with support for Python, Java, JavaScript/TypeScript, and Go
# Serena MCP Server Container Image (Slim)
# Optimized for Python, Go, and TypeScript support with minimal image size

# Stage 1: Build gopls
FROM golang:1.24-alpine AS gopls-builder
# Pin to gopls v0.17.1 which is compatible with Go 1.24
RUN go install golang.org/x/tools/gopls@v0.17.1

# Stage 2: Final image
FROM python:3.11-slim

# OCI labels for GitHub Container Registry
LABEL org.opencontainers.image.title="Serena MCP Server"
LABEL org.opencontainers.image.description="A containerized MCP server with semantic code analysis for Python, Java, JavaScript/TypeScript, and Go"
LABEL org.opencontainers.image.description="A containerized MCP server with semantic code analysis for Python, Go, and TypeScript"
LABEL org.opencontainers.image.source="https://github.com/githubnext/gh-aw-mcpg/tree/main/containers/serena-mcp-server"
LABEL org.opencontainers.image.documentation="https://github.com/githubnext/gh-aw-mcpg/blob/main/containers/serena-mcp-server/README.md"
LABEL org.opencontainers.image.url="https://github.com/githubnext/gh-aw-mcpg/pkgs/container/serena-mcp-server"
Expand All @@ -14,53 +20,29 @@ LABEL org.opencontainers.image.vendor="GitHub"
# Set working directory
WORKDIR /app

# Install system dependencies required for language servers and build tools
# Install minimal system dependencies
# - git: required for some Serena operations
# - nodejs/npm: for TypeScript language server
# - ca-certificates: for HTTPS
RUN apt-get update && apt-get install -y --no-install-recommends \
# Build essentials
build-essential \
git \
curl \
wget \
# Java Development Kit (for Java language support and compilation)
default-jdk \
# Node.js (for JavaScript/TypeScript language support)
nodejs \
npm \
# Go runtime (for Go language support)
golang-go \
# Additional utilities
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& update-ca-certificates
&& apt-get clean

# Set environment variables for language runtimes
ENV JAVA_HOME=/usr/lib/jvm/default-java
ENV PATH="${JAVA_HOME}/bin:${PATH}"
ENV GOPATH=/go
ENV PATH="${GOPATH}/bin:${PATH}"
# Copy pre-built gopls from builder stage
COPY --from=gopls-builder /go/bin/gopls /usr/local/bin/gopls

# Install Serena MCP server from GitHub using pip
# Serena is a Python package, so we can install it directly
# Try GitHub first, then fall back to PyPI package name if available
# Install Serena MCP server from GitHub
RUN pip install --no-cache-dir git+https://github.com/oraios/serena.git || \
(echo "GitHub installation failed, trying PyPI..." && \
pip install --no-cache-dir serena-agent)

# Install common language servers that Serena may need
# These are installed globally to be available to Serena
RUN npm install -g \
typescript \
typescript-language-server \
&& rm -rf /root/.npm

# Install Python language server (pyright is included in Serena dependencies)
# Additional Python tools
RUN pip install --no-cache-dir \
python-lsp-server \
pylsp-mypy

# Install gopls (Go language server)
RUN go install golang.org/x/tools/gopls@latest
# Install TypeScript language server (minimal)
RUN npm install -g typescript typescript-language-server && \
rm -rf /root/.npm /tmp/*

# Create directories for Serena configuration and caching
RUN mkdir -p /workspace /tmp/serena-cache /root/.serena
Expand All @@ -70,30 +52,25 @@ ENV SERENA_WORKSPACE=/workspace
ENV SERENA_CACHE_DIR=/tmp/serena-cache

# Create a dummy project to pre-warm Serena's LSP cache
# This initializes the language servers and caches so they're ready at runtime
# Focus on Python, Go, and TypeScript which are the primary languages for codex context
# Focus on Python, Go, and TypeScript for codex context
RUN mkdir -p /tmp/dummy-project && \
echo 'def hello(): pass' > /tmp/dummy-project/main.py && \
echo 'package main\nfunc main() {}' > /tmp/dummy-project/main.go && \
echo 'export function hello() {}' > /tmp/dummy-project/index.ts

# Pre-index the dummy project to warm up the LSP caches
# Use --language to specify languages non-interactively and --index to index after creation
# This ensures pyright, gopls, and typescript-language-server are initialized
# Pre-index to warm up LSP caches
RUN serena project create /tmp/dummy-project --name dummy \
--language python --language go --language typescript \
--index --log-level INFO --timeout 120 || \
echo "Pre-indexing completed (some warnings may be expected)"

# Clean up the dummy project but keep the caches
# Clean up
RUN rm -rf /tmp/dummy-project

# Expose the workspace directory as a volume mount point
VOLUME ["/workspace"]

# Set default entrypoint to run Serena MCP server
# This will start the MCP server on stdio transport
ENTRYPOINT ["serena-mcp-server"]

# Default arguments (can be overridden)
CMD []
2 changes: 1 addition & 1 deletion containers/serena-mcp-server/test-startup-time.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
export WORKSPACE="${WORKSPACE_ARG:-${PWD}}"

GATEWAY_IMAGE="ghcr.io/githubnext/gh-aw-mcpg:v0.0.84"
SERENA_IMAGE="serena-mcp-server:test"
SERENA_IMAGE="${SERENA_IMAGE:-serena-mcp-server:slim}"

echo "=== Serena Startup Time Test ==="
echo "Gateway image: ${GATEWAY_IMAGE}"
Expand Down