Skip to main content
Glama
cli.ts•1.86 kB
#!/usr/bin/env node /** * CLI entry point for MCP Screenshot server */ import { MCPScreenshotServer } from "./server"; import { SecurityPolicy } from "./types"; // Parse command line arguments for configuration const args = process.argv.slice(2); const configPath = args .find((arg) => arg.startsWith("--config=")) ?.split("=")[1]; // Load security policy from config file if provided let securityPolicy: Partial<SecurityPolicy> | undefined; let excludedWindowPatterns: string[] | undefined; if (configPath) { try { const fs = require("fs"); const config = JSON.parse(fs.readFileSync(configPath, "utf-8")); securityPolicy = config.securityPolicy; excludedWindowPatterns = config.excludedWindowPatterns; } catch (error) { console.error(`Failed to load config from ${configPath}:`, error); process.exit(1); } } // Create and start server const server = new MCPScreenshotServer(securityPolicy, excludedWindowPatterns); // Handle graceful shutdown const shutdown = async (signal: string) => { console.error(`\nReceived ${signal}, shutting down gracefully...`); try { await server.stop(); process.exit(0); } catch (error) { console.error("Error during shutdown:", error); process.exit(1); } }; process.on("SIGINT", () => shutdown("SIGINT")); process.on("SIGTERM", () => shutdown("SIGTERM")); // Handle uncaught errors process.on("uncaughtException", (error) => { console.error("Uncaught exception:", error); shutdown("uncaughtException").catch(() => process.exit(1)); }); process.on("unhandledRejection", (reason, promise) => { console.error("Unhandled rejection at:", promise, "reason:", reason); shutdown("unhandledRejection").catch(() => process.exit(1)); }); // Start the server server.start().catch((error) => { console.error("Failed to start server:", error); process.exit(1); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Digital-Defiance/mcp-screenshot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server