diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 141e117..a83a897 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,8 +10,6 @@ env: ECR_REPOSITORY: dev-docs-mcp AWS_REGION: eu-west-1 ROLE_ARN: arn:aws:iam::455710622635:role/dev-docs-mcp-github-actions-role - ECS_CLUSTER: TlxDevServicesECSClusterDevelopment - ECS_SERVICE: tlxDevDocsMcpService jobs: build: @@ -80,35 +78,3 @@ jobs: tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max - - deploy: - name: Deploy to ECS - needs: push - if: github.ref == 'refs/heads/master' && github.event_name == 'push' - permissions: - id-token: write - contents: read - runs-on: ubuntu-latest - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: ${{ env.AWS_REGION }} - role-to-assume: ${{ env.ROLE_ARN }} - - - name: Force new deployment - run: | - aws ecs update-service \ - --cluster ${{ env.ECS_CLUSTER }} \ - --service ${{ env.ECS_SERVICE }} \ - --force-new-deployment \ - --region ${{ env.AWS_REGION }} - - - name: Wait for service stability - run: | - echo "Waiting for service to become stable..." - aws ecs wait services-stable \ - --cluster ${{ env.ECS_CLUSTER }} \ - --services ${{ env.ECS_SERVICE }} \ - --region ${{ env.AWS_REGION }} - echo "Deployment completed successfully!" diff --git a/Dockerfile b/Dockerfile index 2799958..baa6f25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # ── Stage 1: Build ────────────────────────────────────────────── -FROM node:20-alpine AS build +FROM node:20-slim AS build WORKDIR /app @@ -17,9 +17,9 @@ RUN npm run build RUN npx tsx scripts/warmup-model.ts # ── Stage 2: Runtime ──────────────────────────────────────────── -FROM node:20-alpine +FROM node:20-slim -RUN addgroup -S appgroup && adduser -S appuser -G appgroup +RUN groupadd -r appgroup && useradd -r -g appgroup appuser WORKDIR /app @@ -28,18 +28,9 @@ COPY --from=build /app/dist/ dist/ COPY --from=build /app/node_modules/ node_modules/ COPY --from=build /app/package.json ./ -# Copy cached model from build stage -COPY --from=build /root/.cache/ /home/appuser/.cache/ - -RUN chown -R appuser:appgroup /app /home/appuser/.cache +# Model cache lives inside node_modules/@xenova/transformers/.cache/ +RUN chown -R appuser:appgroup /app USER appuser -ENV MCP_TRANSPORT=http -ENV PORT=3000 -EXPOSE 3000 - -HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ - CMD wget -qO- http://localhost:3000/health || exit 1 - ENTRYPOINT ["node", "dist/index.js"] diff --git a/README.md b/README.md index 97ec3db..e273618 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Clones the documentation repo, chunks markdown files by headings, generates loca - Semantic search across all development documentation - Local embeddings (no external API calls) - Embedding cache keyed by git commit hash -- Supports both stdio and HTTP/SSE transports +- Stdio transport for MCP integration ## Quick start @@ -38,18 +38,6 @@ Or add to your `.mcp.json`: } ``` -### Local HTTP mode - -```bash -MCP_TRANSPORT=http PORT=3000 npx tsx src/index.ts -``` - -Verify with: - -```bash -curl http://localhost:3000/health -``` - ## Available tools | Tool | Description | @@ -59,10 +47,9 @@ curl http://localhost:3000/health ## Environment variables -| Variable | Default | Description | -|----------|---------|-------------| -| `MCP_TRANSPORT` | `stdio` | Transport mode: `http` or `stdio` | -| `PORT` | `3000` | HTTP server port (only used when `MCP_TRANSPORT=http`) | +| Variable | Description | +|----------|-------------| +| `GITHUB_TOKEN` | GitHub token for cloning the private Development-Documentation repo | ## Docker @@ -72,16 +59,10 @@ curl http://localhost:3000/health docker build -t dev-docs-mcp . ``` -### Run (HTTP mode) - -```bash -docker run -p 3000:3000 dev-docs-mcp -``` - -### Run (stdio mode) +### Run ```bash -docker run -i -e MCP_TRANSPORT=stdio dev-docs-mcp +docker run -i -e GITHUB_TOKEN= dev-docs-mcp ``` ## Development diff --git a/src/index.ts b/src/index.ts index 9d83c4b..133bd70 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,6 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; -import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; -import { createServer } from "http"; import { z } from "zod"; import { loadDocs, getLastCommitHash } from "./loader.js"; import { chunkAllDocs } from "./chunker.js"; @@ -159,30 +157,9 @@ server.tool( ); async function main() { - if (process.env.MCP_TRANSPORT === "http") { - const port = parseInt(process.env.PORT || "3000", 10); - const transport = new StreamableHTTPServerTransport({ - sessionIdGenerator: undefined, - }); - - const httpServer = createServer((req, res) => { - if (req.url === "/health") { - res.writeHead(200, { "Content-Type": "text/plain" }); - res.end("ok"); - return; - } - transport.handleRequest(req, res); - }); - - await server.connect(transport); - httpServer.listen(port, () => { - console.error(`[server] MCP server started on HTTP port ${port}`); - }); - } else { - const transport = new StdioServerTransport(); - await server.connect(transport); - console.error("[server] MCP server started on stdio"); - } + const transport = new StdioServerTransport(); + await server.connect(transport); + console.error("[server] MCP server started on stdio"); } main().catch((err) => { diff --git a/src/loader.ts b/src/loader.ts index 342e458..1256ae4 100644 --- a/src/loader.ts +++ b/src/loader.ts @@ -3,7 +3,10 @@ import { existsSync, readdirSync, readFileSync, statSync } from "fs"; import { join } from "path"; import { homedir } from "os"; -const REPO_URL = "https://github.com/Tripletex-AS/Development-Documentation.git"; +const BASE_REPO_URL = "https://github.com/Tripletex-AS/Development-Documentation.git"; +const REPO_URL = process.env.GITHUB_TOKEN + ? `https://x-access-token:${process.env.GITHUB_TOKEN}@github.com/Tripletex-AS/Development-Documentation.git` + : BASE_REPO_URL; const CACHE_DIR = join(homedir(), ".cache", "dev-docs-mcp"); const REPO_DIR = join(CACHE_DIR, "repo");