Skip to content
Open
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
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-alpine

RUN apk add --no-cache git ripgrep jq bash

RUN npm install -g @colbymchenry/codegraph supergateway

WORKDIR /repo

ENV CODEGRAPH_STARTUP_HANDSHAKE_TIMEOUT_MS=0

EXPOSE 8045

ENTRYPOINT ["supergateway", "--port", "8045", "--stdio", "codegraph serve --mcp"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Start the repository’s actual MCP command

For every image built from this Dockerfile, the entrypoint delegates to codegraph serve --mcp, but the tracked CLI defines start as its MCP-server command and has no serve subcommand (repo-wide search of the Rust CLI finds only codegraph start stdio/http). Moreover, the image installs a separately published npm package rather than building this repository, so it cannot run the reviewed server revision; build the repository binary and invoke its supported stdio command, or pin and validate a package whose CLI actually provides this invocation.

Useful? React with 👍 / 👎.

40 changes: 40 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Colby's CodeGraph Dockerized

This repository provides a frictionless, containerized setup for [Colby McHenry's CodeGraph](https://github.com/colbymchenry/codegraph). It packages the Node-based `codegraph` CLI together with `supergateway` to expose the MCP server over an HTTP Server-Sent Events (SSE) endpoint.

This means your AI agents (Claude Code, Cursor, Codex, etc.) can connect to a live-syncing CodeGraph without you having to install Node.js, Rust, or any local binaries on your machine.

## Quick Start

1. **Clone this repository** (or copy `docker-compose.yml` to your project).
2. **Start the container**:
```bash
# Run this from the root of the project you want to index
docker-compose up -d
```
Comment on lines +10 to +14
*Note: This will index the current directory `.` by mounting it to `/repo` inside the container.*
Comment on lines +12 to +15

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make the quick-start Compose invocation address the target project

The documented command cannot deliver the promised mount: after cloning this repository, running docker-compose up -d from the project root finds no Compose file because it lives in docker/; copying only the Compose file instead makes build: . look for a Dockerfile in the target project. Even when run from docker/, Compose resolves the .:/repo bind source relative to that Compose file, so it mounts the docker directory rather than the repository the note says will be indexed. Provide a self-contained template or explicit file/build paths and a configurable target-directory bind mount.

Useful? React with 👍 / 👎.


3. **Wire your agents**:
Use the included script to automatically inject the MCP server configuration into your agents' global settings.
```bash
./wire-clients.sh
```
Comment on lines +17 to +21

## How It Works

- The `Dockerfile` installs `@colbymchenry/codegraph` and `supergateway`.
- The `ENTRYPOINT` starts `supergateway` on port `8045` and proxies traffic to `codegraph serve --mcp`.
- The `docker-compose.yml` mounts your code to `/repo` and persists the `.codegraph` index so it doesn't have to rebuild from scratch if you restart the container.

## Supported Auto-Wired Agents

The `wire-clients.sh` script automatically configures:
- Cursor
- VSCode native MCP
- Codex
- Gemini
- Kimi
- OpenCode
- Cline (VSCode extension)
- Roo Code (VSCode extension)
- Claude Code (Project-scoped)
20 changes: 20 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
codegraph-mcp:
build: .
image: colbymchenry-codegraph-mcp:latest
container_name: codegraph-mcp
restart: unless-stopped
ports:
- "8045:8045"
volumes:
# Mount the current repository (or any target repository) into the container
- .:/repo
# Persist the CodeGraph index so it doesn't rebuild on container restart
Comment on lines +10 to +12
- codegraph-cache:/repo/.codegraph
environment:
- PORT=8045
hostname: codegraph-mcp

volumes:
codegraph-cache:
driver: local
68 changes: 68 additions & 0 deletions docker/wire-clients.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
#
# wire-clients.sh
# A utility script to automatically configure popular AI coding agents
# to use the local CodeGraph MCP SSE server provided by this container.
#
# Usage: ./wire-clients.sh [SSE_URL] [PROJECT_DIR]
# Example: ./wire-clients.sh http://localhost:8045/sse /path/to/my/project

set -euo pipefail

SSE_URL="${1:-http://localhost:8045/sse}"
REPO_ROOT="${2:-$PWD}"
Comment on lines +12 to +13

inject_sse() {
local target="$1"
local agent="$2"

if [ ! -f "$target" ]; then
mkdir -p "$(dirname "$target")"
echo '{"mcpServers": {}}' > "$target"
fi

if ! jq . "$target" >/dev/null 2>&1; then
echo "WARNING: $target is not valid JSON, skipping $agent wiring" >&2
return
fi

jq --arg url "$SSE_URL" '.mcpServers.codegraph = {"type": "sse", "url": $url}' "$target" > "$target.tmp" && mv "$target.tmp" "$target"
echo "✅ Wired CodeGraph SSE for $agent -> $target"
Comment on lines +29 to +30
}

echo "Wiring Colby's CodeGraph MCP SSE URL: $SSE_URL"
echo ""

# 1. Claude Code (Project-scoped)
inject_sse "$REPO_ROOT/.claude.json" "Claude Code"

# 2. Codex (Global)
inject_sse "$HOME/.codex/mcp.json" "Codex"

# 3. Gemini (Global)
inject_sse "$HOME/.gemini/config/mcp.json" "Gemini"

# 4. Kimi (Global)
inject_sse "$HOME/.kimi-code/mcp.json" "Kimi"

# 5. OpenCode (Global)
inject_sse "$HOME/.opencode/mcp.json" "OpenCode"

# 6. Cursor (Global)
inject_sse "$HOME/.cursor/mcp.json" "Cursor"

# 7. VSCode native MCP (Global)
inject_sse "$HOME/.vscode/mcp.json" "VSCode"

# 8. Cline (VSCode extension)
CLINE_PATH="$HOME/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json"
[ "$(uname)" = "Darwin" ] && CLINE_PATH="$HOME/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json"
inject_sse "$CLINE_PATH" "Cline"

# 9. Roo (VSCode extension)
ROO_PATH="$HOME/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json"
[ "$(uname)" = "Darwin" ] && ROO_PATH="$HOME/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json"
inject_sse "$ROO_PATH" "Roo Code"

echo ""
echo "Done! Restart your agents to apply the new configuration."