[Bug] MCP websocket transport silently drops the configured `headers`, so Authorization is never sent
Description
A websocket MCP server config can include headers, but the transport is created with new WebSocketClientTransport(url) and the headers are never used. The server receives the connection with no Authorization header and nothing tells the user.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at eb7dee57)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
- Start a WebSocket server (for example with the
wspackage) that recordsreq.headers.authorizationon each connection. - Create the transport:
TransportFactory.createTransport({name: 'ws', transport: 'websocket', url: 'ws://127.0.0.1:<port>', headers: {Authorization: 'Bearer secret-token'}}). - Call
await transport.start()and look at what the server recorded.
Expected Behavior
The server receives Authorization: Bearer secret-token. If headers cannot be sent, the config is rejected with a clear message.
Actual Behavior
The server records undefined. The headers are ignored with no warning.
Logs/Screenshots
recorded authorization header: [ undefined ] (expected [ 'Bearer secret-token' ])
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/mcp/transport-factory.ts:144-162(createWebSocketTransport): the SDK'sWebSocketClientTransporttakes only a URL. Wrap it (or pass a WebSocket factory) so thewsclient is created with{headers}.- At minimum, throw or warn when
server.headersis set for a websocket server (config type atsource/types/config.tsaround line 558). - Add a test with a local
wsserver like the steps above.
Hi! Picking this up—I have a fix and regression tests ready that forward configured headers over the ws client transport (loaded lazily in start() so startup module count stays unchanged) and preserve websocket headers in the Custom MCP wizard. Opening a PR shortly.