UNPKG

qbo-mcp-ts

Version:

TypeScript QuickBooks Online MCP Server with enhanced features and dual transport support

132 lines • 4.7 kB
#!/usr/bin/env node "use strict"; /** * QBOMCP-TS - TypeScript QuickBooks Online MCP Server * Main entry point with dual transport support */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.main = main; const yargs_1 = __importDefault(require("yargs")); const helpers_1 = require("yargs/helpers"); const server_1 = require("./server"); const stdio_1 = require("./transports/stdio"); const sse_1 = require("./transports/sse"); const config_1 = require("./utils/config"); const logger_1 = require("./utils/logger"); /** * Parse command line arguments */ const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) .option('transport', { alias: 't', type: 'string', choices: ['stdio', 'sse'], default: 'stdio', description: 'Transport type to use', }) .option('port', { alias: 'p', type: 'number', default: 3000, description: 'Port for SSE transport', }) .option('host', { alias: 'h', type: 'string', default: '0.0.0.0', description: 'Host for SSE transport', }) .option('debug', { alias: 'd', type: 'boolean', default: false, description: 'Enable debug logging', }) .help() .alias('help', 'h') .parseSync(); /** * Main application entry point */ async function main() { try { // Log startup information logger_1.logger.info('Starting QBOMCP-TS Server', { version: '2.0.0', transport: argv.transport, environment: config_1.config.getEnv(), features: config_1.config.getFeatureFlags(), }); // Validate configuration try { const qboConfig = config_1.config.getQBOConfig(); logger_1.logger.info('QuickBooks configuration validated', { environment: qboConfig.environment, companyId: qboConfig.companyId, }); } catch (error) { logger_1.logger.error('Invalid QuickBooks configuration', error); console.error('\nāŒ QuickBooks configuration error:'); console.error('Please ensure the following environment variables are set:'); console.error(' - QBO_CLIENT_ID'); console.error(' - QBO_CLIENT_SECRET'); console.error(' - QBO_COMPANY_ID'); console.error(' - QBO_REFRESH_TOKEN'); console.error('\nSee .env.example for more details.\n'); process.exit(1); } // Create MCP server const mcpServer = new server_1.QBOMCPServer(); const server = mcpServer.getServer(); // Initialize transport based on selection if (argv.transport === 'sse') { // SSE Transport for production const transportConfig = { ...config_1.config.getTransportConfig(), type: 'sse', port: argv.port, host: argv.host, }; const transport = new sse_1.SSETransport(server, transportConfig); await transport.start(); console.log('\nāœ… QBOMCP-TS Server started with SSE transport'); console.log(`šŸ“” Listening on http://${argv.host}:${argv.port}`); console.log(`šŸ”— SSE endpoint: http://${argv.host}:${argv.port}/sse`); console.log(`šŸ’š Health check: http://${argv.host}:${argv.port}/health`); console.log('\nPress Ctrl+C to shutdown\n'); } else { // STDIO Transport for local development const transport = new stdio_1.StdioTransport(server); await transport.start(); // In STDIO mode, don't output to console as it interferes with the protocol logger_1.logger.info('QBOMCP-TS Server started with STDIO transport'); } // Handle uncaught errors process.on('uncaughtException', (error) => { logger_1.logger.error('Uncaught exception', error); process.exit(1); }); process.on('unhandledRejection', (reason, _promise) => { logger_1.logger.error('Unhandled rejection', reason); process.exit(1); }); } catch (error) { logger_1.logger.error('Failed to start server', error); console.error('\nāŒ Server startup failed:', error); process.exit(1); } } // Run the application if (require.main === module) { main().catch((error) => { console.error('Fatal error:', error); process.exit(1); }); } //# sourceMappingURL=index.js.map