Parse server transport configuration from CLI arguments and environment variables.
Each server runs with exactly one transport (stdio or HTTP, not both). Path is always '/mcp' per MCP convention (hardcoded in router).
Supports two primary modes:
CLI arguments array (REQUIRED - no default, typically process.argv)
Environment variables object (REQUIRED - no default, typically process.env)
Parsed transport configuration with single transport
Basic stdio usageconst config = parseConfig(process.argv, process.env);// Result: { transport: { type: 'stdio' } } Copy
Basic stdio usageconst config = parseConfig(process.argv, process.env);// Result: { transport: { type: 'stdio' } }
HTTP mode with CLI flagconst config = parseConfig(['--port=3000'], process.env);// Result: { transport: { type: 'http', port: 3000 }, port: 3000 } Copy
HTTP mode with CLI flagconst config = parseConfig(['--port=3000'], process.env);// Result: { transport: { type: 'http', port: 3000 }, port: 3000 }
HTTP mode with env varconst config = parseConfig([], { PORT: '3000' });// Result: { transport: { type: 'http', port: 3000 }, port: 3000 } Copy
HTTP mode with env varconst config = parseConfig([], { PORT: '3000' });// Result: { transport: { type: 'http', port: 3000 }, port: 3000 }
Parse server transport configuration from CLI arguments and environment variables.
Each server runs with exactly one transport (stdio or HTTP, not both). Path is always '/mcp' per MCP convention (hardcoded in router).
Supports two primary modes: