UNPKG

@chargetrip/mcp

Version:

Chargetrip MCP server

46 lines (38 loc) 1.31 kB
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { getMcpServer } from './server/mcp-server'; import { AppLogger } from './utils'; /** * @description This file is for local testing of the Model Context Protocol (MCP) server using standard input/output. */ async function main(): Promise<void> { validate(); // Initialize the MCP server AppLogger.getInstance().info('Starting MCP server...'); const server = getMcpServer(); const transport = new StdioServerTransport(); await server.connect(transport); // Handle graceful shutdown process.on('SIGINT', async () => { AppLogger.getInstance().info('Shutting down gracefully...'); await server.close(); process.exit(0); }); process.on('SIGTERM', async () => { AppLogger.getInstance().info('Shutting down gracefully...'); await server.close(); process.exit(0); }); } main().catch((error: Error) => { AppLogger.getInstance().error('Failed to start MCP server:', error); process.exit(1); }); function validate() { // Ensure required environment variables are set if (!process.env.CLIENT_ID) { throw new Error('CLIENT_ID environment variable is not set'); } if (!process.env.APP_ID) { throw new Error('APP_ID environment variable is not set'); } }