Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v6

- name: Check formatting
run: npx prettier --check .
run: npx prettier@3.7.4 --check .

- uses: actions/setup-node@v6
with:
Expand Down
13 changes: 10 additions & 3 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,14 @@
};

try {
const stateMachine = new OAuthStateMachine(sseUrl, (updates) => {
currentState = { ...currentState, ...updates };
});
const stateMachine = new OAuthStateMachine(
sseUrl,
(updates) => {
currentState = { ...currentState, ...updates };
},
connectionType,
config,
);

while (
currentState.oauthStep !== "complete" &&
Expand Down Expand Up @@ -662,7 +667,7 @@
});
}
},
[sseUrl],

Check warning on line 670 in client/src/App.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has missing dependencies: 'config' and 'connectionType'. Either include them or remove the dependency array
);

useEffect(() => {
Expand Down Expand Up @@ -1264,6 +1269,8 @@
onBack={() => setIsAuthDebuggerVisible(false)}
authState={authState}
updateAuthState={updateAuthState}
connectionType={connectionType}
config={config}
/>
</TabsContent>
);
Expand Down
25 changes: 18 additions & 7 deletions client/src/components/AuthDebugger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import { OAuthStateMachine } from "../lib/oauth-state-machine";
import { SESSION_KEYS } from "../lib/constants";
import { validateRedirectUrl } from "@/utils/urlValidation";
import { InspectorConfig } from "../lib/configurationTypes";

export interface AuthDebuggerProps {
serverUrl: string;
onBack: () => void;
authState: AuthDebuggerState;
updateAuthState: (updates: Partial<AuthDebuggerState>) => void;
connectionType: "direct" | "proxy";
config: InspectorConfig;
}

interface StatusMessageProps {
Expand Down Expand Up @@ -60,6 +63,8 @@
onBack,
authState,
updateAuthState,
connectionType,
config,
}: AuthDebuggerProps) => {
// Check for existing tokens on mount
useEffect(() => {
Expand Down Expand Up @@ -103,8 +108,9 @@
}, [serverUrl, updateAuthState]);

const stateMachine = useMemo(
() => new OAuthStateMachine(serverUrl, updateAuthState),
[serverUrl, updateAuthState],
() =>
new OAuthStateMachine(serverUrl, updateAuthState, connectionType, config),
[serverUrl, updateAuthState, connectionType, config],
);

const proceedToNextStep = useCallback(async () => {
Expand Down Expand Up @@ -150,11 +156,16 @@
latestError: null,
};

const oauthMachine = new OAuthStateMachine(serverUrl, (updates) => {
// Update our temporary state during the process
currentState = { ...currentState, ...updates };
// But don't call updateAuthState yet
});
const oauthMachine = new OAuthStateMachine(
serverUrl,
(updates) => {
// Update our temporary state during the process
currentState = { ...currentState, ...updates };
// But don't call updateAuthState yet
},
connectionType,
config,
);

// Manually step through each stage of the OAuth flow
while (currentState.oauthStep !== "complete") {
Expand Down Expand Up @@ -214,7 +225,7 @@
} finally {
updateAuthState({ isInitiatingAuth: false });
}
}, [serverUrl, updateAuthState, authState]);

Check warning on line 228 in client/src/components/AuthDebugger.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has missing dependencies: 'config' and 'connectionType'. Either include them or remove the dependency array

const handleClearOAuth = useCallback(() => {
if (serverUrl) {
Expand Down
48 changes: 46 additions & 2 deletions client/src/lib/__tests__/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { discoverScopes } from "../auth";
import { discoverAuthorizationServerMetadata } from "@modelcontextprotocol/sdk/client/auth.js";
import { InspectorConfig } from "../configurationTypes";

jest.mock("@modelcontextprotocol/sdk/client/auth.js", () => ({
discoverAuthorizationServerMetadata: jest.fn(),
Expand All @@ -10,6 +11,39 @@ const mockDiscoverAuth =
typeof discoverAuthorizationServerMetadata
>;

const mockConfig: InspectorConfig = {
MCP_SERVER_REQUEST_TIMEOUT: {
label: "Request Timeout",
description: "Timeout for MCP requests",
value: 30000,
is_session_item: false,
},
MCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS: {
label: "Reset Timeout on Progress",
description: "Reset timeout on progress notifications",
value: true,
is_session_item: false,
},
MCP_REQUEST_MAX_TOTAL_TIMEOUT: {
label: "Max Total Timeout",
description: "Maximum total timeout",
value: 300000,
is_session_item: false,
},
MCP_PROXY_FULL_ADDRESS: {
label: "Proxy Address",
description: "Full address of the MCP proxy",
value: "http://localhost:6277",
is_session_item: false,
},
MCP_PROXY_AUTH_TOKEN: {
label: "Proxy Auth Token",
description: "Authentication token for the proxy",
value: "",
is_session_item: false,
},
};

const baseMetadata = {
issuer: "https://test.com",
authorization_endpoint: "https://test.com/authorize",
Expand Down Expand Up @@ -129,7 +163,12 @@ describe("discoverScopes", () => {
}) => {
mockDiscoverAuth.mockResolvedValue(mockResolves);

const result = await discoverScopes(serverUrl, resourceMetadata);
const result = await discoverScopes(
serverUrl,
"direct",
mockConfig,
resourceMetadata,
);

expect(result).toBe(expected);
if (expectedCallUrl) {
Expand All @@ -147,7 +186,12 @@ describe("discoverScopes", () => {
mockDiscoverAuth.mockResolvedValue(mockResolves);
}

const result = await discoverScopes(serverUrl, resourceMetadata);
const result = await discoverScopes(
serverUrl,
"direct",
mockConfig,
resourceMetadata,
);

expect(result).toBeUndefined();
},
Expand Down
Loading