mcp-remote 0.0.9 → 0.0.10-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,6 +61,10 @@ type UseMcpResult = {
61
61
  * @returns Auth URL that can be used to manually open a new window
62
62
  */
63
63
  authenticate: () => Promise<string | undefined>;
64
+ /**
65
+ * Clear all localStorage items for this server
66
+ */
67
+ clearStorage: () => void;
64
68
  };
65
69
  /**
66
70
  * useMcp is a React hook that connects to a remote MCP server, negotiates auth
@@ -36,6 +36,34 @@ var BrowserOAuthClientProvider = class {
36
36
  client_uri: this.clientUri
37
37
  };
38
38
  }
39
+ /**
40
+ * Clears all storage items related to this server
41
+ * @returns The number of items cleared
42
+ */
43
+ clearStorage() {
44
+ const prefix = `${this.storageKeyPrefix}_${this.serverUrlHash}`;
45
+ const keysToRemove = [];
46
+ for (let i = 0; i < localStorage.length; i++) {
47
+ const key = localStorage.key(i);
48
+ if (key && key.startsWith(prefix)) {
49
+ keysToRemove.push(key);
50
+ }
51
+ }
52
+ for (let i = 0; i < localStorage.length; i++) {
53
+ const key = localStorage.key(i);
54
+ if (key && key.startsWith(`${this.storageKeyPrefix}:state_`)) {
55
+ try {
56
+ const state = JSON.parse(localStorage.getItem(key) || "{}");
57
+ if (state.serverUrlHash === this.serverUrlHash) {
58
+ keysToRemove.push(key);
59
+ }
60
+ } catch (e) {
61
+ }
62
+ }
63
+ }
64
+ keysToRemove.forEach((key) => localStorage.removeItem(key));
65
+ return keysToRemove.length;
66
+ }
39
67
  hashString(str) {
40
68
  let hash = 0;
41
69
  for (let i = 0; i < str.length; i++) {
@@ -486,6 +514,18 @@ function useMcp(options) {
486
514
  }
487
515
  };
488
516
  }, [disconnect]);
517
+ const clearStorage = useCallback(() => {
518
+ if (!authProviderRef.current) {
519
+ addLog("warn", "Cannot clear storage: auth provider not initialized");
520
+ return;
521
+ }
522
+ const clearedCount = authProviderRef.current.clearStorage();
523
+ authUrlRef.current = void 0;
524
+ setAuthUrl(void 0);
525
+ metadataRef.current = void 0;
526
+ codeVerifierRef.current = void 0;
527
+ addLog("info", `Cleared ${clearedCount} storage items for server`);
528
+ }, [addLog]);
489
529
  return {
490
530
  state,
491
531
  tools,
@@ -495,7 +535,8 @@ function useMcp(options) {
495
535
  callTool,
496
536
  retry,
497
537
  disconnect,
498
- authenticate
538
+ authenticate,
539
+ clearStorage
499
540
  };
500
541
  }
501
542
  async function onMcpAuthorization(query, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-remote",
3
- "version": "0.0.9",
3
+ "version": "0.0.10-0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mcp-remote": "dist/cli/proxy.js"