mcp-use 1.9.1-canary.0 → 1.10.0-canary.2

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 (56) hide show
  1. package/README.md +9 -6
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/{chunk-MUZ5WYE3.js → chunk-BFFS67JY.js} +1 -1
  4. package/dist/{chunk-D22NUQTL.js → chunk-HRWL2M2I.js} +184 -0
  5. package/dist/{chunk-5URNFWCQ.js → chunk-LWVK6RXA.js} +8 -3
  6. package/dist/{chunk-KHTTBIRP.js → chunk-Q3PFK7Y4.js} +138 -1
  7. package/dist/{context-storage-TXQ4DVSS.js → context-storage-NA4MHWOZ.js} +3 -1
  8. package/dist/index.cjs +184 -0
  9. package/dist/index.d.ts +3 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/src/browser.cjs +184 -0
  13. package/dist/src/browser.js +1 -1
  14. package/dist/src/react/index.cjs +184 -0
  15. package/dist/src/react/index.js +2 -2
  16. package/dist/src/server/context-storage.d.ts +8 -1
  17. package/dist/src/server/context-storage.d.ts.map +1 -1
  18. package/dist/src/server/endpoints/mount-mcp.d.ts.map +1 -1
  19. package/dist/src/server/index.cjs +595 -63
  20. package/dist/src/server/index.d.ts +3 -3
  21. package/dist/src/server/index.d.ts.map +1 -1
  22. package/dist/src/server/index.js +459 -67
  23. package/dist/src/server/mcp-server.d.ts +49 -9
  24. package/dist/src/server/mcp-server.d.ts.map +1 -1
  25. package/dist/src/server/oauth/providers.d.ts +27 -9
  26. package/dist/src/server/oauth/providers.d.ts.map +1 -1
  27. package/dist/src/server/prompts/index.d.ts.map +1 -1
  28. package/dist/src/server/resources/index.d.ts +43 -23
  29. package/dist/src/server/resources/index.d.ts.map +1 -1
  30. package/dist/src/server/resources/subscriptions.d.ts +54 -0
  31. package/dist/src/server/resources/subscriptions.d.ts.map +1 -0
  32. package/dist/src/server/sessions/session-manager.d.ts +9 -1
  33. package/dist/src/server/sessions/session-manager.d.ts.map +1 -1
  34. package/dist/src/server/tools/tool-execution-helpers.d.ts +30 -17
  35. package/dist/src/server/tools/tool-execution-helpers.d.ts.map +1 -1
  36. package/dist/src/server/tools/tool-registration.d.ts.map +1 -1
  37. package/dist/src/server/types/common.d.ts +24 -8
  38. package/dist/src/server/types/common.d.ts.map +1 -1
  39. package/dist/src/server/types/index.d.ts +3 -3
  40. package/dist/src/server/types/index.d.ts.map +1 -1
  41. package/dist/src/server/types/prompt.d.ts +2 -1
  42. package/dist/src/server/types/prompt.d.ts.map +1 -1
  43. package/dist/src/server/types/resource.d.ts +53 -8
  44. package/dist/src/server/types/resource.d.ts.map +1 -1
  45. package/dist/src/server/types/tool-context.d.ts +131 -0
  46. package/dist/src/server/types/tool-context.d.ts.map +1 -1
  47. package/dist/src/server/types/tool.d.ts +1 -1
  48. package/dist/src/server/types/tool.d.ts.map +1 -1
  49. package/dist/src/server/utils/response-helpers.d.ts +48 -4
  50. package/dist/src/server/utils/response-helpers.d.ts.map +1 -1
  51. package/dist/src/server/widgets/index.d.ts +2 -2
  52. package/dist/src/server/widgets/ui-resource-registration.d.ts +2 -2
  53. package/dist/src/session.d.ts +337 -2
  54. package/dist/src/session.d.ts.map +1 -1
  55. package/dist/{tool-execution-helpers-IVUDHXMK.js → tool-execution-helpers-RRMGLAHR.js} +7 -1
  56. package/package.json +3 -3
@@ -2307,6 +2307,190 @@ var MCPSession = class {
2307
2307
  getRoots() {
2308
2308
  return this.connector.getRoots();
2309
2309
  }
2310
+ /**
2311
+ * Get the cached list of tools from the server.
2312
+ *
2313
+ * @returns Array of available tools
2314
+ *
2315
+ * @example
2316
+ * ```typescript
2317
+ * const tools = session.tools;
2318
+ * console.log(`Available tools: ${tools.map(t => t.name).join(", ")}`);
2319
+ * ```
2320
+ */
2321
+ get tools() {
2322
+ return this.connector.tools;
2323
+ }
2324
+ /**
2325
+ * Get the server capabilities advertised during initialization.
2326
+ *
2327
+ * @returns Server capabilities object
2328
+ */
2329
+ get serverCapabilities() {
2330
+ return this.connector.serverCapabilities;
2331
+ }
2332
+ /**
2333
+ * Get the server information (name and version).
2334
+ *
2335
+ * @returns Server info object or null if not available
2336
+ */
2337
+ get serverInfo() {
2338
+ return this.connector.serverInfo;
2339
+ }
2340
+ /**
2341
+ * Call a tool on the server.
2342
+ *
2343
+ * @param name - Name of the tool to call
2344
+ * @param args - Arguments to pass to the tool
2345
+ * @param options - Optional request options (timeout, progress handlers, etc.)
2346
+ * @returns Result from the tool execution
2347
+ *
2348
+ * @example
2349
+ * ```typescript
2350
+ * const result = await session.callTool("add", { a: 5, b: 3 });
2351
+ * console.log(`Result: ${result.content[0].text}`);
2352
+ * ```
2353
+ */
2354
+ async callTool(name, args, options) {
2355
+ return this.connector.callTool(name, args, options);
2356
+ }
2357
+ /**
2358
+ * List resources from the server with optional pagination.
2359
+ *
2360
+ * @param cursor - Optional cursor for pagination
2361
+ * @param options - Request options
2362
+ * @returns Resource list with optional nextCursor for pagination
2363
+ *
2364
+ * @example
2365
+ * ```typescript
2366
+ * const result = await session.listResources();
2367
+ * console.log(`Found ${result.resources.length} resources`);
2368
+ * ```
2369
+ */
2370
+ async listResources(cursor, options) {
2371
+ return this.connector.listResources(cursor, options);
2372
+ }
2373
+ /**
2374
+ * List all resources from the server, automatically handling pagination.
2375
+ *
2376
+ * @param options - Request options
2377
+ * @returns Complete list of all resources
2378
+ *
2379
+ * @example
2380
+ * ```typescript
2381
+ * const result = await session.listAllResources();
2382
+ * console.log(`Total resources: ${result.resources.length}`);
2383
+ * ```
2384
+ */
2385
+ async listAllResources(options) {
2386
+ return this.connector.listAllResources(options);
2387
+ }
2388
+ /**
2389
+ * List resource templates from the server.
2390
+ *
2391
+ * @param options - Request options
2392
+ * @returns List of available resource templates
2393
+ *
2394
+ * @example
2395
+ * ```typescript
2396
+ * const result = await session.listResourceTemplates();
2397
+ * console.log(`Available templates: ${result.resourceTemplates.length}`);
2398
+ * ```
2399
+ */
2400
+ async listResourceTemplates(options) {
2401
+ return this.connector.listResourceTemplates(options);
2402
+ }
2403
+ /**
2404
+ * Read a resource by URI.
2405
+ *
2406
+ * @param uri - URI of the resource to read
2407
+ * @param options - Request options
2408
+ * @returns Resource content
2409
+ *
2410
+ * @example
2411
+ * ```typescript
2412
+ * const resource = await session.readResource("file:///path/to/file.txt");
2413
+ * console.log(resource.contents);
2414
+ * ```
2415
+ */
2416
+ async readResource(uri, options) {
2417
+ return this.connector.readResource(uri, options);
2418
+ }
2419
+ /**
2420
+ * Subscribe to resource updates.
2421
+ *
2422
+ * @param uri - URI of the resource to subscribe to
2423
+ * @param options - Request options
2424
+ *
2425
+ * @example
2426
+ * ```typescript
2427
+ * await session.subscribeToResource("file:///path/to/file.txt");
2428
+ * // Now you'll receive notifications when this resource changes
2429
+ * ```
2430
+ */
2431
+ async subscribeToResource(uri, options) {
2432
+ return this.connector.subscribeToResource(uri, options);
2433
+ }
2434
+ /**
2435
+ * Unsubscribe from resource updates.
2436
+ *
2437
+ * @param uri - URI of the resource to unsubscribe from
2438
+ * @param options - Request options
2439
+ *
2440
+ * @example
2441
+ * ```typescript
2442
+ * await session.unsubscribeFromResource("file:///path/to/file.txt");
2443
+ * ```
2444
+ */
2445
+ async unsubscribeFromResource(uri, options) {
2446
+ return this.connector.unsubscribeFromResource(uri, options);
2447
+ }
2448
+ /**
2449
+ * List available prompts from the server.
2450
+ *
2451
+ * @returns List of available prompts
2452
+ *
2453
+ * @example
2454
+ * ```typescript
2455
+ * const result = await session.listPrompts();
2456
+ * console.log(`Available prompts: ${result.prompts.length}`);
2457
+ * ```
2458
+ */
2459
+ async listPrompts() {
2460
+ return this.connector.listPrompts();
2461
+ }
2462
+ /**
2463
+ * Get a specific prompt with arguments.
2464
+ *
2465
+ * @param name - Name of the prompt to get
2466
+ * @param args - Arguments for the prompt
2467
+ * @returns Prompt result
2468
+ *
2469
+ * @example
2470
+ * ```typescript
2471
+ * const prompt = await session.getPrompt("greeting", { name: "Alice" });
2472
+ * console.log(prompt.messages);
2473
+ * ```
2474
+ */
2475
+ async getPrompt(name, args) {
2476
+ return this.connector.getPrompt(name, args);
2477
+ }
2478
+ /**
2479
+ * Send a raw request through the client.
2480
+ *
2481
+ * @param method - MCP method name
2482
+ * @param params - Request parameters
2483
+ * @param options - Request options
2484
+ * @returns Response from the server
2485
+ *
2486
+ * @example
2487
+ * ```typescript
2488
+ * const result = await session.request("custom/method", { key: "value" });
2489
+ * ```
2490
+ */
2491
+ async request(method, params = null, options) {
2492
+ return this.connector.request(method, params, options);
2493
+ }
2310
2494
  };
2311
2495
 
2312
2496
  // src/client/base.ts
@@ -16,7 +16,7 @@ import {
16
16
  HttpConnector,
17
17
  MCPSession,
18
18
  WebSocketConnector
19
- } from "../chunk-D22NUQTL.js";
19
+ } from "../chunk-HRWL2M2I.js";
20
20
  import {
21
21
  BrowserOAuthClientProvider,
22
22
  onMcpAuthorization
@@ -1574,6 +1574,190 @@ var MCPSession = class {
1574
1574
  getRoots() {
1575
1575
  return this.connector.getRoots();
1576
1576
  }
1577
+ /**
1578
+ * Get the cached list of tools from the server.
1579
+ *
1580
+ * @returns Array of available tools
1581
+ *
1582
+ * @example
1583
+ * ```typescript
1584
+ * const tools = session.tools;
1585
+ * console.log(`Available tools: ${tools.map(t => t.name).join(", ")}`);
1586
+ * ```
1587
+ */
1588
+ get tools() {
1589
+ return this.connector.tools;
1590
+ }
1591
+ /**
1592
+ * Get the server capabilities advertised during initialization.
1593
+ *
1594
+ * @returns Server capabilities object
1595
+ */
1596
+ get serverCapabilities() {
1597
+ return this.connector.serverCapabilities;
1598
+ }
1599
+ /**
1600
+ * Get the server information (name and version).
1601
+ *
1602
+ * @returns Server info object or null if not available
1603
+ */
1604
+ get serverInfo() {
1605
+ return this.connector.serverInfo;
1606
+ }
1607
+ /**
1608
+ * Call a tool on the server.
1609
+ *
1610
+ * @param name - Name of the tool to call
1611
+ * @param args - Arguments to pass to the tool
1612
+ * @param options - Optional request options (timeout, progress handlers, etc.)
1613
+ * @returns Result from the tool execution
1614
+ *
1615
+ * @example
1616
+ * ```typescript
1617
+ * const result = await session.callTool("add", { a: 5, b: 3 });
1618
+ * console.log(`Result: ${result.content[0].text}`);
1619
+ * ```
1620
+ */
1621
+ async callTool(name, args, options) {
1622
+ return this.connector.callTool(name, args, options);
1623
+ }
1624
+ /**
1625
+ * List resources from the server with optional pagination.
1626
+ *
1627
+ * @param cursor - Optional cursor for pagination
1628
+ * @param options - Request options
1629
+ * @returns Resource list with optional nextCursor for pagination
1630
+ *
1631
+ * @example
1632
+ * ```typescript
1633
+ * const result = await session.listResources();
1634
+ * console.log(`Found ${result.resources.length} resources`);
1635
+ * ```
1636
+ */
1637
+ async listResources(cursor, options) {
1638
+ return this.connector.listResources(cursor, options);
1639
+ }
1640
+ /**
1641
+ * List all resources from the server, automatically handling pagination.
1642
+ *
1643
+ * @param options - Request options
1644
+ * @returns Complete list of all resources
1645
+ *
1646
+ * @example
1647
+ * ```typescript
1648
+ * const result = await session.listAllResources();
1649
+ * console.log(`Total resources: ${result.resources.length}`);
1650
+ * ```
1651
+ */
1652
+ async listAllResources(options) {
1653
+ return this.connector.listAllResources(options);
1654
+ }
1655
+ /**
1656
+ * List resource templates from the server.
1657
+ *
1658
+ * @param options - Request options
1659
+ * @returns List of available resource templates
1660
+ *
1661
+ * @example
1662
+ * ```typescript
1663
+ * const result = await session.listResourceTemplates();
1664
+ * console.log(`Available templates: ${result.resourceTemplates.length}`);
1665
+ * ```
1666
+ */
1667
+ async listResourceTemplates(options) {
1668
+ return this.connector.listResourceTemplates(options);
1669
+ }
1670
+ /**
1671
+ * Read a resource by URI.
1672
+ *
1673
+ * @param uri - URI of the resource to read
1674
+ * @param options - Request options
1675
+ * @returns Resource content
1676
+ *
1677
+ * @example
1678
+ * ```typescript
1679
+ * const resource = await session.readResource("file:///path/to/file.txt");
1680
+ * console.log(resource.contents);
1681
+ * ```
1682
+ */
1683
+ async readResource(uri, options) {
1684
+ return this.connector.readResource(uri, options);
1685
+ }
1686
+ /**
1687
+ * Subscribe to resource updates.
1688
+ *
1689
+ * @param uri - URI of the resource to subscribe to
1690
+ * @param options - Request options
1691
+ *
1692
+ * @example
1693
+ * ```typescript
1694
+ * await session.subscribeToResource("file:///path/to/file.txt");
1695
+ * // Now you'll receive notifications when this resource changes
1696
+ * ```
1697
+ */
1698
+ async subscribeToResource(uri, options) {
1699
+ return this.connector.subscribeToResource(uri, options);
1700
+ }
1701
+ /**
1702
+ * Unsubscribe from resource updates.
1703
+ *
1704
+ * @param uri - URI of the resource to unsubscribe from
1705
+ * @param options - Request options
1706
+ *
1707
+ * @example
1708
+ * ```typescript
1709
+ * await session.unsubscribeFromResource("file:///path/to/file.txt");
1710
+ * ```
1711
+ */
1712
+ async unsubscribeFromResource(uri, options) {
1713
+ return this.connector.unsubscribeFromResource(uri, options);
1714
+ }
1715
+ /**
1716
+ * List available prompts from the server.
1717
+ *
1718
+ * @returns List of available prompts
1719
+ *
1720
+ * @example
1721
+ * ```typescript
1722
+ * const result = await session.listPrompts();
1723
+ * console.log(`Available prompts: ${result.prompts.length}`);
1724
+ * ```
1725
+ */
1726
+ async listPrompts() {
1727
+ return this.connector.listPrompts();
1728
+ }
1729
+ /**
1730
+ * Get a specific prompt with arguments.
1731
+ *
1732
+ * @param name - Name of the prompt to get
1733
+ * @param args - Arguments for the prompt
1734
+ * @returns Prompt result
1735
+ *
1736
+ * @example
1737
+ * ```typescript
1738
+ * const prompt = await session.getPrompt("greeting", { name: "Alice" });
1739
+ * console.log(prompt.messages);
1740
+ * ```
1741
+ */
1742
+ async getPrompt(name, args) {
1743
+ return this.connector.getPrompt(name, args);
1744
+ }
1745
+ /**
1746
+ * Send a raw request through the client.
1747
+ *
1748
+ * @param method - MCP method name
1749
+ * @param params - Request parameters
1750
+ * @param options - Request options
1751
+ * @returns Response from the server
1752
+ *
1753
+ * @example
1754
+ * ```typescript
1755
+ * const result = await session.request("custom/method", { key: "value" });
1756
+ * ```
1757
+ */
1758
+ async request(method, params = null, options) {
1759
+ return this.connector.request(method, params, options);
1760
+ }
1577
1761
  };
1578
1762
 
1579
1763
  // src/client/base.ts
@@ -9,8 +9,8 @@ import {
9
9
  useWidgetProps,
10
10
  useWidgetState,
11
11
  useWidgetTheme
12
- } from "../../chunk-MUZ5WYE3.js";
13
- import "../../chunk-D22NUQTL.js";
12
+ } from "../../chunk-BFFS67JY.js";
13
+ import "../../chunk-HRWL2M2I.js";
14
14
  import {
15
15
  onMcpAuthorization
16
16
  } from "../../chunk-3R5PDYIN.js";
@@ -15,6 +15,7 @@ import type { Context } from "hono";
15
15
  *
16
16
  * @param context - Hono Context object to store
17
17
  * @param fn - Function to execute within this context
18
+ * @param sessionId - Optional session ID to store with the context
18
19
  * @returns Promise resolving to the function's return value
19
20
  *
20
21
  * @example
@@ -28,7 +29,7 @@ import type { Context } from "hono";
28
29
  * });
29
30
  * ```
30
31
  */
31
- export declare function runWithContext<T>(context: Context, fn: () => Promise<T>): Promise<T>;
32
+ export declare function runWithContext<T>(context: Context, fn: () => Promise<T>, sessionId?: string): Promise<T>;
32
33
  /**
33
34
  * Get the current request context from AsyncLocalStorage
34
35
  *
@@ -45,6 +46,12 @@ export declare function runWithContext<T>(context: Context, fn: () => Promise<T>
45
46
  * ```
46
47
  */
47
48
  export declare function getRequestContext(): Context | undefined;
49
+ /**
50
+ * Get the current session ID from AsyncLocalStorage
51
+ *
52
+ * @returns The session ID for the current async operation, or undefined if not in a request context
53
+ */
54
+ export declare function getSessionId(): string | undefined;
48
55
  /**
49
56
  * Check if currently executing within a request context
50
57
  *
@@ -1 +1 @@
1
- {"version":3,"file":"context-storage.d.ts","sourceRoot":"","sources":["../../../src/server/context-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAQpC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,GAAG,SAAS,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C"}
1
+ {"version":3,"file":"context-storage.d.ts","sourceRoot":"","sources":["../../../src/server/context-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAgBpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,GAAG,SAAS,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"mount-mcp.d.ts","sourceRoot":"","sources":["../../../../src/server/endpoints/mount-mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAW,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,QAAQ,EACb,iBAAiB,EAAE,GAAG,EAAE,2DAA2D;AACnF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClC,MAAM,EAAE,YAAY,EACpB,gBAAgB,EAAE,OAAO,GACxB,OAAO,CAAC;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC,OAAO,CAAA;CAAE,CAAC,CA4ExE"}
1
+ {"version":3,"file":"mount-mcp.d.ts","sourceRoot":"","sources":["../../../../src/server/endpoints/mount-mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAW,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,QAAQ,EACb,iBAAiB,EAAE,GAAG,EAAE,2DAA2D;AACnF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClC,MAAM,EAAE,YAAY,EACpB,gBAAgB,EAAE,OAAO,GACxB,OAAO,CAAC;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC,OAAO,CAAA;CAAE,CAAC,CAgGxE"}