refactor: remove resource config
This commit is contained in:
parent
b8120d9f85
commit
3b3205228f
5 changed files with 4 additions and 52 deletions
|
|
@ -124,10 +124,6 @@ const App = () => {
|
||||||
return localStorage.getItem("lastOauthScope") || "";
|
return localStorage.getItem("lastOauthScope") || "";
|
||||||
});
|
});
|
||||||
|
|
||||||
const [oauthResource, setOauthResource] = useState<string>(() => {
|
|
||||||
return localStorage.getItem("lastOauthResource") || "";
|
|
||||||
});
|
|
||||||
|
|
||||||
const [pendingSampleRequests, setPendingSampleRequests] = useState<
|
const [pendingSampleRequests, setPendingSampleRequests] = useState<
|
||||||
Array<
|
Array<
|
||||||
PendingRequest & {
|
PendingRequest & {
|
||||||
|
|
@ -198,7 +194,6 @@ const App = () => {
|
||||||
headerName,
|
headerName,
|
||||||
oauthClientId,
|
oauthClientId,
|
||||||
oauthScope,
|
oauthScope,
|
||||||
oauthResource,
|
|
||||||
config,
|
config,
|
||||||
onNotification: (notification) => {
|
onNotification: (notification) => {
|
||||||
setNotifications((prev) => [...prev, notification as ServerNotification]);
|
setNotifications((prev) => [...prev, notification as ServerNotification]);
|
||||||
|
|
@ -250,10 +245,6 @@ const App = () => {
|
||||||
localStorage.setItem("lastOauthScope", oauthScope);
|
localStorage.setItem("lastOauthScope", oauthScope);
|
||||||
}, [oauthScope]);
|
}, [oauthScope]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
localStorage.setItem("lastOauthResource", oauthResource);
|
|
||||||
}, [oauthResource]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
saveInspectorConfig(CONFIG_LOCAL_STORAGE_KEY, config);
|
saveInspectorConfig(CONFIG_LOCAL_STORAGE_KEY, config);
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
@ -681,8 +672,6 @@ const App = () => {
|
||||||
setOauthClientId={setOauthClientId}
|
setOauthClientId={setOauthClientId}
|
||||||
oauthScope={oauthScope}
|
oauthScope={oauthScope}
|
||||||
setOauthScope={setOauthScope}
|
setOauthScope={setOauthScope}
|
||||||
oauthResource={oauthResource}
|
|
||||||
setOauthResource={setOauthResource}
|
|
||||||
onConnect={connectMcpServer}
|
onConnect={connectMcpServer}
|
||||||
onDisconnect={disconnectMcpServer}
|
onDisconnect={disconnectMcpServer}
|
||||||
stdErrNotifications={stdErrNotifications}
|
stdErrNotifications={stdErrNotifications}
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,6 @@ interface SidebarProps {
|
||||||
setOauthClientId: (id: string) => void;
|
setOauthClientId: (id: string) => void;
|
||||||
oauthScope: string;
|
oauthScope: string;
|
||||||
setOauthScope: (scope: string) => void;
|
setOauthScope: (scope: string) => void;
|
||||||
oauthResource: string;
|
|
||||||
setOauthResource: (resource: string) => void;
|
|
||||||
onConnect: () => void;
|
onConnect: () => void;
|
||||||
onDisconnect: () => void;
|
onDisconnect: () => void;
|
||||||
stdErrNotifications: StdErrNotification[];
|
stdErrNotifications: StdErrNotification[];
|
||||||
|
|
@ -93,8 +91,6 @@ const Sidebar = ({
|
||||||
setOauthClientId,
|
setOauthClientId,
|
||||||
oauthScope,
|
oauthScope,
|
||||||
setOauthScope,
|
setOauthScope,
|
||||||
oauthResource,
|
|
||||||
setOauthResource,
|
|
||||||
onConnect,
|
onConnect,
|
||||||
onDisconnect,
|
onDisconnect,
|
||||||
stdErrNotifications,
|
stdErrNotifications,
|
||||||
|
|
@ -409,14 +405,6 @@ const Sidebar = ({
|
||||||
data-testid="oauth-scope-input"
|
data-testid="oauth-scope-input"
|
||||||
className="font-mono"
|
className="font-mono"
|
||||||
/>
|
/>
|
||||||
<label className="text-sm font-medium">Resource</label>
|
|
||||||
<Input
|
|
||||||
placeholder="Resource"
|
|
||||||
onChange={(e) => setOauthResource(e.target.value)}
|
|
||||||
value={oauthResource}
|
|
||||||
data-testid="oauth-resource-input"
|
|
||||||
className="font-mono"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,6 @@ describe("Sidebar Environment Variables", () => {
|
||||||
setOauthClientId: jest.fn(),
|
setOauthClientId: jest.fn(),
|
||||||
oauthScope: "",
|
oauthScope: "",
|
||||||
setOauthScope: jest.fn(),
|
setOauthScope: jest.fn(),
|
||||||
oauthResource: "",
|
|
||||||
setOauthResource: jest.fn(),
|
|
||||||
env: {},
|
env: {},
|
||||||
setEnv: jest.fn(),
|
setEnv: jest.fn(),
|
||||||
bearerToken: "",
|
bearerToken: "",
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,8 @@ export const clearClientInformationFromSessionStorage = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
export class InspectorOAuthClientProvider implements OAuthClientProvider {
|
export class InspectorOAuthClientProvider implements OAuthClientProvider {
|
||||||
constructor(
|
|
||||||
protected serverUrl: string,
|
constructor(protected serverUrl: string) {
|
||||||
protected resource?: string,
|
|
||||||
) {
|
|
||||||
// Save the server URL to session storage
|
// Save the server URL to session storage
|
||||||
sessionStorage.setItem(SESSION_KEYS.SERVER_URL, serverUrl);
|
sessionStorage.setItem(SESSION_KEYS.SERVER_URL, serverUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -131,18 +129,6 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
redirectToAuthorization(authorizationUrl: URL) {
|
redirectToAuthorization(authorizationUrl: URL) {
|
||||||
/**
|
|
||||||
* Note: This resource parameter is for testing purposes in Inspector.
|
|
||||||
* Once MCP Client SDK supports resource indicators, this parameter
|
|
||||||
* will be passed to the SDK's auth method similar to how scope is passed.
|
|
||||||
*
|
|
||||||
* See: https://github.com/modelcontextprotocol/typescript-sdk/pull/498
|
|
||||||
*
|
|
||||||
* TODO: @xiaoyijun Remove this once MCP Client SDK supports resource indicators.
|
|
||||||
*/
|
|
||||||
if (this.resource) {
|
|
||||||
authorizationUrl.searchParams.set("resource", this.resource);
|
|
||||||
}
|
|
||||||
window.location.href = authorizationUrl.href;
|
window.location.href = authorizationUrl.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ interface UseConnectionOptions {
|
||||||
headerName?: string;
|
headerName?: string;
|
||||||
oauthClientId?: string;
|
oauthClientId?: string;
|
||||||
oauthScope?: string;
|
oauthScope?: string;
|
||||||
oauthResource?: string;
|
|
||||||
config: InspectorConfig;
|
config: InspectorConfig;
|
||||||
onNotification?: (notification: Notification) => void;
|
onNotification?: (notification: Notification) => void;
|
||||||
onStdErrNotification?: (notification: Notification) => void;
|
onStdErrNotification?: (notification: Notification) => void;
|
||||||
|
|
@ -78,7 +77,6 @@ export function useConnection({
|
||||||
headerName,
|
headerName,
|
||||||
oauthClientId,
|
oauthClientId,
|
||||||
oauthScope,
|
oauthScope,
|
||||||
oauthResource,
|
|
||||||
config,
|
config,
|
||||||
onNotification,
|
onNotification,
|
||||||
onStdErrNotification,
|
onStdErrNotification,
|
||||||
|
|
@ -301,7 +299,6 @@ export function useConnection({
|
||||||
if (is401Error(error)) {
|
if (is401Error(error)) {
|
||||||
const serverAuthProvider = new InspectorOAuthClientProvider(
|
const serverAuthProvider = new InspectorOAuthClientProvider(
|
||||||
sseUrl,
|
sseUrl,
|
||||||
oauthResource,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await auth(serverAuthProvider, {
|
const result = await auth(serverAuthProvider, {
|
||||||
|
|
@ -343,10 +340,7 @@ export function useConnection({
|
||||||
const headers: HeadersInit = {};
|
const headers: HeadersInit = {};
|
||||||
|
|
||||||
// Create an auth provider with the current server URL
|
// Create an auth provider with the current server URL
|
||||||
const serverAuthProvider = new InspectorOAuthClientProvider(
|
const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
|
||||||
sseUrl,
|
|
||||||
oauthResource,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Use manually provided bearer token if available, otherwise use OAuth tokens
|
// Use manually provided bearer token if available, otherwise use OAuth tokens
|
||||||
const token =
|
const token =
|
||||||
|
|
@ -566,10 +560,7 @@ export function useConnection({
|
||||||
clientTransport as StreamableHTTPClientTransport
|
clientTransport as StreamableHTTPClientTransport
|
||||||
).terminateSession();
|
).terminateSession();
|
||||||
await mcpClient?.close();
|
await mcpClient?.close();
|
||||||
const authProvider = new InspectorOAuthClientProvider(
|
const authProvider = new InspectorOAuthClientProvider(sseUrl);
|
||||||
sseUrl,
|
|
||||||
oauthResource,
|
|
||||||
);
|
|
||||||
authProvider.clear();
|
authProvider.clear();
|
||||||
setMcpClient(null);
|
setMcpClient(null);
|
||||||
setClientTransport(null);
|
setClientTransport(null);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue