set header name

This commit is contained in:
Ido Salomon
2025-04-05 12:46:25 +03:00
parent 3032a67d4e
commit 91633de80f
4 changed files with 29 additions and 2 deletions

View File

@@ -41,6 +41,7 @@ interface UseConnectionOptions {
env: Record<string, string>;
proxyServerUrl: string;
bearerToken?: string;
headerName?: string;
requestTimeout?: number;
onNotification?: (notification: Notification) => void;
onStdErrNotification?: (notification: Notification) => void;
@@ -64,6 +65,7 @@ export function useConnection({
env,
proxyServerUrl,
bearerToken,
headerName,
requestTimeout,
onNotification,
onStdErrNotification,
@@ -274,7 +276,8 @@ export function useConnection({
// Use manually provided bearer token if available, otherwise use OAuth tokens
const token = bearerToken || (await authProvider.tokens())?.access_token;
if (token) {
headers["Authorization"] = `Bearer ${token}`;
const authHeaderName = headerName || "Authorization";
headers[authHeaderName] = `${token}`;
}
const clientTransport = new SSEClientTransport(mcpProxyServerUrl, {