cli.tsā¢1.21 kB
#!/usr/bin/env node
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { spawn } from 'child_process';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const args = process.argv.slice(2);
const serverName = args[0];
const serverMap: Record<string, string> = {
'arxiv': join(__dirname, 'servers', 'arxiv-server.js'),
'semantic': join(__dirname, 'servers', 'semantic-scholar-server.js'),
'pubmed': join(__dirname, 'servers', 'pubmed-server.js'),
};
if (!serverName || !serverMap[serverName]) {
console.error('Usage: researchmcp <arxiv|semantic|pubmed>');
console.error('\nAvailable servers:');
console.error(' arxiv - arXiv research papers');
console.error(' semantic - Semantic Scholar with citations');
console.error(' pubmed - PubMed biomedical research');
process.exit(1);
}
const serverPath = serverMap[serverName];
// Spawn the server process
const child = spawn('node', [serverPath], {
stdio: 'inherit',
env: process.env,
});
child.on('error', (error) => {
console.error('Failed to start server:', error);
process.exit(1);
});
child.on('exit', (code) => {
process.exit(code || 0);
});