@mcp-ts/sdk 1.3.9 → 1.4.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.
Files changed (47) hide show
  1. package/README.md +0 -1
  2. package/dist/adapters/langchain-adapter.js.map +1 -1
  3. package/dist/adapters/langchain-adapter.mjs.map +1 -1
  4. package/dist/client/index.d.mts +3 -189
  5. package/dist/client/index.d.ts +3 -189
  6. package/dist/client/index.js +218 -54
  7. package/dist/client/index.js.map +1 -1
  8. package/dist/client/index.mjs +215 -55
  9. package/dist/client/index.mjs.map +1 -1
  10. package/dist/client/react.d.mts +29 -40
  11. package/dist/client/react.d.ts +29 -40
  12. package/dist/client/react.js +492 -147
  13. package/dist/client/react.js.map +1 -1
  14. package/dist/client/react.mjs +490 -149
  15. package/dist/client/react.mjs.map +1 -1
  16. package/dist/client/vue.d.mts +3 -2
  17. package/dist/client/vue.d.ts +3 -2
  18. package/dist/client/vue.js +239 -63
  19. package/dist/client/vue.js.map +1 -1
  20. package/dist/client/vue.mjs +236 -64
  21. package/dist/client/vue.mjs.map +1 -1
  22. package/dist/index-CQr9q0bF.d.mts +295 -0
  23. package/dist/index-nE_7Io0I.d.ts +295 -0
  24. package/dist/index.d.mts +2 -1
  25. package/dist/index.d.ts +2 -1
  26. package/dist/index.js +315 -64
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +303 -65
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/server/index.js +93 -10
  31. package/dist/server/index.js.map +1 -1
  32. package/dist/server/index.mjs +88 -10
  33. package/dist/server/index.mjs.map +1 -1
  34. package/package.json +13 -11
  35. package/src/adapters/langchain-adapter.ts +1 -1
  36. package/src/client/core/app-host.ts +252 -65
  37. package/src/client/core/constants.ts +30 -0
  38. package/src/client/index.ts +6 -1
  39. package/src/client/react/index.ts +6 -1
  40. package/src/client/react/use-app-host.ts +13 -19
  41. package/src/client/react/use-mcp-apps.tsx +297 -125
  42. package/src/client/react/use-mcp.ts +75 -36
  43. package/src/client/utils/app-host-utils.ts +62 -0
  44. package/src/client/vue/use-mcp.ts +23 -12
  45. package/src/server/mcp/oauth-client.ts +31 -8
  46. package/src/server/storage/crypto.ts +92 -0
  47. package/src/server/storage/supabase-backend.ts +7 -6
@@ -1,10 +1,11 @@
1
- import { SSEClient, AppHost } from './index.mjs';
2
- export { SSEClientOptions } from './index.mjs';
1
+ import { c as SSEClient, e as AppHostOptions, f as AppHostClient, a as AppHost } from '../index-CQr9q0bF.mjs';
2
+ export { A as APP_HOST_DEFAULTS, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, d as SSEClientOptions } from '../index-CQr9q0bF.mjs';
3
3
  import { c as McpConnectionState, M as McpConnectionEvent } from '../events-CK3N--3g.mjs';
4
4
  export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, d as McpObservabilityEvent } from '../events-CK3N--3g.mjs';
5
5
  import { T as ToolInfo, k as FinishAuthResult, n as ListToolsRpcResult, L as ListPromptsResult, l as ListResourcesResult } from '../types-CW6lghof.mjs';
6
6
  export { p as McpRpcRequest, q as McpRpcResponse } from '../types-CW6lghof.mjs';
7
7
  import React$1 from 'react';
8
+ import '@modelcontextprotocol/ext-apps/app-bridge';
8
9
  import '@modelcontextprotocol/sdk/types.js';
9
10
 
10
11
  /**
@@ -172,23 +173,19 @@ declare function useMcp(options: UseMcpOptions): McpClient$1;
172
173
  /**
173
174
  * Hook to host an MCP App in a React component
174
175
  *
175
- * Optimized for instant loading:
176
- * - Creates AppHost synchronously
177
- * - Starts bridge connection immediately
178
- * - Returns host before connection completes (ready to call launch)
176
+ * Initialization is async but optimized for instant availability:
177
+ * - Constructor runs synchronously (sandbox + bridge handler setup)
178
+ * - Host is set in state immediately so launch() can be called right away
179
+ * - start() is a lightweight no-op reserved for future async pre-init work
180
+ * - The real async work (iframe load, bridge connect) happens inside launch()
179
181
  *
180
182
  * @param client - Connected SSEClient instance
181
183
  * @param iframeRef - Reference to the iframe element
182
184
  * @param options - Optional configuration
183
185
  * @returns Object containing the AppHost instance (or null) and error state
184
186
  */
185
- declare function useAppHost(client: SSEClient, iframeRef: React.RefObject<HTMLIFrameElement>, options?: {
186
- /** Callback when the App sends a message (e.g. to chat) */
187
- onMessage?: (params: {
188
- role: string;
189
- content: unknown;
190
- }) => void;
191
- }): {
187
+ type UseAppHostOptions = AppHostOptions;
188
+ declare function useAppHost(client: AppHostClient | null, iframeRef: React.RefObject<HTMLIFrameElement>, options?: UseAppHostOptions): {
192
189
  host: AppHost | null;
193
190
  error: Error | null;
194
191
  };
@@ -222,42 +219,34 @@ interface McpAppMetadata {
222
219
  resourceUri: string;
223
220
  sessionId: string;
224
221
  }
225
- interface McpAppRendererProps {
226
- mcpClient: McpClient | null;
222
+ /**
223
+ * Imperative handle for {@link useMcpApps}'s `McpAppRenderer` (via `ref`),
224
+ * aligned with `@mcp-ui/client`'s `AppRendererHandle.teardownResource`.
225
+ */
226
+ interface McpAppRendererHandle {
227
+ teardownResource: (params?: Record<string, unknown>) => void;
228
+ }
229
+ /** Props for {@link useMcpApps}'s `McpAppRenderer` (client is supplied via the hook). */
230
+ interface McpAppRendererProps extends Pick<UseAppHostOptions, 'sandbox' | 'hostContext' | 'onCallTool' | 'onReadResource' | 'onFallbackRequest' | 'onMessage' | 'onOpenLink' | 'onLoggingMessage' | 'onSizeChanged' | 'onError'> {
227
231
  name: string;
232
+ toolResourceUri?: string;
233
+ html?: string;
228
234
  input?: Record<string, unknown>;
229
235
  result?: unknown;
230
- status: 'executing' | 'inProgress' | 'complete' | 'idle';
231
- /** Custom CSS class for the container */
236
+ status?: 'executing' | 'inProgress' | 'complete' | 'idle';
237
+ toolInputPartial?: any;
238
+ toolCancelled?: boolean;
232
239
  className?: string;
240
+ loader?: React$1.ReactNode;
233
241
  }
234
242
  /**
235
- * Simple hook to get MCP app metadata
236
- *
237
- * @param mcpClient - The MCP client from useMcp() or context
238
- * @returns Object with getAppMetadata function and McpAppRenderer component
239
- *
240
- * @example
241
- * ```tsx
242
- * function ToolRenderer(props) {
243
- * const { getAppMetadata, McpAppRenderer } = useMcpApps(mcpClient);
244
- * const metadata = getAppMetadata(props.name);
243
+ * Helpers scoped to one `mcpClient`. Pass the client here once; `McpAppRenderer` only needs per-tool props (`name`, `input`, `result`, `status`).
245
244
  *
246
- * if (!metadata) return null;
247
- * return (
248
- * <McpAppRenderer
249
- * metadata={metadata}
250
- * input={props.args}
251
- * result={props.result}
252
- * status={props.status}
253
- * />
254
- * );
255
- * }
256
- * ```
245
+ * @param mcpClient - From `useMcp()` or context (for example `useMcpContext()`).
257
246
  */
258
247
  declare function useMcpApps(mcpClient: McpClient | null): {
259
248
  getAppMetadata: (toolName: string) => McpAppMetadata | undefined;
260
- McpAppRenderer: React$1.NamedExoticComponent<McpAppRendererProps>;
249
+ McpAppRenderer: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<McpAppRendererProps & React$1.RefAttributes<McpAppRendererHandle>>>;
261
250
  };
262
251
 
263
- export { AppHost, type McpClient$1 as McpClient, type McpConnection, McpConnectionEvent, McpConnectionState, SSEClient, ToolInfo, type UseMcpOptions, useAppHost, useMcp, useMcpApps };
252
+ export { AppHost, type McpAppMetadata, type McpAppRendererHandle, type McpAppRendererProps, type McpClient$1 as McpClient, type McpConnection, McpConnectionEvent, McpConnectionState, SSEClient, ToolInfo, type UseMcpOptions, useAppHost, useMcp, useMcpApps };
@@ -1,10 +1,11 @@
1
- import { SSEClient, AppHost } from './index.js';
2
- export { SSEClientOptions } from './index.js';
1
+ import { c as SSEClient, e as AppHostOptions, f as AppHostClient, a as AppHost } from '../index-nE_7Io0I.js';
2
+ export { A as APP_HOST_DEFAULTS, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, d as SSEClientOptions } from '../index-nE_7Io0I.js';
3
3
  import { c as McpConnectionState, M as McpConnectionEvent } from '../events-CK3N--3g.js';
4
4
  export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, d as McpObservabilityEvent } from '../events-CK3N--3g.js';
5
5
  import { T as ToolInfo, k as FinishAuthResult, n as ListToolsRpcResult, L as ListPromptsResult, l as ListResourcesResult } from '../types-CW6lghof.js';
6
6
  export { p as McpRpcRequest, q as McpRpcResponse } from '../types-CW6lghof.js';
7
7
  import React$1 from 'react';
8
+ import '@modelcontextprotocol/ext-apps/app-bridge';
8
9
  import '@modelcontextprotocol/sdk/types.js';
9
10
 
10
11
  /**
@@ -172,23 +173,19 @@ declare function useMcp(options: UseMcpOptions): McpClient$1;
172
173
  /**
173
174
  * Hook to host an MCP App in a React component
174
175
  *
175
- * Optimized for instant loading:
176
- * - Creates AppHost synchronously
177
- * - Starts bridge connection immediately
178
- * - Returns host before connection completes (ready to call launch)
176
+ * Initialization is async but optimized for instant availability:
177
+ * - Constructor runs synchronously (sandbox + bridge handler setup)
178
+ * - Host is set in state immediately so launch() can be called right away
179
+ * - start() is a lightweight no-op reserved for future async pre-init work
180
+ * - The real async work (iframe load, bridge connect) happens inside launch()
179
181
  *
180
182
  * @param client - Connected SSEClient instance
181
183
  * @param iframeRef - Reference to the iframe element
182
184
  * @param options - Optional configuration
183
185
  * @returns Object containing the AppHost instance (or null) and error state
184
186
  */
185
- declare function useAppHost(client: SSEClient, iframeRef: React.RefObject<HTMLIFrameElement>, options?: {
186
- /** Callback when the App sends a message (e.g. to chat) */
187
- onMessage?: (params: {
188
- role: string;
189
- content: unknown;
190
- }) => void;
191
- }): {
187
+ type UseAppHostOptions = AppHostOptions;
188
+ declare function useAppHost(client: AppHostClient | null, iframeRef: React.RefObject<HTMLIFrameElement>, options?: UseAppHostOptions): {
192
189
  host: AppHost | null;
193
190
  error: Error | null;
194
191
  };
@@ -222,42 +219,34 @@ interface McpAppMetadata {
222
219
  resourceUri: string;
223
220
  sessionId: string;
224
221
  }
225
- interface McpAppRendererProps {
226
- mcpClient: McpClient | null;
222
+ /**
223
+ * Imperative handle for {@link useMcpApps}'s `McpAppRenderer` (via `ref`),
224
+ * aligned with `@mcp-ui/client`'s `AppRendererHandle.teardownResource`.
225
+ */
226
+ interface McpAppRendererHandle {
227
+ teardownResource: (params?: Record<string, unknown>) => void;
228
+ }
229
+ /** Props for {@link useMcpApps}'s `McpAppRenderer` (client is supplied via the hook). */
230
+ interface McpAppRendererProps extends Pick<UseAppHostOptions, 'sandbox' | 'hostContext' | 'onCallTool' | 'onReadResource' | 'onFallbackRequest' | 'onMessage' | 'onOpenLink' | 'onLoggingMessage' | 'onSizeChanged' | 'onError'> {
227
231
  name: string;
232
+ toolResourceUri?: string;
233
+ html?: string;
228
234
  input?: Record<string, unknown>;
229
235
  result?: unknown;
230
- status: 'executing' | 'inProgress' | 'complete' | 'idle';
231
- /** Custom CSS class for the container */
236
+ status?: 'executing' | 'inProgress' | 'complete' | 'idle';
237
+ toolInputPartial?: any;
238
+ toolCancelled?: boolean;
232
239
  className?: string;
240
+ loader?: React$1.ReactNode;
233
241
  }
234
242
  /**
235
- * Simple hook to get MCP app metadata
236
- *
237
- * @param mcpClient - The MCP client from useMcp() or context
238
- * @returns Object with getAppMetadata function and McpAppRenderer component
239
- *
240
- * @example
241
- * ```tsx
242
- * function ToolRenderer(props) {
243
- * const { getAppMetadata, McpAppRenderer } = useMcpApps(mcpClient);
244
- * const metadata = getAppMetadata(props.name);
243
+ * Helpers scoped to one `mcpClient`. Pass the client here once; `McpAppRenderer` only needs per-tool props (`name`, `input`, `result`, `status`).
245
244
  *
246
- * if (!metadata) return null;
247
- * return (
248
- * <McpAppRenderer
249
- * metadata={metadata}
250
- * input={props.args}
251
- * result={props.result}
252
- * status={props.status}
253
- * />
254
- * );
255
- * }
256
- * ```
245
+ * @param mcpClient - From `useMcp()` or context (for example `useMcpContext()`).
257
246
  */
258
247
  declare function useMcpApps(mcpClient: McpClient | null): {
259
248
  getAppMetadata: (toolName: string) => McpAppMetadata | undefined;
260
- McpAppRenderer: React$1.NamedExoticComponent<McpAppRendererProps>;
249
+ McpAppRenderer: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<McpAppRendererProps & React$1.RefAttributes<McpAppRendererHandle>>>;
261
250
  };
262
251
 
263
- export { AppHost, type McpClient$1 as McpClient, type McpConnection, McpConnectionEvent, McpConnectionState, SSEClient, ToolInfo, type UseMcpOptions, useAppHost, useMcp, useMcpApps };
252
+ export { AppHost, type McpAppMetadata, type McpAppRendererHandle, type McpAppRendererProps, type McpClient$1 as McpClient, type McpConnection, McpConnectionEvent, McpConnectionState, SSEClient, ToolInfo, type UseMcpOptions, useAppHost, useMcp, useMcpApps };