From 3b9924de411aee0586ab542c79518ec7ae96a091 Mon Sep 17 00:00:00 2001 From: Christopher Pappas Date: Sat, 4 Oct 2025 10:34:39 -0700 Subject: [PATCH 1/2] feat: add --silent flag to suppress log output --- src/lib/utils.test.ts | 13 +++++++++++++ src/lib/utils.ts | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts index 9ae95ca..6cd3c9f 100644 --- a/src/lib/utils.test.ts +++ b/src/lib/utils.test.ts @@ -418,6 +418,19 @@ describe('Feature: Command Line Arguments Parsing', () => { consoleSpy.mockRestore() }) + + it('Scenario: Suppresses LOG when using --silent', async () => { + const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {}) + const args = ['https://example.com/sse', '--auth-timeout', '45', '--silent'] + const usage = 'test usage' + + const result = await parseCommandLineArgs(args, usage) + + expect(result.authTimeoutMs).toBe(45000) + expect(consoleSpy).not.toHaveBeenCalled() + + consoleSpy.mockRestore() + }) }) describe('Feature: Tool Filtering with Ignore Patterns', () => { diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 3824903..76d6bc0 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -32,6 +32,7 @@ export { MCP_REMOTE_VERSION } const pid = process.pid // Global debug flag export let DEBUG = false +export let SILENT = false // Helper function for timestamp formatting function getTimestamp(): string { @@ -72,8 +73,10 @@ export function debugLog(message: string, ...args: any[]) { } export function log(str: string, ...rest: unknown[]) { - // Using stderr so that it doesn't interfere with stdout - console.error(`[${pid}] ${str}`, ...rest) + if (!SILENT) { + // Using stderr so that it doesn't interfere with stdout + console.error(`[${pid}] ${str}`, ...rest) + } // If debug mode is on, also log to debug file debugLog(str, ...rest) @@ -632,6 +635,13 @@ export async function parseCommandLineArgs(args: string[], usage: string) { log('Debug mode enabled - detailed logs will be written to ~/.mcp-auth/') } + // Check for silent flag + const silent = args.includes('--silent') + if (silent) { + SILENT = true + log('Silent mode enabled - stderr output will be suppressed, except when --debug is also enabled') + } + const enableProxy = args.includes('--enable-proxy') if (enableProxy) { // Use env proxy From e24d577b1d1880c7ae026536233701dffb68ab0a Mon Sep 17 00:00:00 2001 From: Christopher Pappas Date: Sat, 4 Oct 2025 10:41:13 -0700 Subject: [PATCH 2/2] docs: update docs with new `--silent` flag --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index ca9d961..ed1e2a6 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,16 @@ To bypass authentication, or to emit custom headers on all requests to your remo ] ``` +* To suppress default logs, add the `--silent` flag. This will prevent logs from being emitted, except in the case where `--debug` is also passed. + +```json + "args": [ + "mcp-remote", + "https://remote.mcp.server/sse", + "--silent" + ] +``` + * To enable an outbound HTTP(S) proxy for mcp-remote, add the `--enable-proxy` flag. When enabled, mcp-remote will use the proxy settings from common environment variables (for example `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`). ```json