During metadata fetching, try with the MCP header, then without, then return undefined if both fail
This commit is contained in:
parent
80e148491c
commit
1b8e94ca40
1 changed files with 13 additions and 4 deletions
|
|
@ -163,11 +163,20 @@ export async function discoverOAuthMetadata(
|
|||
opts?: { protocolVersion?: string },
|
||||
): Promise<OAuthMetadata | undefined> {
|
||||
const url = new URL("/.well-known/oauth-authorization-server", serverUrl);
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"MCP-Protocol-Version": opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetch(url, {
|
||||
headers: {
|
||||
"MCP-Protocol-Version": opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION
|
||||
}
|
||||
});
|
||||
} catch {
|
||||
try {
|
||||
response = await fetch(url);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (response.status === 404) {
|
||||
return undefined;
|
||||
|
|
|
|||
Loading…
Reference in a new issue