Skip to content

Commit fceebdc

Browse files
committed
Add MCP-Protocol-Version header
1 parent 141f3f5 commit fceebdc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/client/auth.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pkceChallenge from "pkce-challenge";
22
import { z } from "zod";
3+
import { LATEST_PROTOCOL_VERSION } from "../types.js";
34

45
export const OAuthMetadataSchema = z
56
.object({
@@ -229,9 +230,15 @@ export async function auth(
229230
*/
230231
export async function discoverOAuthMetadata(
231232
serverUrl: string | URL,
233+
opts?: { protocolVersion?: string },
232234
): Promise<OAuthMetadata | undefined> {
233235
const url = new URL("/.well-known/oauth-authorization-server", serverUrl);
234-
const response = await fetch(url);
236+
const response = await fetch(url, {
237+
headers: {
238+
"MCP-Protocol-Version": opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION
239+
}
240+
});
241+
235242
if (response.status === 404) {
236243
return undefined;
237244
}

0 commit comments

Comments
 (0)