Merge branch 'main' into add-mcp-docs-server-to-claude
This commit is contained in:
commit
ea82effeed
2 changed files with 29 additions and 7 deletions
|
|
@ -153,15 +153,22 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
get clientMetadata(): OAuthClientMetadata {
|
get clientMetadata(): OAuthClientMetadata {
|
||||||
return {
|
const metadata: OAuthClientMetadata = {
|
||||||
redirect_uris: this.redirect_uris,
|
redirect_uris: this.redirect_uris,
|
||||||
token_endpoint_auth_method: "none",
|
token_endpoint_auth_method: "none",
|
||||||
grant_types: ["authorization_code", "refresh_token"],
|
grant_types: ["authorization_code", "refresh_token"],
|
||||||
response_types: ["code"],
|
response_types: ["code"],
|
||||||
client_name: "MCP Inspector",
|
client_name: "MCP Inspector",
|
||||||
client_uri: "https://github.com/modelcontextprotocol/inspector",
|
client_uri: "https://github.com/modelcontextprotocol/inspector",
|
||||||
scope: this.scope ?? "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Only include scope if it's defined and non-empty
|
||||||
|
// Per OAuth spec, omit the scope field entirely if no scopes are requested
|
||||||
|
if (this.scope) {
|
||||||
|
metadata.scope = this.scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
state(): string | Promise<string> {
|
state(): string | Promise<string> {
|
||||||
|
|
|
||||||
|
|
@ -393,11 +393,22 @@ export function useConnection({
|
||||||
saveScopeToSessionStorage(sseUrl, scope);
|
saveScopeToSessionStorage(sseUrl, scope);
|
||||||
const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
|
const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
|
||||||
|
|
||||||
const result = await auth(serverAuthProvider, {
|
try {
|
||||||
serverUrl: sseUrl,
|
const result = await auth(serverAuthProvider, {
|
||||||
scope,
|
serverUrl: sseUrl,
|
||||||
});
|
scope,
|
||||||
return result === "AUTHORIZED";
|
});
|
||||||
|
return result === "AUTHORIZED";
|
||||||
|
} catch (authError) {
|
||||||
|
// Show user-friendly error message for OAuth failures
|
||||||
|
toast({
|
||||||
|
title: "OAuth Authentication Failed",
|
||||||
|
description:
|
||||||
|
authError instanceof Error ? authError.message : String(authError),
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -534,6 +545,7 @@ export function useConnection({
|
||||||
requestHeaders["Accept"] = "text/event-stream";
|
requestHeaders["Accept"] = "text/event-stream";
|
||||||
requestHeaders["content-type"] = "application/json";
|
requestHeaders["content-type"] = "application/json";
|
||||||
transportOptions = {
|
transportOptions = {
|
||||||
|
authProvider: serverAuthProvider,
|
||||||
fetch: async (
|
fetch: async (
|
||||||
url: string | URL | globalThis.Request,
|
url: string | URL | globalThis.Request,
|
||||||
init?: RequestInit,
|
init?: RequestInit,
|
||||||
|
|
@ -555,6 +567,7 @@ export function useConnection({
|
||||||
|
|
||||||
case "streamable-http":
|
case "streamable-http":
|
||||||
transportOptions = {
|
transportOptions = {
|
||||||
|
authProvider: serverAuthProvider,
|
||||||
fetch: async (
|
fetch: async (
|
||||||
url: string | URL | globalThis.Request,
|
url: string | URL | globalThis.Request,
|
||||||
init?: RequestInit,
|
init?: RequestInit,
|
||||||
|
|
@ -643,6 +656,7 @@ export function useConnection({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
transportOptions = {
|
transportOptions = {
|
||||||
|
authProvider: serverAuthProvider,
|
||||||
eventSourceInit: {
|
eventSourceInit: {
|
||||||
fetch: (
|
fetch: (
|
||||||
url: string | URL | globalThis.Request,
|
url: string | URL | globalThis.Request,
|
||||||
|
|
@ -664,6 +678,7 @@ export function useConnection({
|
||||||
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/mcp`);
|
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/mcp`);
|
||||||
mcpProxyServerUrl.searchParams.append("url", sseUrl);
|
mcpProxyServerUrl.searchParams.append("url", sseUrl);
|
||||||
transportOptions = {
|
transportOptions = {
|
||||||
|
authProvider: serverAuthProvider,
|
||||||
eventSourceInit: {
|
eventSourceInit: {
|
||||||
fetch: (
|
fetch: (
|
||||||
url: string | URL | globalThis.Request,
|
url: string | URL | globalThis.Request,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue