feat(runner-template): MCP Streamable HTTP + OAuth 2.1 resource server template

This commit is contained in:
Marco Sadjadi 2026-05-19 00:27:22 +02:00
parent cc24dd4a63
commit efa2c3f30d
5 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,4 @@
node_modules
dist
.turbo
*.tsbuildinfo

View File

@ -0,0 +1,15 @@
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json ./
RUN npm install --omit=dev --no-audit --no-fund && npm install --no-save tsx@4.19.2 typescript@5.7.2
FROM node:20-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY package.json tsconfig.json ./
COPY src ./src
EXPOSE 3000
HEALTHCHECK --interval=15s --timeout=3s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["npx", "tsx", "src/server.ts"]

View File

@ -0,0 +1,19 @@
{
"name": "bmm-runner",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "tsx src/server.ts"
},
"dependencies": {
"@modelcontextprotocol/sdk": "1.0.4",
"fastify": "5.2.0",
"jose": "5.9.6",
"zod": "3.23.8"
},
"devDependencies": {
"tsx": "4.19.2",
"typescript": "5.7.2"
}
}

View File

@ -0,0 +1,18 @@
// Placeholder. The generator overwrites this file with rendered code.
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
import Fastify from 'fastify';
import { randomUUID } from 'node:crypto';
const PORT = Number.parseInt(process.env.PORT ?? '3000', 10);
const server = new McpServer({ name: 'placeholder', version: '0.0.0' });
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => randomUUID() });
const app = Fastify({ logger: { level: 'info' } });
app.get('/health', async () => ({ ok: true }));
app.all('/mcp', async (req, reply) => {
await transport.handleRequest(req.raw, reply.raw, req.body);
});
await server.connect(transport);
await app.listen({ port: PORT, host: '0.0.0.0' });

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"skipLibCheck": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"verbatimModuleSyntax": false
},
"include": ["src/**/*"]
}