Add MCP-Protocol-Version header
This commit is contained in:
parent
141f3f5532
commit
fceebdcf5a
1 changed files with 8 additions and 1 deletions
|
|
@ -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<OAuthMetadata | undefined> {
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue