Merge branch 'main' into playwright-test
This commit is contained in:
commit
86eaabe598
10 changed files with 41 additions and 28 deletions
|
|
@ -30,4 +30,4 @@ The project is organized as a monorepo with workspaces:
|
||||||
|
|
||||||
- `client/`: React frontend with Vite, TypeScript and Tailwind
|
- `client/`: React frontend with Vite, TypeScript and Tailwind
|
||||||
- `server/`: Express backend with TypeScript
|
- `server/`: Express backend with TypeScript
|
||||||
- `bin/`: CLI scripts
|
- `cli/`: Command-line interface for testing and invoking MCP server methods directly
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||||
"commander": "^13.1.0",
|
"commander": "^13.1.0",
|
||||||
"spawn-rx": "^5.1.2"
|
"spawn-rx": "^5.1.2"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
"cleanup:e2e": "node e2e/global-teardown.js"
|
"cleanup:e2e": "node e2e/global-teardown.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||||
"@radix-ui/react-checkbox": "^1.1.4",
|
"@radix-ui/react-checkbox": "^1.1.4",
|
||||||
"ajv": "^6.12.6",
|
"ajv": "^6.12.6",
|
||||||
"@radix-ui/react-dialog": "^1.1.3",
|
"@radix-ui/react-dialog": "^1.1.3",
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ export const OAuthFlowProgress = ({
|
||||||
{authState.resourceMetadataError && (
|
{authState.resourceMetadataError && (
|
||||||
<div className="mt-2 p-3 border border-blue-300 bg-blue-50 rounded-md">
|
<div className="mt-2 p-3 border border-blue-300 bg-blue-50 rounded-md">
|
||||||
<p className="text-sm font-medium text-blue-700">
|
<p className="text-sm font-medium text-blue-700">
|
||||||
ℹ️ No resource metadata available from{" "}
|
ℹ️ Problem with resource metadata from{" "}
|
||||||
<a
|
<a
|
||||||
href={
|
href={
|
||||||
new URL(
|
new URL(
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ jest.mock("@modelcontextprotocol/sdk/client/auth.js", () => ({
|
||||||
startAuthorization: jest.fn(),
|
startAuthorization: jest.fn(),
|
||||||
exchangeAuthorization: jest.fn(),
|
exchangeAuthorization: jest.fn(),
|
||||||
discoverOAuthProtectedResourceMetadata: jest.fn(),
|
discoverOAuthProtectedResourceMetadata: jest.fn(),
|
||||||
|
selectResourceURL: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Import the functions to get their types
|
// Import the functions to get their types
|
||||||
|
|
@ -88,7 +89,7 @@ describe("AuthDebugger", () => {
|
||||||
const defaultAuthState = EMPTY_DEBUGGER_STATE;
|
const defaultAuthState = EMPTY_DEBUGGER_STATE;
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
serverUrl: "https://example.com",
|
serverUrl: "https://example.com/mcp",
|
||||||
onBack: jest.fn(),
|
onBack: jest.fn(),
|
||||||
authState: defaultAuthState,
|
authState: defaultAuthState,
|
||||||
updateAuthState: jest.fn(),
|
updateAuthState: jest.fn(),
|
||||||
|
|
@ -203,7 +204,7 @@ describe("AuthDebugger", () => {
|
||||||
|
|
||||||
// Should first discover and save OAuth metadata
|
// Should first discover and save OAuth metadata
|
||||||
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
||||||
new URL("https://example.com"),
|
new URL("https://example.com/"),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check that updateAuthState was called with the right info message
|
// Check that updateAuthState was called with the right info message
|
||||||
|
|
@ -320,6 +321,7 @@ describe("AuthDebugger", () => {
|
||||||
isInitiatingAuth: false,
|
isInitiatingAuth: false,
|
||||||
resourceMetadata: null,
|
resourceMetadata: null,
|
||||||
resourceMetadataError: null,
|
resourceMetadataError: null,
|
||||||
|
resource: null,
|
||||||
oauthTokens: null,
|
oauthTokens: null,
|
||||||
oauthStep: "metadata_discovery",
|
oauthStep: "metadata_discovery",
|
||||||
latestError: null,
|
latestError: null,
|
||||||
|
|
@ -361,7 +363,7 @@ describe("AuthDebugger", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
||||||
new URL("https://example.com"),
|
new URL("https://example.com/"),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -496,11 +498,11 @@ describe("AuthDebugger", () => {
|
||||||
it("should successfully fetch and display protected resource metadata", async () => {
|
it("should successfully fetch and display protected resource metadata", async () => {
|
||||||
const updateAuthState = jest.fn();
|
const updateAuthState = jest.fn();
|
||||||
const mockResourceMetadata = {
|
const mockResourceMetadata = {
|
||||||
resource: "https://example.com/api",
|
resource: "https://example.com/mcp",
|
||||||
authorization_servers: ["https://custom-auth.example.com"],
|
authorization_servers: ["https://custom-auth.example.com"],
|
||||||
bearer_methods_supported: ["header", "body"],
|
bearer_methods_supported: ["header", "body"],
|
||||||
resource_documentation: "https://example.com/api/docs",
|
resource_documentation: "https://example.com/mcp/docs",
|
||||||
resource_policy_uri: "https://example.com/api/policy",
|
resource_policy_uri: "https://example.com/mcp/policy",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mock successful metadata discovery
|
// Mock successful metadata discovery
|
||||||
|
|
@ -538,7 +540,7 @@ describe("AuthDebugger", () => {
|
||||||
// Wait for the metadata to be fetched
|
// Wait for the metadata to be fetched
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(mockDiscoverOAuthProtectedResourceMetadata).toHaveBeenCalledWith(
|
expect(mockDiscoverOAuthProtectedResourceMetadata).toHaveBeenCalledWith(
|
||||||
"https://example.com",
|
"https://example.com/mcp",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -584,7 +586,7 @@ describe("AuthDebugger", () => {
|
||||||
// Wait for the metadata fetch to fail
|
// Wait for the metadata fetch to fail
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(mockDiscoverOAuthProtectedResourceMetadata).toHaveBeenCalledWith(
|
expect(mockDiscoverOAuthProtectedResourceMetadata).toHaveBeenCalledWith(
|
||||||
"https://example.com",
|
"https://example.com/mcp",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -594,7 +596,7 @@ describe("AuthDebugger", () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
resourceMetadataError: mockError,
|
resourceMetadataError: mockError,
|
||||||
// Should use the original server URL as fallback
|
// Should use the original server URL as fallback
|
||||||
authServerUrl: new URL("https://example.com"),
|
authServerUrl: new URL("https://example.com/"),
|
||||||
oauthStep: "client_registration",
|
oauthStep: "client_registration",
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -602,7 +604,7 @@ describe("AuthDebugger", () => {
|
||||||
|
|
||||||
// Verify that regular OAuth metadata discovery was still called
|
// Verify that regular OAuth metadata discovery was still called
|
||||||
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
||||||
new URL("https://example.com"),
|
new URL("https://example.com/"),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ export interface AuthDebuggerState {
|
||||||
oauthStep: OAuthStep;
|
oauthStep: OAuthStep;
|
||||||
resourceMetadata: OAuthProtectedResourceMetadata | null;
|
resourceMetadata: OAuthProtectedResourceMetadata | null;
|
||||||
resourceMetadataError: Error | null;
|
resourceMetadataError: Error | null;
|
||||||
|
resource: URL | null;
|
||||||
authServerUrl: URL | null;
|
authServerUrl: URL | null;
|
||||||
oauthMetadata: OAuthMetadata | null;
|
oauthMetadata: OAuthMetadata | null;
|
||||||
oauthClientInfo: OAuthClientInformationFull | OAuthClientInformation | null;
|
oauthClientInfo: OAuthClientInformationFull | OAuthClientInformation | null;
|
||||||
|
|
@ -47,6 +48,7 @@ export const EMPTY_DEBUGGER_STATE: AuthDebuggerState = {
|
||||||
oauthMetadata: null,
|
oauthMetadata: null,
|
||||||
resourceMetadata: null,
|
resourceMetadata: null,
|
||||||
resourceMetadataError: null,
|
resourceMetadataError: null,
|
||||||
|
resource: null,
|
||||||
authServerUrl: null,
|
authServerUrl: null,
|
||||||
oauthClientInfo: null,
|
oauthClientInfo: null,
|
||||||
authorizationUrl: null,
|
authorizationUrl: null,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
startAuthorization,
|
startAuthorization,
|
||||||
exchangeAuthorization,
|
exchangeAuthorization,
|
||||||
discoverOAuthProtectedResourceMetadata,
|
discoverOAuthProtectedResourceMetadata,
|
||||||
|
selectResourceURL,
|
||||||
} from "@modelcontextprotocol/sdk/client/auth.js";
|
} from "@modelcontextprotocol/sdk/client/auth.js";
|
||||||
import {
|
import {
|
||||||
OAuthMetadataSchema,
|
OAuthMetadataSchema,
|
||||||
|
|
@ -29,17 +30,15 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
metadata_discovery: {
|
metadata_discovery: {
|
||||||
canTransition: async () => true,
|
canTransition: async () => true,
|
||||||
execute: async (context) => {
|
execute: async (context) => {
|
||||||
let authServerUrl = new URL(context.serverUrl);
|
// Default to discovering from the server's URL
|
||||||
|
let authServerUrl = new URL("/", context.serverUrl);
|
||||||
let resourceMetadata: OAuthProtectedResourceMetadata | null = null;
|
let resourceMetadata: OAuthProtectedResourceMetadata | null = null;
|
||||||
let resourceMetadataError: Error | null = null;
|
let resourceMetadataError: Error | null = null;
|
||||||
try {
|
try {
|
||||||
resourceMetadata = await discoverOAuthProtectedResourceMetadata(
|
resourceMetadata = await discoverOAuthProtectedResourceMetadata(
|
||||||
context.serverUrl,
|
context.serverUrl,
|
||||||
);
|
);
|
||||||
if (
|
if (resourceMetadata?.authorization_servers?.length) {
|
||||||
resourceMetadata &&
|
|
||||||
resourceMetadata.authorization_servers?.length
|
|
||||||
) {
|
|
||||||
authServerUrl = new URL(resourceMetadata.authorization_servers[0]);
|
authServerUrl = new URL(resourceMetadata.authorization_servers[0]);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -50,6 +49,13 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const resource: URL | undefined = await selectResourceURL(
|
||||||
|
context.serverUrl,
|
||||||
|
context.provider,
|
||||||
|
// we default to null, so swap it for undefined if not set
|
||||||
|
resourceMetadata ?? undefined,
|
||||||
|
);
|
||||||
|
|
||||||
const metadata = await discoverOAuthMetadata(authServerUrl);
|
const metadata = await discoverOAuthMetadata(authServerUrl);
|
||||||
if (!metadata) {
|
if (!metadata) {
|
||||||
throw new Error("Failed to discover OAuth metadata");
|
throw new Error("Failed to discover OAuth metadata");
|
||||||
|
|
@ -58,6 +64,7 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
context.provider.saveServerMetadata(parsedMetadata);
|
context.provider.saveServerMetadata(parsedMetadata);
|
||||||
context.updateState({
|
context.updateState({
|
||||||
resourceMetadata,
|
resourceMetadata,
|
||||||
|
resource,
|
||||||
resourceMetadataError,
|
resourceMetadataError,
|
||||||
authServerUrl,
|
authServerUrl,
|
||||||
oauthMetadata: parsedMetadata,
|
oauthMetadata: parsedMetadata,
|
||||||
|
|
@ -113,6 +120,7 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
clientInformation,
|
clientInformation,
|
||||||
redirectUrl: context.provider.redirectUrl,
|
redirectUrl: context.provider.redirectUrl,
|
||||||
scope,
|
scope,
|
||||||
|
resource: context.state.resource ?? undefined,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -163,6 +171,7 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
authorizationCode: context.state.authorizationCode,
|
authorizationCode: context.state.authorizationCode,
|
||||||
codeVerifier,
|
codeVerifier,
|
||||||
redirectUri: context.provider.redirectUrl,
|
redirectUri: context.provider.redirectUrl,
|
||||||
|
resource: context.state.resource ?? undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
context.provider.saveTokens(tokens);
|
context.provider.saveTokens(tokens);
|
||||||
|
|
|
||||||
14
package-lock.json
generated
14
package-lock.json
generated
|
|
@ -17,7 +17,7 @@
|
||||||
"@modelcontextprotocol/inspector-cli": "^0.14.3",
|
"@modelcontextprotocol/inspector-cli": "^0.14.3",
|
||||||
"@modelcontextprotocol/inspector-client": "^0.14.3",
|
"@modelcontextprotocol/inspector-client": "^0.14.3",
|
||||||
"@modelcontextprotocol/inspector-server": "^0.14.3",
|
"@modelcontextprotocol/inspector-server": "^0.14.3",
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.1",
|
||||||
"concurrently": "^9.0.1",
|
"concurrently": "^9.0.1",
|
||||||
"open": "^10.1.0",
|
"open": "^10.1.0",
|
||||||
"shell-quote": "^1.8.2",
|
"shell-quote": "^1.8.2",
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
"version": "0.14.3",
|
"version": "0.14.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||||
"commander": "^13.1.0",
|
"commander": "^13.1.0",
|
||||||
"spawn-rx": "^5.1.2"
|
"spawn-rx": "^5.1.2"
|
||||||
},
|
},
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
"version": "0.14.3",
|
"version": "0.14.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||||
"@radix-ui/react-checkbox": "^1.1.4",
|
"@radix-ui/react-checkbox": "^1.1.4",
|
||||||
"@radix-ui/react-dialog": "^1.1.3",
|
"@radix-ui/react-dialog": "^1.1.3",
|
||||||
"@radix-ui/react-icons": "^1.3.0",
|
"@radix-ui/react-icons": "^1.3.0",
|
||||||
|
|
@ -2006,9 +2006,9 @@
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@modelcontextprotocol/sdk": {
|
"node_modules/@modelcontextprotocol/sdk": {
|
||||||
"version": "1.12.1",
|
"version": "1.13.1",
|
||||||
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.12.1.tgz",
|
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.13.1.tgz",
|
||||||
"integrity": "sha512-KG1CZhZfWg+u8pxeM/mByJDScJSrjjxLc8fwQqbsS8xCjBmQfMNEBTotYdNanKekepnfRI85GtgQlctLFpcYPw==",
|
"integrity": "sha512-8q6+9aF0yA39/qWT/uaIj6zTpC+Qu07DnN/lb9mjoquCJsAh6l3HyYqc9O3t2j7GilseOQOQimLg7W3By6jqvg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ajv": "^6.12.6",
|
"ajv": "^6.12.6",
|
||||||
"content-type": "^1.0.5",
|
"content-type": "^1.0.5",
|
||||||
|
|
@ -10987,7 +10987,7 @@
|
||||||
"version": "0.14.3",
|
"version": "0.14.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"ws": "^8.18.0",
|
"ws": "^8.18.0",
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
"@modelcontextprotocol/inspector-cli": "^0.14.3",
|
"@modelcontextprotocol/inspector-cli": "^0.14.3",
|
||||||
"@modelcontextprotocol/inspector-client": "^0.14.3",
|
"@modelcontextprotocol/inspector-client": "^0.14.3",
|
||||||
"@modelcontextprotocol/inspector-server": "^0.14.3",
|
"@modelcontextprotocol/inspector-server": "^0.14.3",
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.1",
|
||||||
"concurrently": "^9.0.1",
|
"concurrently": "^9.0.1",
|
||||||
"open": "^10.1.0",
|
"open": "^10.1.0",
|
||||||
"shell-quote": "^1.8.2",
|
"shell-quote": "^1.8.2",
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"ws": "^8.18.0",
|
"ws": "^8.18.0",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue