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
34 changes: 0 additions & 34 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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!"
19 changes: 5 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ── Stage 1: Build ──────────────────────────────────────────────
FROM node:20-alpine AS build
FROM node:20-slim AS build

WORKDIR /app

Expand All @@ -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

Expand All @@ -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"]
31 changes: 6 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 |
Expand All @@ -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

Expand All @@ -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=<your-token> dev-docs-mcp
```

## Development
Expand Down
29 changes: 3 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) => {
Expand Down
5 changes: 4 additions & 1 deletion src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down