From 207fc8692e067a49aeff7a2af505c71f8b2ed326 Mon Sep 17 00:00:00 2001 From: Glen Maddern Date: Mon, 5 May 2025 17:01:50 +1000 Subject: [PATCH] wip --- package.json | 10 +++++++--- pnpm-lock.yaml | 19 ++++++++++--------- src/auth/browser-provider.ts | 1 + src/auth/callback.ts | 1 + src/react/useMcp.ts | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 76e4e04..0ae5423 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,11 @@ "LICENSE" ], "exports": { + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/index.js", + "import": "./dist/index.js" + }, "./react": { "types": "./dist/react/index.d.ts", "require": "./dist/react/index.js", @@ -20,7 +25,7 @@ "check": "prettier --check . && tsc" }, "dependencies": { - "@modelcontextprotocol/sdk": "^1.7.0" + "@modelcontextprotocol/sdk": "^1.11.0" }, "devDependencies": { "@types/react": "^19.0.12", @@ -32,8 +37,7 @@ }, "tsup": { "entry": [ - "src/cli/client.ts", - "src/cli/proxy.ts", + "src/index.ts", "src/react/index.ts" ], "format": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 760b451..f11d45d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@modelcontextprotocol/sdk': - specifier: ^1.7.0 - version: 1.7.0 + specifier: ^1.11.0 + version: 1.11.0 devDependencies: '@types/react': specifier: ^19.0.12 @@ -205,8 +205,8 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@modelcontextprotocol/sdk@1.7.0': - resolution: {integrity: sha512-IYPe/FLpvF3IZrd/f5p5ffmWhMc3aEMuM2wGJASDqC2Ge7qatVCdbfPx3n/5xFeb19xN0j/911M2AaFuircsWA==} + '@modelcontextprotocol/sdk@1.11.0': + resolution: {integrity: sha512-k/1pb70eD638anoi0e8wUGAlbMJXyvdV4p62Ko+EZ7eBe1xMx8Uhak1R5DgfoofsK5IBBnRwsYGTaLZl+6/+RQ==} engines: {node: '>=18'} '@pkgjs/parseargs@0.11.0': @@ -717,8 +717,8 @@ packages: resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} engines: {node: '>= 6'} - pkce-challenge@4.1.0: - resolution: {integrity: sha512-ZBmhE1C9LcPoH9XZSdwiPtbPHZROwAnMy+kIFQVrnMCxY4Cudlz3gBOpzilgc0jOgRaiT3sIWfpMomW2ar2orQ==} + pkce-challenge@5.0.0: + resolution: {integrity: sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==} engines: {node: '>=16.20.0'} postcss-load-config@6.0.1: @@ -1072,14 +1072,15 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - '@modelcontextprotocol/sdk@1.7.0': + '@modelcontextprotocol/sdk@1.11.0': dependencies: content-type: 1.0.5 cors: 2.8.5 + cross-spawn: 7.0.6 eventsource: 3.0.5 express: 5.0.1 express-rate-limit: 7.5.0(express@5.0.1) - pkce-challenge: 4.1.0 + pkce-challenge: 5.0.0 raw-body: 3.0.0 zod: 3.24.2 zod-to-json-schema: 3.24.5(zod@3.24.2) @@ -1543,7 +1544,7 @@ snapshots: pirates@4.0.6: {} - pkce-challenge@4.1.0: {} + pkce-challenge@5.0.0: {} postcss-load-config@6.0.1(tsx@4.19.3): dependencies: diff --git a/src/auth/browser-provider.ts b/src/auth/browser-provider.ts index 329098e..6ab96c2 100644 --- a/src/auth/browser-provider.ts +++ b/src/auth/browser-provider.ts @@ -186,6 +186,7 @@ export class BrowserOAuthClientProvider implements OAuthClientProvider { * @param options Configuration for the popup window. * @returns An object indicating success, whether the popup was potentially blocked, and the URL used. */ + // @ts-ignore async redirectToAuthorization( authorizationUrl: URL, metadata: OAuthMetadata, diff --git a/src/auth/callback.ts b/src/auth/callback.ts index 0779a37..8ffa702 100644 --- a/src/auth/callback.ts +++ b/src/auth/callback.ts @@ -103,6 +103,7 @@ export async function onMcpAuthorization( authorizationCode: code, codeVerifier, // redirectUrl is typically required by the token endpoint for verification + // @ts-ignore redirectUrl: new URL('/oauth/callback', window.location.origin).toString(), // TODO: Make this configurable or get from provider instance? }); diff --git a/src/react/useMcp.ts b/src/react/useMcp.ts index 8ca250b..1fa2aa3 100644 --- a/src/react/useMcp.ts +++ b/src/react/useMcp.ts @@ -53,7 +53,7 @@ export function useMcp(options: UseMcpOptions): UseMcpResult { const addLog = useCallback( (level: UseMcpResult['log'][0]['level'], message: string, ...args: unknown[]) => { - if (level === 'debug' && !debug) return; + // if (level === 'debug' && !debug) return; const fullMessage = args.length > 0 ? `${message} ${args.map(arg => JSON.stringify(arg)).join(' ')}` : message; console[level](`[useMcp] ${fullMessage}`); @@ -507,7 +507,7 @@ export function useMcp(options: UseMcpOptions): UseMcpResult { addLog('debug', 'Auth callback message listener removed.'); clearTimeout(authTimeoutRef.current!); }; - }, [addLog, failConnection, disconnect, connect]); // Dependencies: functions that handle success/failure + }, [addLog, failConnection, disconnect, connect, authTimeoutRef, isMountedRef]); // Dependencies: functions that handle success/failure // Effect for initial connection and auto-retry useEffect(() => {