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
12 changes: 12 additions & 0 deletions containers/serena-mcp-server/BUILD_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ The Serena MCP server container Dockerfile has been created with support for:

## Recent Fixes

### Multi-Language Configuration Script (2026-02-07)
Added automatic project configuration for TypeScript and Python language servers:
- **Problem**: The `.serena/project.yml` configuration only included Go, causing TypeScript and Python language server analysis to fail
- **Solution**: Created initialization script (`serena-init.sh`) that automatically generates/updates `.serena/project.yml` with all three languages (Go, TypeScript, Python) on container startup
- **Impact**: TypeScript and Python code analysis now works out-of-the-box without manual project configuration
- **Implementation**:
- Script checks if `project.yml` exists and contains all three required languages (Go, TypeScript, Python)
- Automatically creates/updates configuration only when any language is missing
- Uses anchored grep patterns for precise language detection
- Runs via ENTRYPOINT before starting the Serena MCP server
- **Testing**: Container successfully creates `.serena/project.yml` when mounting any workspace to `/workspace`
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note says the container “successfully creates .serena/project.yml when mounting any workspace to /workspace”, but the documented configuration mounts /workspace read-only (:ro), in which case the init script cannot write the file. Update the notes to clarify the workspace (or at least /workspace/.serena) must be writable, or that the script skips initialization on read-only mounts.

Suggested change
- **Testing**: Container successfully creates `.serena/project.yml` when mounting any workspace to `/workspace`
- **Testing**: Container successfully creates `.serena/project.yml` when mounting a **writable** workspace to `/workspace`; when `/workspace` is mounted read-only (e.g., with `:ro`), the init script cannot write `.serena/project.yml` and initialization is skipped

Copilot uses AI. Check for mistakes.

### Go Runtime Re-added (2026-02-05)
Re-added Go runtime to the container to support Go code analysis:
- **Problem**: The Dockerfile only installed `gopls` (Go LSP) but not the Go runtime itself
Expand Down
26 changes: 24 additions & 2 deletions containers/serena-mcp-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@ RUN mkdir -p /workspace /tmp/serena-cache /root/.serena
ENV SERENA_WORKSPACE=/workspace
ENV SERENA_CACHE_DIR=/tmp/serena-cache

# Create a startup script that ensures multi-language support
# This script will initialize the workspace with Go, TypeScript, and Python if not already configured
RUN printf '#!/bin/bash\n\
set -e\n\
\n\
# Ensure .serena directory exists in workspace\n\
mkdir -p /workspace/.serena\n\
\n\
Comment on lines +61 to +63
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entrypoint script creates /workspace/.serena and may write /workspace/.serena/project.yml. In the documented usage for this image, /workspace is commonly mounted read-only (:ro), which will cause the container to exit due to set -e when it cannot create/write these paths. Consider detecting a non-writable workspace (and warning + skipping init), or adjusting the image/docs to mount a writable volume specifically at /workspace/.serena (or make /workspace writable).

Copilot uses AI. Check for mistakes.
# Check if project.yml needs to be created or updated\n\
# Create/update if: file does not exist, OR it is missing any of the three required languages\n\
if [ ! -f /workspace/.serena/project.yml ] || \\\n\
! grep -q "^- go$" /workspace/.serena/project.yml || \\\n\
! grep -q "^- typescript$" /workspace/.serena/project.yml || \\\n\
! grep -q "^- python$" /workspace/.serena/project.yml; then\n\
echo "Initializing Serena project with Go, TypeScript, and Python support..."\n\
printf "languages:\\n- go\\n- typescript\\n- python\\n" > /workspace/.serena/project.yml\n\
Comment on lines +64 to +71
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When any required language is missing, the script overwrites project.yml entirely. This discards any existing configuration the user may have in that file. Consider updating only the languages: list (preserving other keys) or appending missing languages without clobbering the whole file.

Suggested change
# Check if project.yml needs to be created or updated\n\
# Create/update if: file does not exist, OR it is missing any of the three required languages\n\
if [ ! -f /workspace/.serena/project.yml ] || \\\n\
! grep -q "^- go$" /workspace/.serena/project.yml || \\\n\
! grep -q "^- typescript$" /workspace/.serena/project.yml || \\\n\
! grep -q "^- python$" /workspace/.serena/project.yml; then\n\
echo "Initializing Serena project with Go, TypeScript, and Python support..."\n\
printf "languages:\\n- go\\n- typescript\\n- python\\n" > /workspace/.serena/project.yml\n\
PROJECT_FILE="/workspace/.serena/project.yml"\n\
\n\
# If project.yml does not exist, create it with the required languages\n\
if [ ! -f "$PROJECT_FILE" ]; then\n\
echo "Creating new Serena project with Go, TypeScript, and Python support..."\n\
printf "languages:\\n- go\\n- typescript\\n- python\\n" > "$PROJECT_FILE"\n\
else\n\
echo "Ensuring Serena project has Go, TypeScript, and Python language support..."\n\
NEED_UPDATE=false\n\
\n\
grep -q "^- go$" "$PROJECT_FILE" || NEED_UPDATE=true\n\
grep -q "^- typescript$" "$PROJECT_FILE" || NEED_UPDATE=true\n\
grep -q "^- python$" "$PROJECT_FILE" || NEED_UPDATE=true\n\
\n\
if [ "$NEED_UPDATE" = true ]; then\n\
echo "Appending missing language entries to existing Serena project.yml..."\n\
{\n\
echo ""\n\
echo "# The following languages were added automatically by Serena init:"\n\
echo "languages:"\n\
grep -q "^- go$" "$PROJECT_FILE" || echo "- go"\n\
grep -q "^- typescript$" "$PROJECT_FILE" || echo "- typescript"\n\
grep -q "^- python$" "$PROJECT_FILE" || echo "- python"\n\
} >> "$PROJECT_FILE"\n\
fi\n\

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +71
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init script hardcodes /workspace paths instead of using SERENA_WORKSPACE (which is set just above and can be overridden by users). Using the env var (with a default) would keep behavior consistent if the workspace location changes.

Suggested change
# Ensure .serena directory exists in workspace\n\
mkdir -p /workspace/.serena\n\
\n\
# Check if project.yml needs to be created or updated\n\
# Create/update if: file does not exist, OR it is missing any of the three required languages\n\
if [ ! -f /workspace/.serena/project.yml ] || \\\n\
! grep -q "^- go$" /workspace/.serena/project.yml || \\\n\
! grep -q "^- typescript$" /workspace/.serena/project.yml || \\\n\
! grep -q "^- python$" /workspace/.serena/project.yml; then\n\
echo "Initializing Serena project with Go, TypeScript, and Python support..."\n\
printf "languages:\\n- go\\n- typescript\\n- python\\n" > /workspace/.serena/project.yml\n\
# Determine workspace directory (allow override via SERENA_WORKSPACE)\n\
WORKSPACE="${SERENA_WORKSPACE:-/workspace}"\n\
\n\
# Ensure .serena directory exists in workspace\n\
mkdir -p "$WORKSPACE/.serena"\n\
\n\
# Check if project.yml needs to be created or updated\n\
# Create/update if: file does not exist, OR it is missing any of the three required languages\n\
if [ ! -f "$WORKSPACE/.serena/project.yml" ] || \\\n\
! grep -q "^- go$" "$WORKSPACE/.serena/project.yml" || \\\n\
! grep -q "^- typescript$" "$WORKSPACE/.serena/project.yml" || \\\n\
! grep -q "^- python$" "$WORKSPACE/.serena/project.yml"; then\n\
echo "Initializing Serena project with Go, TypeScript, and Python support..."\n\
printf "languages:\\n- go\\n- typescript\\n- python\\n" > "$WORKSPACE/.serena/project.yml"\n\

Copilot uses AI. Check for mistakes.
fi\n\
\n\
# Start the Serena MCP server\n\
exec serena-mcp-server "$@"\n\
' > /usr/local/bin/serena-init.sh && chmod +x /usr/local/bin/serena-init.sh

# Create a dummy project to pre-warm Serena's LSP cache
# Focus on Python, Go, and TypeScript for codex context
RUN mkdir -p /tmp/dummy-project && \
Expand All @@ -72,7 +94,7 @@ 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
ENTRYPOINT ["serena-mcp-server"]
# Set default entrypoint to run initialization script
ENTRYPOINT ["/usr/local/bin/serena-init.sh"]

CMD []