We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/n0zer0d4y/vulcan-file-ops'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
cli.ts•1.92 KiB
#!/usr/bin/env node
// CRITICAL: Detect MCP mode and suppress console output BEFORE any imports
// MCP servers use stdin/stdout for JSON-RPC via stdio transport
// Detection: stdin/stdout are NOT TTY (piped/redirected) = MCP mode
//
// EXCEPTION: --help and --version flags should always output to console
// even when stdin/stdout are piped (e.g., in scripts or CI environments)
const isHelpOrVersion = process.argv.some(
(arg) => arg === "--help" || arg === "-h" || arg === "--version" || arg === "-v"
);
// MCP mode detection: suppress console if ANY of these are true:
// 1. stdin is piped/redirected (not a TTY) - MCP clients pipe JSON-RPC via stdin
// 2. stdout is piped/redirected (not a TTY) - MCP clients read JSON-RPC from stdout
// 3. argv contains "mcp" or "stdio" - explicit MCP mode indicator
// Using OR (||) instead of AND (&&) because MCP clients may only pipe one direction
const isMCP =
!isHelpOrVersion &&
(!process.stdin.isTTY ||
!process.stdout.isTTY ||
process.argv.some((arg) => arg.includes("mcp") || arg.includes("stdio")));
if (isMCP) {
// Suppress all console methods (but NOT stdout/stderr streams - MCP SDK needs those)
const noop = () => {};
console.log = noop;
console.error = noop;
console.warn = noop;
console.info = noop;
console.debug = noop;
// NOTE: Do NOT redirect process.stdout.write or process.stderr.write
// as the MCP SDK uses those for JSON-RPC protocol communication
}
import { runServer } from "./server/index.js";
// Run the server and handle any fatal errors
runServer().catch((error) => {
// Only show errors when not running under MCP (to avoid protocol corruption)
if (!isMCP) {
// Restore console.error temporarily for fatal errors
const originalError = console.error;
if (originalError.toString() !== "() => {}") {
originalError("Fatal error running server:", error);
}
}
process.exit(1);
});