Merge pull request 'chore: bootstrap Claude setup' (#1) from chore/bootstrap into master

Reviewed-on: #1
This commit is contained in:
dasemu committed 2026-10-18 18:57:44 +00:00
commit b46ad06b47
7 files changed
+144

No files matched your search

+1
View File
@@ -0,0 +1 @@
2
+25
View File
@@ -0,0 +1,25 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "FILE=$(jq -r '.tool_input.file_path // empty'); case \"$FILE\" in *.ts|*.tsx) WS=$(echo \"$FILE\" | grep -oE 'apps/(server|web)' | head -1); if [ -n \"$WS\" ]; then npx --prefix \"$CLAUDE_PROJECT_DIR\" -y tsc --noEmit -p \"$CLAUDE_PROJECT_DIR/$WS/tsconfig.json\" >&2 || true; fi ;; esac"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "cd \"$CLAUDE_PROJECT_DIR\" && npm run build --workspace apps/server && npm test"
}
]
}
]
}
}
+4
View File
@@ -2,7 +2,9 @@ name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
test:
@@ -12,6 +14,8 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build --workspace apps/server
- run: npm run build --workspace apps/web
- run: npm test
+41
View File
@@ -0,0 +1,41 @@
name: Version
# This repo has no `development` branch yet: every push to `master` is treated as a
# direct push and bumps PATCH. Once `development` exists, split this into a PATCH bump
# on push to `development` and a MINOR bump on a `development` -> `master` merge, per
# the global CLAUDE.md versioning rules.
on:
push:
branches: [master]
permissions:
contents: write
jobs:
bump:
if: github.actor != 'claude' && !contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump PATCH version
run: |
set -e
VERSION_FILE="VERSION"
if [ ! -f "$VERSION_FILE" ]; then
echo "0.1.0" > "$VERSION_FILE"
fi
IFS='.' read -r MAJOR MINOR PATCH < "$VERSION_FILE"
PATCH=$((PATCH + 1))
echo "${MAJOR}.${MINOR}.${PATCH}" > "$VERSION_FILE"
echo "NEW_VERSION=${MAJOR}.${MINOR}.${PATCH}" >> "$GITHUB_ENV"
- name: Commit and push
run: |
git config user.name "claude"
git config user.email "noreply@anthropic.com"
git add VERSION
git commit -m "chore(release): v${NEW_VERSION} [skip ci]"
git push origin HEAD:master
+39
View File
@@ -0,0 +1,39 @@
# CLAUDE.md
## Overview
Self-hosted manager for MCP servers: install one from a GitHub repo URL, build it with
Nixpacks, run it in a container, and expose it at an authenticated `/mcp/<slug>` URL.
npm workspaces monorepo: `apps/server` (Express + TypeScript API) and `apps/web` (React + Vite UI).
## Commands
- Install: `npm install`
- Dev (server): `npm run dev:server`
- Dev (web): `npm run dev --workspace apps/web`
- Test: `npm test` (runs `apps/server`'s vitest suite; `apps/web` has no tests yet)
- Build (server): `npm run build --workspace apps/server`
- Build (web): `npm run build --workspace apps/web`
- Lint: none configured — CI type-checks via each workspace's build (`tsc`)
## Architecture
Operator installs an MCP server from a repo URL; the server clones it, builds it with
Nixpacks, runs it as a sibling container on a shared Docker network (`mcp-net`), and proxies
authenticated requests to it. See `README.md` for the full flow and `docs/` for details.
## Conventions
- TypeScript, strict mode, ES modules (`type: "module"`) in both workspaces.
- Tests live next to the code as `*.test.ts`, run with vitest.
- Secrets (env vars, bearer tokens) are encrypted at rest with AES-256-GCM (`apps/server/src/crypto/secrets.ts`).
## Workflow quirks
- This repo is hosted on Gitea; CI workflows live in `.gitea/workflows/`, not `.github/workflows/`.
- Local dev requires Podman with a `docker`-compatible socket (see README) because the manager
itself must run as a container attached to `mcp-net` to reach sibling MCP containers.
## Deployment
- Production: `docker compose up -d --build` behind your own reverse proxy for TLS (see README).
- See `LESSONS.md` before touching the build/container pipeline — several non-obvious gotchas
(Nixpacks binary extraction, BuildKit/buildx, cgroup delegation) are recorded there.
## Gotchas
- Builds run one at a time; no per-installation resource override (see README "Known limitations").
- `.gitea/workflows/ci.yml` only runs if this repo's Gitea instance has Actions enabled with a runner.
+1
View File
@@ -0,0 +1 @@
0.1.0
+33
View File
@@ -0,0 +1,33 @@
# Architecture
## Components
- **`apps/server`** — Express + TypeScript API and proxy. Owns the SQLite DB
(`apps/server/src/db`), the Docker/Podman control plane (`apps/server/src/docker`), the
Nixpacks build pipeline (`apps/server/src/build`), secret encryption
(`apps/server/src/crypto`), and the authenticated reverse proxy to installed MCP
containers (`apps/server/src/proxy`).
- **`apps/web`** — React + Vite single-page admin panel (install wizard, installation list
and detail views, login).
## Installation lifecycle
1. Operator submits a repo URL (+ optional git ref) through the web UI.
2. `apps/server/src/service/orchestrator.ts` clones (or updates) the repo, detects env vars
from its `.env.example`, and creates a draft `Installation` row.
3. On build, the repo is (re-)cloned and built with Nixpacks
(`apps/server/src/build/nixpacks.ts`) into a Docker image.
4. The image is run as a sibling container attached to the shared `mcp-net` Docker network
(`apps/server/src/docker/containers.ts`), with the resource caps from `CONTAINER_MEMORY_MB`
/ `CONTAINER_CPUS`.
5. Requests to `/mcp/<slug>` are authenticated against the installation's bearer token
(`apps/server/src/proxy/mcpProxy.ts`, constant-time comparison) and proxied to the
container's IP on the shared network.
## Why the manager itself must run as a container
Rootless Podman isolates the host network namespace from the container bridge, so the
manager can only reach sibling MCP containers (by IP on `mcp-net`) when it is itself
attached to that network — running it directly on the host only works for routes that
don't need to reach a sibling container (e.g. `/health`, `/api/auth`). See the README's
"Local development (Podman)" section and `LESSONS.md` for the operational detail.