@modelcontextprotocol/inspector-client 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/OAuthCallback-DsrZ1Q5-.js +84 -0
- package/dist/assets/index-CMyU_PZH.js +29652 -0
- package/dist/assets/index-D5WIP3OH.css +2204 -0
- package/dist/index.html +14 -0
- package/dist/mcp.svg +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { u as useToast, r as reactExports, j as jsxRuntimeExports, S as SESSION_KEYS, I as InspectorOAuthClientProvider, a as auth } from "./index-CMyU_PZH.js";
|
|
2
|
+
const parseOAuthCallbackParams = (location) => {
|
|
3
|
+
const params = new URLSearchParams(location);
|
|
4
|
+
const code = params.get("code");
|
|
5
|
+
if (code) {
|
|
6
|
+
return { successful: true, code };
|
|
7
|
+
}
|
|
8
|
+
const error = params.get("error");
|
|
9
|
+
const error_description = params.get("error_description");
|
|
10
|
+
const error_uri = params.get("error_uri");
|
|
11
|
+
if (error) {
|
|
12
|
+
return { successful: false, error, error_description, error_uri };
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
successful: false,
|
|
16
|
+
error: "invalid_request",
|
|
17
|
+
error_description: "Missing code or error in response",
|
|
18
|
+
error_uri: null
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const generateOAuthErrorDescription = (params) => {
|
|
22
|
+
const error = params.error;
|
|
23
|
+
const errorDescription = params.error_description;
|
|
24
|
+
const errorUri = params.error_uri;
|
|
25
|
+
return [
|
|
26
|
+
`Error: ${error}.`,
|
|
27
|
+
errorDescription ? `Details: ${errorDescription}.` : "",
|
|
28
|
+
errorUri ? `More info: ${errorUri}.` : ""
|
|
29
|
+
].filter(Boolean).join("\n");
|
|
30
|
+
};
|
|
31
|
+
const OAuthCallback = ({ onConnect }) => {
|
|
32
|
+
const { toast } = useToast();
|
|
33
|
+
const hasProcessedRef = reactExports.useRef(false);
|
|
34
|
+
reactExports.useEffect(() => {
|
|
35
|
+
const handleCallback = async () => {
|
|
36
|
+
if (hasProcessedRef.current) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
hasProcessedRef.current = true;
|
|
40
|
+
const notifyError = (description) => void toast({
|
|
41
|
+
title: "OAuth Authorization Error",
|
|
42
|
+
description,
|
|
43
|
+
variant: "destructive"
|
|
44
|
+
});
|
|
45
|
+
const params = parseOAuthCallbackParams(window.location.search);
|
|
46
|
+
if (!params.successful) {
|
|
47
|
+
return notifyError(generateOAuthErrorDescription(params));
|
|
48
|
+
}
|
|
49
|
+
const serverUrl = sessionStorage.getItem(SESSION_KEYS.SERVER_URL);
|
|
50
|
+
if (!serverUrl) {
|
|
51
|
+
return notifyError("Missing Server URL");
|
|
52
|
+
}
|
|
53
|
+
let result;
|
|
54
|
+
try {
|
|
55
|
+
const serverAuthProvider = new InspectorOAuthClientProvider(serverUrl);
|
|
56
|
+
result = await auth(serverAuthProvider, {
|
|
57
|
+
serverUrl,
|
|
58
|
+
authorizationCode: params.code
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("OAuth callback error:", error);
|
|
62
|
+
return notifyError(`Unexpected error occurred: ${error}`);
|
|
63
|
+
}
|
|
64
|
+
if (result !== "AUTHORIZED") {
|
|
65
|
+
return notifyError(
|
|
66
|
+
`Expected to be authorized after providing auth code, got: ${result}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
toast({
|
|
70
|
+
title: "Success",
|
|
71
|
+
description: "Successfully authenticated with OAuth",
|
|
72
|
+
variant: "default"
|
|
73
|
+
});
|
|
74
|
+
onConnect(serverUrl);
|
|
75
|
+
};
|
|
76
|
+
handleCallback().finally(() => {
|
|
77
|
+
window.history.replaceState({}, document.title, "/");
|
|
78
|
+
});
|
|
79
|
+
}, [toast, onConnect]);
|
|
80
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-screen", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg text-gray-500", children: "Processing OAuth callback..." }) });
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
OAuthCallback as default
|
|
84
|
+
};
|