19 lines
839 B
TypeScript
19 lines
839 B
TypeScript
|
|
// 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' });
|