UNPKG

@atlas-kitchen/atlas-mcp

Version:

Model Context Protocol server for Atlas restaurant management system - enables Claude to interact with restaurant orders, menus, and reports

99 lines 3.4 kB
#!/usr/bin/env node // Check Node.js version before proceeding const nodeVersion = process.versions.node; const major = parseInt(nodeVersion.split('.')[0], 10); if (major < 18) { console.error(`Error: Node.js version ${nodeVersion} is not supported.`); console.error('This package requires Node.js 18.0.0 or higher.'); console.error('Please upgrade your Node.js version.'); process.exit(1); } // Load environment variables before any other imports import dotenv from 'dotenv'; dotenv.config(); // Verify that fetch and Headers are available if (typeof fetch === 'undefined' || typeof Headers === 'undefined') { console.error('Error: fetch or Headers API is not available.'); console.error('Please ensure you are using Node.js 18.0.0 or higher with --experimental-fetch flag if needed.'); console.error(`Current Node.js version: ${nodeVersion}`); process.exit(1); } import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js'; import { AuthManager } from './auth.js'; import { AtlasClient } from './client.js'; import { createAuthTools } from './tools/auth.js'; import { createOrderTools } from './tools/orders.js'; import { createMenuTools } from './tools/menu.js'; import { createReportingTools } from './tools/reports.js'; const server = new Server({ name: 'atlas-mcp', version: '1.0.0', }, { capabilities: { tools: {}, }, }); // Initialize auth manager and client const authManager = new AuthManager(); const atlasClient = new AtlasClient(authManager); // Register all tools const allTools = [ ...createAuthTools(atlasClient, authManager), ...createOrderTools(atlasClient, authManager), ...createMenuTools(atlasClient, authManager), ...createReportingTools(atlasClient, authManager), ]; // Handle tool calls server.setRequestHandler(CallToolRequestSchema, async (request) => { const tool = allTools.find(t => t.name === request.params.name); if (!tool) { throw new Error(`Tool ${request.params.name} not found`); } try { return { content: [ { type: 'text', text: JSON.stringify(await tool.handler(request.params.arguments)), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: error.message || 'An unexpected error occurred', }), }, ], }; } }); // Handle tool list requests server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools.map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema, })), }; }); // Start the server async function main() { const transport = new StdioServerTransport(); await server.connect(transport); // Keep the process alive process.stdin.resume(); } main().catch((error) => { console.error('Server error:', error); process.exit(1); }); //# sourceMappingURL=index.js.map