@mcp-use/client 2.0.0-beta.16 → 2.0.0-beta.17

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.
Files changed (65) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/auth/browser.d.ts +51 -2
  3. package/dist/auth/browser.d.ts.map +1 -1
  4. package/dist/auth/node.d.ts +99 -4
  5. package/dist/auth/node.d.ts.map +1 -1
  6. package/dist/auth/session-store.d.ts +6 -0
  7. package/dist/auth/session-store.d.ts.map +1 -1
  8. package/dist/core/base.d.ts +4 -8
  9. package/dist/core/base.d.ts.map +1 -1
  10. package/dist/core/browser.d.ts +14 -2
  11. package/dist/core/browser.d.ts.map +1 -1
  12. package/dist/core/config.d.ts +82 -20
  13. package/dist/core/config.d.ts.map +1 -1
  14. package/dist/core/node.d.ts +7 -10
  15. package/dist/core/node.d.ts.map +1 -1
  16. package/dist/core/session.d.ts +18 -4
  17. package/dist/core/session.d.ts.map +1 -1
  18. package/dist/index-browser.d.ts +1 -0
  19. package/dist/index-browser.d.ts.map +1 -1
  20. package/dist/index-browser.js +142 -21
  21. package/dist/index-browser.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +218 -31
  24. package/dist/index.js.map +1 -1
  25. package/dist/react/McpClientProvider.d.ts +22 -10
  26. package/dist/react/McpClientProvider.d.ts.map +1 -1
  27. package/dist/react/index.d.ts +2 -0
  28. package/dist/react/index.d.ts.map +1 -1
  29. package/dist/react/index.js +164 -21
  30. package/dist/react/index.js.map +1 -1
  31. package/dist/react/rpc-logger.d.ts +5 -0
  32. package/dist/react/rpc-logger.d.ts.map +1 -1
  33. package/dist/react/storage.d.ts +47 -0
  34. package/dist/react/storage.d.ts.map +1 -1
  35. package/dist/react/types.d.ts +107 -16
  36. package/dist/react/types.d.ts.map +1 -1
  37. package/dist/react/useMcp-operations.d.ts.map +1 -1
  38. package/dist/react/view/ViewRenderer.d.ts +7 -0
  39. package/dist/react/view/ViewRenderer.d.ts.map +1 -1
  40. package/dist/react/view/parse-custom-props.d.ts +8 -0
  41. package/dist/react/view/parse-custom-props.d.ts.map +1 -1
  42. package/dist/react/view/resolve-view-resource.d.ts +10 -0
  43. package/dist/react/view/resolve-view-resource.d.ts.map +1 -1
  44. package/dist/react/view/types.d.ts +89 -0
  45. package/dist/react/view/types.d.ts.map +1 -1
  46. package/dist/react/view/view-detection.d.ts +18 -0
  47. package/dist/react/view/view-detection.d.ts.map +1 -1
  48. package/dist/react/view/view-host-policy.d.ts +35 -0
  49. package/dist/react/view/view-host-policy.d.ts.map +1 -1
  50. package/dist/telemetry/telemetry.d.ts +5 -1
  51. package/dist/telemetry/telemetry.d.ts.map +1 -1
  52. package/dist/transport/base.d.ts +85 -13
  53. package/dist/transport/base.d.ts.map +1 -1
  54. package/dist/transport/connection-manager.d.ts +1 -1
  55. package/dist/transport/http.d.ts +51 -2
  56. package/dist/transport/http.d.ts.map +1 -1
  57. package/dist/transport/stdio.d.ts +29 -1
  58. package/dist/transport/stdio.d.ts.map +1 -1
  59. package/dist/utils/elicitation.d.ts +4 -2
  60. package/dist/utils/elicitation.d.ts.map +1 -1
  61. package/dist/utils/logging.d.ts +1 -0
  62. package/dist/utils/logging.d.ts.map +1 -1
  63. package/dist/utils/version.d.ts +6 -0
  64. package/dist/utils/version.d.ts.map +1 -1
  65. package/package.json +4 -4
@@ -7,6 +7,7 @@ import type { McpServer, McpServerConfig, PendingElicitationRequest, PendingSamp
7
7
  * Context value for multi-server management
8
8
  */
9
9
  export interface McpClientContextType {
10
+ /** Managed servers and their current reactive state. */
10
11
  servers: McpServer[];
11
12
  /** Idempotent — safe to call multiple times with the same id; duplicates are silently ignored. */
12
13
  addServer: (id: string, config: McpServerConfig) => void;
@@ -24,10 +25,13 @@ export interface McpClientContextType {
24
25
  removeServer: (id: string, opts?: {
25
26
  clearCredentials?: boolean;
26
27
  }) => Promise<void>;
28
+ /** Updates cached presentation metadata for a managed server. */
27
29
  updateServerMetadata: (id: string, metadata: {
28
30
  name: string;
29
31
  }) => Promise<void>;
32
+ /** Merges configuration changes into a managed server. */
30
33
  updateServer: (id: string, options: Partial<McpServerConfig>) => Promise<void>;
34
+ /** Returns a managed server by ID. */
31
35
  getServer: (id: string) => McpServer | undefined;
32
36
  /** Whether storage has finished loading (true if no storage provider) */
33
37
  storageLoaded: boolean;
@@ -36,6 +40,7 @@ export interface McpClientContextType {
36
40
  * Props for McpClientProvider
37
41
  */
38
42
  export interface McpClientProviderProps {
43
+ /** React subtree that can access the MCP client context. */
39
44
  children: ReactNode;
40
45
  /**
41
46
  * Initial servers configuration (like Python MCPClient.from_dict)
@@ -57,7 +62,9 @@ export interface McpClientProviderProps {
57
62
  * Can be overridden per-server in addServer() options
58
63
  */
59
64
  defaultProxyConfig?: {
65
+ /** Default MCP proxy endpoint. */
60
66
  proxyAddress?: string;
67
+ /** Default headers sent to the MCP proxy. */
61
68
  headers?: Record<string, string>;
62
69
  };
63
70
  /**
@@ -67,7 +74,9 @@ export interface McpClientProviderProps {
67
74
  * @defaultValue false
68
75
  */
69
76
  defaultAutoProxyFallback?: boolean | {
77
+ /** Whether automatic proxy fallback is enabled. */
70
78
  enabled?: boolean;
79
+ /** Proxy endpoint used after direct connection fails. */
71
80
  proxyAddress?: string;
72
81
  };
73
82
  /**
@@ -95,8 +104,11 @@ export interface McpClientProviderProps {
95
104
  description?: string;
96
105
  /** Client icons (first icon used as logo_uri for OAuth) */
97
106
  icons?: Array<{
107
+ /** Icon URL. */
98
108
  src: string;
109
+ /** Icon media type. */
99
110
  mimeType?: string;
111
+ /** Supported icon sizes, such as `"48x48"`. */
100
112
  sizes?: string[];
101
113
  }>;
102
114
  /** Client website URL (used as client_uri for OAuth) */
@@ -143,20 +155,20 @@ export interface McpClientProviderProps {
143
155
  onServerStateChange?: (id: string, state: McpServer["state"]) => void;
144
156
  /**
145
157
  * Callback when a sampling request is received from any server
146
- * @param request The sampling request details
147
- * @param serverId The ID of the server that sent the request
148
- * @param serverName The name of the server
149
- * @param approve Function to approve the request
150
- * @param reject Function to reject the request
158
+ * @param request - The sampling request details
159
+ * @param serverId - The ID of the server that sent the request
160
+ * @param serverName - The name of the server
161
+ * @param approve - Function to approve the request
162
+ * @param reject - Function to reject the request
151
163
  */
152
164
  onSamplingRequest?: (request: PendingSamplingRequest, serverId: string, serverName: string, approve: (requestId: string, result: SamplingCreateMessageResult) => void, reject: (requestId: string, error?: string) => void) => void;
153
165
  /**
154
166
  * Callback when an elicitation request is received from any server
155
- * @param request The elicitation request details
156
- * @param serverId The ID of the server that sent the request
157
- * @param serverName The name of the server
158
- * @param approve Function to approve the request
159
- * @param reject Function to reject the request
167
+ * @param request - The elicitation request details
168
+ * @param serverId - The ID of the server that sent the request
169
+ * @param serverName - The name of the server
170
+ * @param approve - Function to approve the request
171
+ * @param reject - Function to reject the request
160
172
  */
161
173
  onElicitationRequest?: (request: PendingElicitationRequest, serverId: string, serverName: string, approve: (requestId: string, result: ElicitResult) => void, reject: (requestId: string, error?: string) => void) => void;
162
174
  }
@@ -1 +1 @@
1
- {"version":3,"file":"McpClientProvider.d.ts","sourceRoot":"","sources":["../../src/react/McpClientProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,EAQZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,yBAAyB,EACzB,sBAAsB,EAEvB,MAAM,YAAY,CAAC;AAUpB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,kGAAkG;IAClG,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,eA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AAC;IAEV;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,CACrB,OAAO,EAAE,yBAAyB,EAClC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,EAC1D,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,KAChD,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAgC,EAChC,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,gBAAwB,EACxB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,EAAE,sBAAsB,qBAojBxB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,YAAY,IAAI,oBAAoB,CAMnD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAM9D"}
1
+ {"version":3,"file":"McpClientProvider.d.ts","sourceRoot":"","sources":["../../src/react/McpClientProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,EAQZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,yBAAyB,EACzB,sBAAsB,EAEvB,MAAM,YAAY,CAAC;AAUpB;;GAEG;A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K,IAAI,CAAC;IAEtE;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,CAClB,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,2BAA2B,KAAK,IAAI,EACzE,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,KAChD,IAAI,CAAC;IAEV;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,CACrB,OAAO,EAAE,yBAAyB,EAClC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,EAC1D,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,KAChD,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAgC,EAChC,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,gBAAwB,EACxB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,EAAE,sBAAsB,qBAojBxB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,YAAY,IAAI,oBAAoB,CAMnD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAM9D"}
@@ -18,7 +18,9 @@ export type { SamplingCreateMessageParams, SamplingCreateMessageResult, } from "
18
18
  import type { SamplingCreateMessageParams, SamplingCreateMessageResult } from "../core/config.js";
19
19
  /** JSON-RPC envelope for `sampling/createMessage`. */
20
20
  export type SamplingCreateMessageRequest = {
21
+ /** JSON-RPC method name. */
21
22
  method: "sampling/createMessage";
23
+ /** Sampling request parameters. */
22
24
  params: SamplingCreateMessageParams;
23
25
  };
24
26
  /** @deprecated Use {@link SamplingCreateMessageRequest}. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,eAAe;AACf,sCAAsC;AACtC,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EACL,GAAG,EACH,SAAS,EACT,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAG3C,YAAY,EACV,cAAc,EACd,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,QAAQ,EACR,oBAAoB,EACpB,IAAI,EACJ,SAAS,GACV,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,sDAAsD;AACtD,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,2BAA2B,CAAC;CACrC,CAAC;AACF,4DAA4D;AAC5D,YAAY,EAAE,4BAA4B,IAAI,oBAAoB,EAAE,CAAC;AACrE,2DAA2D;AAC3D,YAAY,EAAE,2BAA2B,IAAI,mBAAmB,EAAE,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,GAC1C,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,eAAe;AACf,sC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EACL,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,GAC1C,MAAM,wBAAwB,CAAC"}
@@ -517,6 +517,11 @@ var BaseConnector = class {
517
517
  notificationHandlers = [];
518
518
  rootsCache = [];
519
519
  activeProgressHandlers = /* @__PURE__ */ new Set();
520
+ /**
521
+ * Creates a connector with shared SDK and callback options.
522
+ *
523
+ * @param opts - Connector initialization options.
524
+ */
520
525
  constructor(opts = {}) {
521
526
  this.opts = opts;
522
527
  if (opts.roots) {
@@ -699,7 +704,9 @@ var BaseConnector = class {
699
704
  }
700
705
  }
701
706
  /**
702
- * Get the current roots.
707
+ * Returns the roots currently advertised to the server.
708
+ *
709
+ * @returns A copy of the configured roots.
703
710
  */
704
711
  getRoots() {
705
712
  return [...this.rootsCache];
@@ -768,7 +775,11 @@ var BaseConnector = class {
768
775
  "setupElicitationHandler: Elicitation handler registered successfully"
769
776
  );
770
777
  }
771
- /** Disconnect and release resources. */
778
+ /**
779
+ * Disconnects the SDK client and releases transport resources.
780
+ *
781
+ * @returns A promise that resolves after cleanup completes.
782
+ */
772
783
  async disconnect() {
773
784
  if (!this.connected) {
774
785
  logger.debug("Not connected to MCP implementation");
@@ -779,7 +790,7 @@ var BaseConnector = class {
779
790
  this.connected = false;
780
791
  logger.debug("Disconnected from MCP implementation");
781
792
  }
782
- /** Check if the client is connected */
793
+ /** Whether an SDK client currently exists for this connector. */
783
794
  get isClientConnected() {
784
795
  return this.client != null;
785
796
  }
@@ -789,6 +800,10 @@ var BaseConnector = class {
789
800
  * In the SDK, `Client.connect(transport)` automatically performs the
790
801
  * protocol‑level `initialize` handshake, so we only need to cache the list of
791
802
  * tools and expose some server info.
803
+ *
804
+ * @param defaultRequestOptions - Options used while fetching the initial tool list.
805
+ * @returns The capabilities advertised by the server.
806
+ * @throws When {@link BaseConnector.connect} has not completed.
792
807
  */
793
808
  async initialize(defaultRequestOptions = this.opts.defaultRequestOptions ?? {}) {
794
809
  if (!this.client) {
@@ -826,18 +841,22 @@ var BaseConnector = class {
826
841
  logger.debug("Server info:", serverInfo);
827
842
  return capabilities;
828
843
  }
829
- /** Lazily expose the cached tools list. */
844
+ /**
845
+ * Returns the tool list cached during initialization.
846
+ *
847
+ * @throws When {@link BaseConnector.initialize} has not completed.
848
+ */
830
849
  get tools() {
831
850
  if (!this.toolsCache) {
832
851
  throw new Error("MCP client is not initialized; call initialize() first");
833
852
  }
834
853
  return this.toolsCache;
835
854
  }
836
- /** Expose cached server capabilities. */
855
+ /** Capabilities cached during initialization, or an empty object. */
837
856
  get serverCapabilities() {
838
857
  return this.capabilitiesCache || {};
839
858
  }
840
- /** Expose cached server info. */
859
+ /** Server identity cached during initialization, or `null`. */
841
860
  get serverInfo() {
842
861
  return this.serverInfoCache;
843
862
  }
@@ -858,7 +877,15 @@ var BaseConnector = class {
858
877
  get negotiatedProtocolVersion() {
859
878
  return this.client?.getNegotiatedProtocolVersion?.();
860
879
  }
861
- /** Call a tool on the server. */
880
+ /**
881
+ * Calls a tool on the connected server.
882
+ *
883
+ * @param name - Tool name.
884
+ * @param args - Tool arguments.
885
+ * @param options - Per-request timeout, cancellation, and progress options.
886
+ * @returns The tool result returned by the server.
887
+ * @throws When the connector is not connected or the tool call fails.
888
+ */
862
889
  async callTool(name, args, options) {
863
890
  if (!this.client) {
864
891
  throw new Error("MCP client is not connected");
@@ -983,7 +1010,13 @@ var BaseConnector = class {
983
1010
  );
984
1011
  return result;
985
1012
  }
986
- /** Read a resource by URI. */
1013
+ /**
1014
+ * Reads a resource by URI.
1015
+ *
1016
+ * @param uri - Resource URI to read.
1017
+ * @param options - Per-request options.
1018
+ * @returns The resource contents returned by the server.
1019
+ */
987
1020
  async readResource(uri, options) {
988
1021
  if (!this.client) {
989
1022
  throw new Error("MCP client is not connected");
@@ -1018,6 +1051,11 @@ var BaseConnector = class {
1018
1051
  logger.debug(`Unsubscribing from resource: ${uri}`);
1019
1052
  return await this.client.unsubscribeResource({ uri }, options);
1020
1053
  }
1054
+ /**
1055
+ * Lists prompts exposed by the server.
1056
+ *
1057
+ * @returns The prompt list, or an empty list when prompts are unsupported.
1058
+ */
1021
1059
  async listPrompts() {
1022
1060
  if (!this.client) {
1023
1061
  throw new Error("MCP client is not connected");
@@ -1038,6 +1076,13 @@ var BaseConnector = class {
1038
1076
  throw err;
1039
1077
  }
1040
1078
  }
1079
+ /**
1080
+ * Gets a prompt with the supplied arguments.
1081
+ *
1082
+ * @param name - Prompt name.
1083
+ * @param args - Prompt arguments.
1084
+ * @returns The rendered prompt returned by the server.
1085
+ */
1041
1086
  async getPrompt(name, args) {
1042
1087
  if (!this.client) {
1043
1088
  throw new Error("MCP client is not connected");
@@ -1045,7 +1090,14 @@ var BaseConnector = class {
1045
1090
  logger.debug(`Getting prompt ${name}`);
1046
1091
  return await this.client.getPrompt({ name, arguments: args });
1047
1092
  }
1048
- /** Send a raw request through the client. */
1093
+ /**
1094
+ * Sends a raw, potentially non-standard request through the SDK client.
1095
+ *
1096
+ * @param method - JSON-RPC method name.
1097
+ * @param params - Request parameters. Defaults to an empty object.
1098
+ * @param options - Per-request options.
1099
+ * @returns The unvalidated result returned by the server.
1100
+ */
1049
1101
  async request(method, params = null, options) {
1050
1102
  if (!this.client) {
1051
1103
  throw new Error("MCP client is not connected");
@@ -1144,6 +1196,12 @@ var HttpConnector = class extends BaseConnector {
1144
1196
  reconnectionOptions;
1145
1197
  transportType = null;
1146
1198
  streamableTransport = null;
1199
+ /**
1200
+ * Creates an HTTP connector.
1201
+ *
1202
+ * @param baseUrl - MCP endpoint URL.
1203
+ * @param opts - Authentication, transport, SDK, and reconnection options.
1204
+ */
1147
1205
  constructor(baseUrl, opts = {}) {
1148
1206
  super(opts);
1149
1207
  const originalUrl = baseUrl.replace(/\/$/, "");
@@ -1261,7 +1319,12 @@ var HttpConnector = class extends BaseConnector {
1261
1319
  }
1262
1320
  return { fallbackReason, is401Error, httpStatusCode };
1263
1321
  }
1264
- /** Establish connection to the MCP implementation via streamable HTTP. */
1322
+ /**
1323
+ * Establishes a streamable HTTP connection to the MCP server.
1324
+ *
1325
+ * @returns A promise that resolves after protocol negotiation completes.
1326
+ * @throws An error with `code: 401` when authentication is required.
1327
+ */
1265
1328
  async connect() {
1266
1329
  if (this.connected) {
1267
1330
  logger.debug("Already connected to MCP implementation");
@@ -1489,6 +1552,11 @@ var HttpConnector = class extends BaseConnector {
1489
1552
  throw err;
1490
1553
  }
1491
1554
  }
1555
+ /**
1556
+ * Returns fields that identify the endpoint and negotiated transport.
1557
+ *
1558
+ * @returns HTTP connector identity metadata.
1559
+ */
1492
1560
  get publicIdentifier() {
1493
1561
  return {
1494
1562
  type: "http",
@@ -1497,7 +1565,11 @@ var HttpConnector = class extends BaseConnector {
1497
1565
  protocolEra: this.protocolEra ?? "unknown"
1498
1566
  };
1499
1567
  }
1500
- /** Get the active transport type (`streamable-http` once connected). */
1568
+ /**
1569
+ * Returns the active transport type.
1570
+ *
1571
+ * @returns `"streamable-http"` after connection, otherwise `null`.
1572
+ */
1501
1573
  getTransportType() {
1502
1574
  return this.transportType;
1503
1575
  }
@@ -1534,7 +1606,7 @@ var HttpConnector = class extends BaseConnector {
1534
1606
  };
1535
1607
 
1536
1608
  // src/utils/version.ts
1537
- var VERSION = "2.0.0-beta.16";
1609
+ var VERSION = "2.0.0-beta.17";
1538
1610
  function getPackageVersion() {
1539
1611
  return VERSION;
1540
1612
  }
@@ -2129,11 +2201,14 @@ function trimTrailingSlashes(value) {
2129
2201
  return value.slice(0, end);
2130
2202
  }
2131
2203
  var BrowserOAuthClientProvider = class {
2204
+ /** Protected MCP server URL associated with this provider. */
2132
2205
  serverUrl;
2206
+ /** Pre-registered public client information, when configured. */
2133
2207
  staticClientInfo;
2134
2208
  session;
2135
2209
  storage;
2136
2210
  // Browser-only state
2211
+ /** Whether initial connection waits for explicit authentication. */
2137
2212
  preventAutoAuth;
2138
2213
  useRedirectFlow;
2139
2214
  oauthProxyUrl;
@@ -2141,6 +2216,7 @@ var BrowserOAuthClientProvider = class {
2141
2216
  proxyOAuthRequests;
2142
2217
  lastAttemptedAuthUrl = null;
2143
2218
  authorizationPending = false;
2219
+ /** Callback invoked immediately before an authorization popup opens. */
2144
2220
  onPopupWindow;
2145
2221
  constructor(serverUrl, options = {}) {
2146
2222
  if (options.staticClientInfo?.client_secret) {
@@ -2164,36 +2240,51 @@ var BrowserOAuthClientProvider = class {
2164
2240
  this.onPopupWindow = options.onPopupWindow;
2165
2241
  }
2166
2242
  // --- Identity / key fields exposed for callback handling ---
2243
+ /** Prefix used for persisted OAuth keys. */
2167
2244
  get storageKeyPrefix() {
2168
2245
  return this.session.storageKeyPrefix;
2169
2246
  }
2247
+ /** Stable hash used to namespace storage for this server. */
2170
2248
  get serverUrlHash() {
2171
2249
  return this.session.serverUrlHash;
2172
2250
  }
2251
+ /** Human-readable OAuth client name. */
2173
2252
  get clientName() {
2174
2253
  return this.session.clientName;
2175
2254
  }
2255
+ /** Public website describing the OAuth client. */
2176
2256
  get clientUri() {
2177
2257
  return this.session.clientUri;
2178
2258
  }
2259
+ /** Public OAuth client logo URL. */
2179
2260
  get logoUri() {
2180
2261
  return this.session.logoUri;
2181
2262
  }
2263
+ /** OAuth redirect URI. */
2182
2264
  get callbackUrl() {
2183
2265
  return this.session.callbackUrl;
2184
2266
  }
2267
+ /** Space-delimited OAuth scopes requested by the client. */
2185
2268
  get scope() {
2186
2269
  return this.session.scope;
2187
2270
  }
2188
2271
  get clientMetadataUrl() {
2189
2272
  return this.session.clientMetadataUrl;
2190
2273
  }
2274
+ /**
2275
+ * Returns a provider-scoped storage key.
2276
+ *
2277
+ * @param keySuffix - Suffix identifying the stored value.
2278
+ * @returns Namespaced storage key.
2279
+ */
2191
2280
  getKey(keySuffix) {
2192
2281
  return this.session.getKey(keySuffix);
2193
2282
  }
2283
+ /** Whether an authorization flow is awaiting completion. */
2194
2284
  get hasPendingFlow() {
2195
2285
  return this.authorizationPending;
2196
2286
  }
2287
+ /** Marks the current authorization flow as complete. */
2197
2288
  markFlowComplete() {
2198
2289
  this.authorizationPending = false;
2199
2290
  }
@@ -2380,10 +2471,25 @@ var BrowserOAuthClientProvider = class {
2380
2471
  this.authorizationPending = false;
2381
2472
  return this.session.saveTokens(tokens, ctx);
2382
2473
  }
2474
+ /**
2475
+ * Returns the configured or dynamically registered OAuth client information.
2476
+ *
2477
+ * @param ctx - Optional registration context.
2478
+ * @returns OAuth client information, or `undefined` when not registered.
2479
+ */
2383
2480
  async clientInformation(ctx) {
2384
2481
  if (this.staticClientInfo) return this.staticClientInfo;
2385
2482
  return this.session.clientInformation(ctx);
2386
2483
  }
2484
+ /**
2485
+ * Persists public OAuth client registration information.
2486
+ *
2487
+ * Static client configuration takes precedence, and browser providers discard
2488
+ * any client secret returned for a public client.
2489
+ *
2490
+ * @param clientInformation - Registration information to save.
2491
+ * @param ctx - Optional registration context.
2492
+ */
2387
2493
  async saveClientInformation(clientInformation, ctx) {
2388
2494
  if (this.staticClientInfo) return;
2389
2495
  const { client_secret: discardedClientSecret, ...publicClientInformation } = clientInformation;
@@ -2463,7 +2569,7 @@ var BrowserOAuthClientProvider = class {
2463
2569
  }
2464
2570
  /**
2465
2571
  * Redirects the user agent to the authorization URL, storing necessary state.
2466
- * @param authorizationUrl The fully constructed authorization URL from the SDK.
2572
+ * @param authorizationUrl - The fully constructed authorization URL from the SDK.
2467
2573
  */
2468
2574
  async redirectToAuthorization(authorizationUrl) {
2469
2575
  const sanitizedAuthUrl = await this.prepareAuthorizationUrl(authorizationUrl);
@@ -2513,6 +2619,11 @@ var BrowserOAuthClientProvider = class {
2513
2619
  getLastAttemptedAuthUrl() {
2514
2620
  return this.lastAttemptedAuthUrl;
2515
2621
  }
2622
+ /**
2623
+ * Removes OAuth state stored for this server.
2624
+ *
2625
+ * @returns The number of storage entries removed.
2626
+ */
2516
2627
  clearStorage() {
2517
2628
  this.lastAttemptedAuthUrl = null;
2518
2629
  this.authorizationPending = false;
@@ -3374,7 +3485,7 @@ var MCPConnection = class {
3374
3485
  /**
3375
3486
  * Normalized server metadata for this ready connection.
3376
3487
  *
3377
- * @throws {Error} When called before protocol negotiation completes.
3488
+ * @throws When called before protocol negotiation completes.
3378
3489
  */
3379
3490
  get info() {
3380
3491
  const protocolEra = this.protocolEra;
@@ -3595,12 +3706,10 @@ function isOAuthClientProvider(provider) {
3595
3706
  var BaseMCPClient = class {
3596
3707
  /**
3597
3708
  * Internal configuration object containing MCP server definitions.
3598
- * @protected
3599
3709
  */
3600
3710
  config = {};
3601
3711
  /**
3602
3712
  * Map of server names to their active sessions.
3603
- * @protected
3604
3713
  */
3605
3714
  sessions = {};
3606
3715
  /**
@@ -3644,7 +3753,7 @@ var BaseMCPClient = class {
3644
3753
  *
3645
3754
  * @param _cfg - Configuration dictionary
3646
3755
  * @returns Client instance
3647
- * @throws {Error} If called on the base class instead of a concrete implementation
3756
+ * @throws If called on the base class instead of a concrete implementation
3648
3757
  *
3649
3758
  * @example
3650
3759
  * ```typescript
@@ -3786,7 +3895,7 @@ var BaseMCPClient = class {
3786
3895
  * @param serverName - The name of the server as defined in the client configuration
3787
3896
  * @param autoInitialize - Whether to automatically initialize the session (default: true)
3788
3897
  * @returns A promise that resolves to the created MCPSession instance
3789
- * @throws {Error} If the server is not found in the configuration
3898
+ * @throws If the server is not found in the configuration
3790
3899
  *
3791
3900
  * @example
3792
3901
  * ```typescript
@@ -3956,7 +4065,7 @@ var BaseMCPClient = class {
3956
4065
  *
3957
4066
  * @param serverName - Name of the server
3958
4067
  * @returns The session instance
3959
- * @throws {Error} If the session is not found
4068
+ * @throws If the session is not found
3960
4069
  *
3961
4070
  * @example
3962
4071
  * ```typescript
@@ -4125,16 +4234,28 @@ function trackBrowserClientInit(config) {
4125
4234
  }
4126
4235
  var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
4127
4236
  /**
4128
- * Get the mcp-use package version.
4129
- * Works in all environments (Node.js, browser, Cloudflare Workers, Deno, etc.)
4237
+ * Returns the installed `@mcp-use/client` package version.
4238
+ *
4239
+ * @returns The package version string.
4130
4240
  */
4131
4241
  static getPackageVersion() {
4132
4242
  return getPackageVersion();
4133
4243
  }
4244
+ /**
4245
+ * Creates a browser MCP client.
4246
+ *
4247
+ * @param config - Client configuration containing an optional `mcpServers` map.
4248
+ */
4134
4249
  constructor(config) {
4135
4250
  super(config);
4136
4251
  trackBrowserClientInit(this.config);
4137
4252
  }
4253
+ /**
4254
+ * Creates a browser client from an inline configuration object.
4255
+ *
4256
+ * @param cfg - Client configuration containing an optional `mcpServers` map.
4257
+ * @returns A browser client initialized with `cfg`.
4258
+ */
4138
4259
  static fromDict(cfg) {
4139
4260
  return new _BrowserMCPClient(cfg);
4140
4261
  }
@@ -7011,11 +7132,18 @@ function useMcpServer(id) {
7011
7132
 
7012
7133
  // src/react/storage.ts
7013
7134
  var LocalStorageProvider = class {
7135
+ /**
7136
+ * Creates a browser storage provider.
7137
+ *
7138
+ * @param storageKey - Key used for configurations. Metadata uses the same key
7139
+ * with a `-metadata` suffix. Defaults to `"mcp-client-servers"`.
7140
+ */
7014
7141
  constructor(storageKey = "mcp-client-servers") {
7015
7142
  this.storageKey = storageKey;
7016
7143
  this.metadataKey = `${storageKey}-metadata`;
7017
7144
  }
7018
7145
  metadataKey;
7146
+ /** Returns sanitized server configurations from `localStorage`. */
7019
7147
  getServers() {
7020
7148
  try {
7021
7149
  const stored = localStorage.getItem(this.storageKey);
@@ -7050,6 +7178,7 @@ var LocalStorageProvider = class {
7050
7178
  return {};
7051
7179
  }
7052
7180
  }
7181
+ /** Replaces all saved server configurations. */
7053
7182
  setServers(servers) {
7054
7183
  try {
7055
7184
  const sanitized = Object.fromEntries(
@@ -7063,17 +7192,20 @@ var LocalStorageProvider = class {
7063
7192
  console.error("[LocalStorageProvider] Failed to save servers.");
7064
7193
  }
7065
7194
  }
7195
+ /** Saves one server configuration. */
7066
7196
  setServer(id, config) {
7067
7197
  const servers = this.getServers();
7068
7198
  servers[id] = config;
7069
7199
  this.setServers(servers);
7070
7200
  }
7201
+ /** Removes one server and its cached metadata. */
7071
7202
  removeServer(id) {
7072
7203
  const servers = this.getServers();
7073
7204
  delete servers[id];
7074
7205
  this.setServers(servers);
7075
7206
  this.removeServerMetadata(id);
7076
7207
  }
7208
+ /** Removes all saved configurations and metadata. */
7077
7209
  clear() {
7078
7210
  try {
7079
7211
  localStorage.removeItem(this.storageKey);
@@ -7098,14 +7230,17 @@ var LocalStorageProvider = class {
7098
7230
  console.error("[LocalStorageProvider] Failed to save metadata.");
7099
7231
  }
7100
7232
  }
7233
+ /** Returns cached presentation metadata for a server. */
7101
7234
  getServerMetadata(id) {
7102
7235
  return this.getAllMetadata()[id];
7103
7236
  }
7237
+ /** Saves presentation metadata and stamps the current cache time. */
7104
7238
  setServerMetadata(id, metadata) {
7105
7239
  const allMetadata = this.getAllMetadata();
7106
7240
  allMetadata[id] = { ...metadata, cachedAt: Date.now() };
7107
7241
  this.setAllMetadata(allMetadata);
7108
7242
  }
7243
+ /** Removes cached presentation metadata for a server. */
7109
7244
  removeServerMetadata(id) {
7110
7245
  const allMetadata = this.getAllMetadata();
7111
7246
  delete allMetadata[id];
@@ -7115,9 +7250,11 @@ var LocalStorageProvider = class {
7115
7250
  var MemoryStorageProvider = class {
7116
7251
  storage = {};
7117
7252
  metadata = {};
7253
+ /** Returns a shallow copy of all stored server configurations. */
7118
7254
  getServers() {
7119
7255
  return { ...this.storage };
7120
7256
  }
7257
+ /** Replaces all stored server configurations. */
7121
7258
  setServers(servers) {
7122
7259
  this.storage = Object.fromEntries(
7123
7260
  Object.entries(servers).map(([id, config]) => [
@@ -7126,23 +7263,29 @@ var MemoryStorageProvider = class {
7126
7263
  ])
7127
7264
  );
7128
7265
  }
7266
+ /** Stores one server configuration. */
7129
7267
  setServer(id, config) {
7130
7268
  this.storage[id] = toPersistedServerConfig(config);
7131
7269
  }
7270
+ /** Removes one server and its cached metadata. */
7132
7271
  removeServer(id) {
7133
7272
  delete this.storage[id];
7134
7273
  this.removeServerMetadata(id);
7135
7274
  }
7275
+ /** Removes all configurations and metadata. */
7136
7276
  clear() {
7137
7277
  this.storage = {};
7138
7278
  this.metadata = {};
7139
7279
  }
7280
+ /** Returns cached presentation metadata for a server. */
7140
7281
  getServerMetadata(id) {
7141
7282
  return this.metadata[id];
7142
7283
  }
7284
+ /** Saves presentation metadata and stamps the current cache time. */
7143
7285
  setServerMetadata(id, metadata) {
7144
7286
  this.metadata[id] = { ...metadata, cachedAt: Date.now() };
7145
7287
  }
7288
+ /** Removes cached presentation metadata for a server. */
7146
7289
  removeServerMetadata(id) {
7147
7290
  delete this.metadata[id];
7148
7291
  }