@@ -9,7 +9,8 @@ This library provides a lightweight wrapper that makes [Anthropic Model Context
99
1010- 🔌 ** Transport Options**
1111
12- - Connect to MCP servers via stdio (local) or SSE (remote)
12+ - Connect to MCP servers via stdio (local) or Streamable HTTP (remote)
13+ - Streamable HTTP automatically falls back to SSE for compatibility with legacy MCP server implementations
1314 - Support for custom headers in SSE connections for authentication
1415 - Configurable reconnection strategies for both transport types
1516
@@ -38,13 +39,13 @@ npm install @langchain/mcp-adapters
3839
3940### Optional Dependencies
4041
41- For SSE connections with custom headers in Node.js:
42+ For SSE connections with custom headers in Node.js (does not apply to Streamable HTTP) :
4243
4344``` bash
4445npm install eventsource
4546```
4647
47- For enhanced SSE header support:
48+ For enhanced SSE header support (does not apply to Streamable HTTP) :
4849
4950``` bash
5051npm install extended-eventsource
@@ -155,26 +156,25 @@ const client = new MultiServerMCPClient({
155156 args: [" -y" , " @modelcontextprotocol/server-filesystem" ],
156157 },
157158
158- // SSE transport example with reconnection configuration
159+ // Sreamable HTTP transport example, with auth headers and automatic SSE fallback disabled (defaults to enabled)
159160 weather: {
160- transport: " sse" ,
161- url: " https://example.com/mcp-weather" ,
161+ url: " https://example.com/weather/mcp" ,
162162 headers: {
163163 Authorization: " Bearer token123" ,
164- },
165- useNodeEventSource: true ,
164+ }
165+ automaticSSEFallback : false
166+ },
167+
168+ // how to force SSE, for old servers that are known to only support SSE (streamable HTTP falls back automatically if unsure)
169+ github: {
170+ transport: " sse" , // also works with "type" field instead of "transport"
171+ url: " https://example.com/mcp" ,
166172 reconnect: {
167173 enabled: true ,
168174 maxAttempts: 5 ,
169175 delayMs: 2000 ,
170176 },
171177 },
172-
173- // Streamable HTTP transport example
174- github: {
175- transport: " streamable" ,
176- url: " https://example.com/mcp" ,
177- },
178178 },
179179});
180180
@@ -218,8 +218,8 @@ When loading MCP tools either directly through `loadMcpTools` or via `MultiServe
218218| Option | Type | Default | Description |
219219| ------------------------------ | ------- | ------- | ------------------------------------------------------------------------------------ |
220220| ` throwOnLoadError ` | boolean | ` true ` | Whether to throw an error if a tool fails to load |
221- | ` prefixToolNameWithServerName ` | boolean | ` false ` | If true, prefixes all tool names with the server name (e.g., ` serverName__toolName ` ) |
222- | ` additionalToolNamePrefix ` | string | ` "" ` | Additional prefix to add to tool names (e.g., ` prefix__serverName__toolName ` ) |
221+ | ` prefixToolNameWithServerName ` | boolean | ` true ` | If true, prefixes all tool names with the server name (e.g., ` serverName__toolName ` ) |
222+ | ` additionalToolNamePrefix ` | string | ` mcp ` | Additional prefix to add to tool names (e.g., ` prefix__serverName__toolName ` ) |
223223
224224## Response Handling
225225
@@ -367,8 +367,8 @@ Example Zod error for an invalid SSE URL:
367367
368368When using in browsers:
369369
370- - Native EventSource API doesn't support custom headers
371- - Consider using a proxy or pass authentication via query parameters
370+ - EventSource API doesn't support custom headers for SSE
371+ - Consider using a proxy or pass authentication via query parameters to avoid leaking credentials to client
372372- May require CORS configuration on the server side
373373
374374## Troubleshooting
0 commit comments