mcp-remote 0.0.9 → 0.0.10-1

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.
@@ -29,7 +29,7 @@ var NodeOAuthClientProvider = class {
29
29
  clientName;
30
30
  clientUri;
31
31
  get redirectUrl() {
32
- return `http://localhost:${this.options.callbackPort}${this.callbackPath}`;
32
+ return `http://127.0.0.1:${this.options.callbackPort}${this.callbackPath}`;
33
33
  }
34
34
  get clientMetadata() {
35
35
  return {
@@ -193,7 +193,7 @@ function setupOAuthCallbackServer(options) {
193
193
  options.events.emit("auth-code-received", code);
194
194
  });
195
195
  const server = app.listen(options.port, () => {
196
- console.error(`OAuth callback server running at http://localhost:${options.port}`);
196
+ console.error(`OAuth callback server running at http://127.0.0.1:${options.port}`);
197
197
  });
198
198
  const waitForAuthCode = () => {
199
199
  return new Promise((resolve) => {
@@ -235,7 +235,7 @@ async function parseCommandLineArgs(args, defaultPort, usage) {
235
235
  process.exit(1);
236
236
  }
237
237
  const url = new URL(serverUrl);
238
- const isLocalhost = url.hostname === "localhost" && url.protocol === "http:";
238
+ const isLocalhost = (url.hostname === "localhost" || url.hostname === "127.0.0.1") && url.protocol === "http:";
239
239
  if (!(url.protocol == "https:" || isLocalhost)) {
240
240
  console.error(usage);
241
241
  process.exit(1);
@@ -4,7 +4,7 @@ import {
4
4
  parseCommandLineArgs,
5
5
  setupOAuthCallbackServer,
6
6
  setupSignalHandlers
7
- } from "../chunk-4ROPBD3M.js";
7
+ } from "../chunk-S3VO5IXF.js";
8
8
 
9
9
  // src/cli/client.ts
10
10
  import { EventEmitter } from "events";
package/dist/cli/proxy.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  parseCommandLineArgs,
5
5
  setupOAuthCallbackServer,
6
6
  setupSignalHandlers
7
- } from "../chunk-4ROPBD3M.js";
7
+ } from "../chunk-S3VO5IXF.js";
8
8
 
9
9
  // src/cli/proxy.ts
10
10
  import { EventEmitter } from "events";
@@ -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-1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mcp-remote": "dist/cli/proxy.js"