From fceebdcf5a49837187b8436ccc323d1da4067287 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 11 Feb 2025 17:58:58 +0000 Subject: [PATCH] Add `MCP-Protocol-Version` header --- src/client/auth.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/auth.ts b/src/client/auth.ts index 8b6eed7c..2c11ea8a 100644 --- a/src/client/auth.ts +++ b/src/client/auth.ts @@ -1,5 +1,6 @@ import pkceChallenge from "pkce-challenge"; import { z } from "zod"; +import { LATEST_PROTOCOL_VERSION } from "../types.js"; export const OAuthMetadataSchema = z .object({ @@ -229,9 +230,15 @@ export async function auth( */ export async function discoverOAuthMetadata( serverUrl: string | URL, + opts?: { protocolVersion?: string }, ): Promise { const url = new URL("/.well-known/oauth-authorization-server", serverUrl); - const response = await fetch(url); + const response = await fetch(url, { + headers: { + "MCP-Protocol-Version": opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION + } + }); + if (response.status === 404) { return undefined; }