refactor: remove resource config

This commit is contained in:
Xiao Yijun 2025-07-08 10:21:40 +08:00
commit 3b3205228f
No known key found for this signature in database
GPG key ID: 6F648FC1262DB420
5 changed files with 4 additions and 52 deletions

View file

@ -124,10 +124,6 @@ const App = () => {
return localStorage.getItem("lastOauthScope") || "";
});
const [oauthResource, setOauthResource] = useState<string>(() => {
return localStorage.getItem("lastOauthResource") || "";
});
const [pendingSampleRequests, setPendingSampleRequests] = useState<
Array<
PendingRequest & {
@ -198,7 +194,6 @@ const App = () => {
headerName,
oauthClientId,
oauthScope,
oauthResource,
config,
onNotification: (notification) => {
setNotifications((prev) => [...prev, notification as ServerNotification]);
@ -250,10 +245,6 @@ const App = () => {
localStorage.setItem("lastOauthScope", oauthScope);
}, [oauthScope]);
useEffect(() => {
localStorage.setItem("lastOauthResource", oauthResource);
}, [oauthResource]);
useEffect(() => {
saveInspectorConfig(CONFIG_LOCAL_STORAGE_KEY, config);
}, [config]);
@ -681,8 +672,6 @@ const App = () => {
setOauthClientId={setOauthClientId}
oauthScope={oauthScope}
setOauthScope={setOauthScope}
oauthResource={oauthResource}
setOauthResource={setOauthResource}
onConnect={connectMcpServer}
onDisconnect={disconnectMcpServer}
stdErrNotifications={stdErrNotifications}

View file

@ -60,8 +60,6 @@ interface SidebarProps {
setOauthClientId: (id: string) => void;
oauthScope: string;
setOauthScope: (scope: string) => void;
oauthResource: string;
setOauthResource: (resource: string) => void;
onConnect: () => void;
onDisconnect: () => void;
stdErrNotifications: StdErrNotification[];
@ -93,8 +91,6 @@ const Sidebar = ({
setOauthClientId,
oauthScope,
setOauthScope,
oauthResource,
setOauthResource,
onConnect,
onDisconnect,
stdErrNotifications,
@ -409,14 +405,6 @@ const Sidebar = ({
data-testid="oauth-scope-input"
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>

View file

@ -46,8 +46,6 @@ describe("Sidebar Environment Variables", () => {
setOauthClientId: jest.fn(),
oauthScope: "",
setOauthScope: jest.fn(),
oauthResource: "",
setOauthResource: jest.fn(),
env: {},
setEnv: jest.fn(),
bearerToken: "",

View file

@ -66,10 +66,8 @@ export const clearClientInformationFromSessionStorage = ({
};
export class InspectorOAuthClientProvider implements OAuthClientProvider {
constructor(
protected serverUrl: string,
protected resource?: string,
) {
constructor(protected serverUrl: string) {
// Save the server URL to session storage
sessionStorage.setItem(SESSION_KEYS.SERVER_URL, serverUrl);
}
@ -131,18 +129,6 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
}
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;
}

View file

@ -58,7 +58,6 @@ interface UseConnectionOptions {
headerName?: string;
oauthClientId?: string;
oauthScope?: string;
oauthResource?: string;
config: InspectorConfig;
onNotification?: (notification: Notification) => void;
onStdErrNotification?: (notification: Notification) => void;
@ -78,7 +77,6 @@ export function useConnection({
headerName,
oauthClientId,
oauthScope,
oauthResource,
config,
onNotification,
onStdErrNotification,
@ -301,7 +299,6 @@ export function useConnection({
if (is401Error(error)) {
const serverAuthProvider = new InspectorOAuthClientProvider(
sseUrl,
oauthResource,
);
const result = await auth(serverAuthProvider, {
@ -343,10 +340,7 @@ export function useConnection({
const headers: HeadersInit = {};
// Create an auth provider with the current server URL
const serverAuthProvider = new InspectorOAuthClientProvider(
sseUrl,
oauthResource,
);
const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
// Use manually provided bearer token if available, otherwise use OAuth tokens
const token =
@ -566,10 +560,7 @@ export function useConnection({
clientTransport as StreamableHTTPClientTransport
).terminateSession();
await mcpClient?.close();
const authProvider = new InspectorOAuthClientProvider(
sseUrl,
oauthResource,
);
const authProvider = new InspectorOAuthClientProvider(sseUrl);
authProvider.clear();
setMcpClient(null);
setClientTransport(null);