@toponextech/smartembed-mcp-server
Version:
MCP server for intelligent embedded development with PlatformIO - AI-powered project creation, error diagnosis, and device detection
91 lines (87 loc) • 2.76 kB
JavaScript
/**
* SmartEmbed MCP Server CLI
* Command-line interface for the MCP server
*/
Object.defineProperty(exports, "__esModule", { value: true });
const server_1 = require("./server");
// Ensure the process doesn't exit on uncaught errors before we handle them
process.on('uncaughtException', (error) => {
console.error('Uncaught Exception:', error);
process.exit(1);
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
process.exit(1);
});
async function main() {
// Parse command line arguments
const args = process.argv.slice(2);
// Handle help flag
if (args.includes('--help') || args.includes('-h')) {
console.log(`
SmartEmbed MCP Server v1.0.0
Intelligent embedded development assistant for PlatformIO
Usage: smartembed-mcp-server [options]
Options:
-h, --help Show this help message
-v, --version Show version information
--debug Enable debug logging
This server implements the Model Context Protocol (MCP) and should be
configured in your Cline settings. For more information, visit:
https://github.com/toponex/smartembed-mcp-server
Example Cline configuration:
{
"mcpServers": {
"smartembed": {
"command": "npx",
"args": ["smartembed-mcp-server"]
}
}
}
`.trim());
process.exit(0);
}
// Handle version flag
if (args.includes('--version') || args.includes('-v')) {
const packageInfo = require('../package.json');
console.log(`smartembed-mcp-server v${packageInfo.version}`);
process.exit(0);
}
// Enable debug mode if requested
if (args.includes('--debug')) {
process.env.DEBUG = 'smartembed:*';
}
// Create and start server
const server = new server_1.SmartEmbedServer();
try {
await server.start();
// Log to stderr to avoid interfering with MCP protocol
if (process.env.DEBUG) {
console.error('[SmartEmbed] MCP Server started successfully');
}
}
catch (error) {
console.error('[SmartEmbed] Failed to start MCP Server:', error);
process.exit(1);
}
// Handle graceful shutdown
const shutdown = async () => {
if (process.env.DEBUG) {
console.error('[SmartEmbed] Shutting down MCP Server...');
}
await server.stop();
process.exit(0);
};
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);
// Keep the process alive
process.stdin.resume();
}
// Run the CLI
main().catch(error => {
console.error('[SmartEmbed] Fatal error:', error);
process.exit(1);
});
//# sourceMappingURL=cli.js.map
;