From ed24e77ffb91c7e037471b8ab7b8b6b209cf6ea0 Mon Sep 17 00:00:00 2001 From: Jarad DeLorenzo Date: Thu, 16 Jul 2026 15:20:47 -0400 Subject: [PATCH] feat: Add Docker and MCP SSE support --- docker/Dockerfile | 13 ++++++++ docker/README.md | 40 +++++++++++++++++++++++ docker/docker-compose.yml | 20 ++++++++++++ docker/wire-clients.sh | 68 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100644 docker/docker-compose.yml create mode 100755 docker/wire-clients.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..6a7d6958 --- /dev/null +++ b/docker/Dockerfile @@ -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"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..a407d894 --- /dev/null +++ b/docker/README.md @@ -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 + ``` + *Note: This will index the current directory `.` by mounting it to `/repo` inside the container.* + +3. **Wire your agents**: + Use the included script to automatically inject the MCP server configuration into your agents' global settings. + ```bash + ./wire-clients.sh + ``` + +## 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) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 00000000..de9f5d41 --- /dev/null +++ b/docker/docker-compose.yml @@ -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 + - codegraph-cache:/repo/.codegraph + environment: + - PORT=8045 + hostname: codegraph-mcp + +volumes: + codegraph-cache: + driver: local diff --git a/docker/wire-clients.sh b/docker/wire-clients.sh new file mode 100755 index 00000000..c7da8b7f --- /dev/null +++ b/docker/wire-clients.sh @@ -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}" + +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" +} + +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."