()
| 17 | * Creates and configures an MCP server for chart generation. |
| 18 | */ |
| 19 | export function createServer(): Server { |
| 20 | const server = new Server( |
| 21 | { |
| 22 | name: "mcp-server-chart", |
| 23 | version: "0.8.x", |
| 24 | }, |
| 25 | { |
| 26 | capabilities: { |
| 27 | tools: {}, |
| 28 | }, |
| 29 | }, |
| 30 | ); |
| 31 | |
| 32 | setupToolHandlers(server); |
| 33 | |
| 34 | server.onerror = (e: Error) => { |
| 35 | logger.error("Server encountered an error, shutting down", e); |
| 36 | }; |
| 37 | |
| 38 | process.on("SIGINT", async () => { |
| 39 | logger.info("SIGINT received, shutting down server..."); |
| 40 | await server.close(); |
| 41 | process.exit(0); |
| 42 | }); |
| 43 | |
| 44 | return server; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Gets enabled tools based on environment variables. |
no test coverage detected