fix: make mcp work?

This commit is contained in:
2025-08-07 11:54:18 -07:00
parent b8b17b72a3
commit 04f1efa6b8
4 changed files with 356 additions and 24 deletions
+26 -2
View File
@@ -5,12 +5,15 @@
*/
import cors from "@fastify/cors";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import fastify from "fastify";
// eslint-disable-next-line @typescript-eslint/naming-convention -- 'Tis a class.
import FastifyMcpServer from "fastify-mcp-server";
import { documentationData } from "./data/docs.js";
import { corsHook } from "./hooks/cors.js";
import { ipHook } from "./hooks/ips.js";
import { announcementRoutes } from "./routes/announcement.js";
import { baseRoutes } from "./routes/base.js";
import { mcpRoutes } from "./routes/mcp.js";
import { logger } from "./utils/logger.js";
const server = fastify({
@@ -33,7 +36,28 @@ server.addHook("preHandler", ipHook);
server.register(baseRoutes);
server.register(announcementRoutes);
server.register(mcpRoutes);
const mcp = new McpServer({
name: "nhcarrigan-mcp",
version: process.env.npm_package_version ?? "0.0.0",
});
// Define MCP tools
mcp.tool("docs", () => {
return {
content: documentationData.documents.map((document) => {
return {
text: JSON.stringify(document, null, 2),
type: "text",
};
}),
};
});
await server.register(FastifyMcpServer, {
endpoint: "/mcp",
server: mcp.server,
});
server.listen({ port: 20_000 }, (error) => {
if (error) {