Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/lib/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
14 changes: 12 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down