forked from cristotodev/MCP-Facturascripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp-server.js
More file actions
26 lines (21 loc) · 781 Bytes
/
mcp-server.js
File metadata and controls
26 lines (21 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env node
// MCP FacturaScripts Server Entry Point
// This script ensures the server is built and runs the JavaScript version
import { execSync } from 'child_process';
import { existsSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const distPath = join(__dirname, 'dist', 'index.js');
// Ensure the project is built
try {
if (!existsSync(distPath)) {
console.log('Building project...');
execSync('npm run build', { stdio: 'inherit', cwd: __dirname });
}
// Import and run the built server
const serverModule = await import('./dist/index.js');
} catch (error) {
console.error('Failed to start MCP server:', error.message);
process.exit(1);
}