mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
feat: add headers support to SSE transport MCP servers (#3902)
This commit is contained in:
@@ -6,7 +6,10 @@
|
||||
|
||||
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
||||
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
||||
import {
|
||||
SSEClientTransport,
|
||||
SSEClientTransportOptions,
|
||||
} from '@modelcontextprotocol/sdk/client/sse.js';
|
||||
import {
|
||||
StreamableHTTPClientTransport,
|
||||
StreamableHTTPClientTransportOptions,
|
||||
@@ -190,7 +193,16 @@ async function connectAndDiscover(
|
||||
transportOptions,
|
||||
);
|
||||
} else if (mcpServerConfig.url) {
|
||||
transport = new SSEClientTransport(new URL(mcpServerConfig.url));
|
||||
const transportOptions: SSEClientTransportOptions = {};
|
||||
if (mcpServerConfig.headers) {
|
||||
transportOptions.requestInit = {
|
||||
headers: mcpServerConfig.headers,
|
||||
};
|
||||
}
|
||||
transport = new SSEClientTransport(
|
||||
new URL(mcpServerConfig.url),
|
||||
transportOptions,
|
||||
);
|
||||
} else if (mcpServerConfig.command) {
|
||||
transport = new StdioClientTransport({
|
||||
command: mcpServerConfig.command,
|
||||
|
||||
Reference in New Issue
Block a user