mcp-use 2.0.0-beta.63 → 2.0.0-beta.65

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 (42) hide show
  1. package/dist/bin.js +1 -1
  2. package/dist/{chunk-VJ4S2BU7.js → chunk-ZG2PVYTM.js} +1 -1
  3. package/dist/context.d.ts +7 -0
  4. package/dist/index-node.js +14 -12
  5. package/dist/index.d.ts +10 -7
  6. package/dist/index.js +1 -1
  7. package/dist/internal/usage.js +1 -1
  8. package/dist/landing.d.ts +17 -4
  9. package/dist/middleware/mcp-middleware.d.ts +18 -0
  10. package/dist/next/config.d.ts +33 -4
  11. package/dist/next/handler.d.ts +16 -0
  12. package/dist/next/index.d.ts +5 -0
  13. package/dist/node-bridge.d.ts +33 -4
  14. package/dist/oauth/auth0.d.ts +24 -0
  15. package/dist/oauth/better-auth.d.ts +23 -0
  16. package/dist/oauth/clerk.d.ts +26 -0
  17. package/dist/oauth/keycloak.d.ts +28 -0
  18. package/dist/oauth/provider.d.ts +17 -1
  19. package/dist/oauth/supabase.d.ts +36 -1
  20. package/dist/oauth/workos.d.ts +27 -0
  21. package/dist/react/components/error-boundary.d.ts +3 -0
  22. package/dist/react/components/theme-provider.d.ts +4 -3
  23. package/dist/react/hooks/use-view-tool.d.ts +3 -3
  24. package/dist/react/index.d.ts +5 -13
  25. package/dist/react/index.js +7 -177
  26. package/dist/react/runtime/bootstrap-view.d.ts +3 -3
  27. package/dist/react/runtime/view-runtime.d.ts +0 -2
  28. package/dist/react/types/file-types.d.ts +2 -0
  29. package/dist/react/types/host-types.d.ts +2 -0
  30. package/dist/response-helpers.d.ts +8 -0
  31. package/dist/server.d.ts +2 -0
  32. package/dist/views/types.d.ts +3 -3
  33. package/package.json +8 -12
  34. package/dist/chunk-4TTKTNKI.js +0 -1
  35. package/dist/chunk-ZBN5QPYD.js +0 -1
  36. package/dist/compat-v1/oauth.d.ts +0 -37
  37. package/dist/compat-v1.d.ts +0 -528
  38. package/dist/compat-v1.js +0 -43
  39. package/dist/landing-handler-2IDA43KU.js +0 -630
  40. package/dist/mcp-proxy-O6GLK2IL.js +0 -2
  41. package/dist/public-route-GWDSKOSN.js +0 -1
  42. package/dist/react/compat-v1.d.ts +0 -221
@@ -1,20 +1,37 @@
1
+ /**
2
+ * Verify Keycloak access tokens for an mcp-use resource server.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  import { type OAuthProvider, type OAuthResourceOptions } from "./provider.js";
2
7
  /** Verified Keycloak user and role claims exposed to authenticated MCP callbacks. */
3
8
  export interface KeycloakOAuthUser {
9
+ /** Keycloak subject identifier. */
4
10
  id: string;
11
+ /** Primary email address, when included in the access token. */
5
12
  email?: string;
13
+ /** Display name, when included in the access token. */
6
14
  name?: string;
15
+ /** Preferred username, when included in the access token. */
7
16
  preferredUsername?: string;
17
+ /** Given name, when included in the access token. */
8
18
  givenName?: string;
19
+ /** Family name, when included in the access token. */
9
20
  familyName?: string;
21
+ /** Whether Keycloak has verified {@link KeycloakOAuthUser.email}. */
10
22
  emailVerified?: boolean;
23
+ /** Realm roles from `realm_access.roles`. */
11
24
  roles: string[];
25
+ /** Unmodified `realm_access` claim, when present. */
12
26
  realmAccess?: Record<string, unknown>;
27
+ /** Unmodified `resource_access` claim, when present. */
13
28
  resourceAccess?: Record<string, unknown>;
14
29
  }
15
30
  /** Configures Keycloak JWT verification and protected-resource metadata. */
16
31
  export interface KeycloakOAuthProviderOptions extends OAuthResourceOptions {
32
+ /** Base URL of the Keycloak server. */
17
33
  serverUrl: URL | string;
34
+ /** Keycloak realm that issues accepted access tokens. */
18
35
  realm: string;
19
36
  }
20
37
  /**
@@ -22,5 +39,16 @@ export interface KeycloakOAuthProviderOptions extends OAuthResourceOptions {
22
39
  *
23
40
  * @param options - Keycloak server URL, realm, and resource-server settings.
24
41
  * @returns A provider that rejects tokens not issued for the resolved MCP resource.
42
+ * @throws A `TypeError` if `serverUrl` or `realm` is invalid.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { oauthKeycloakProvider } from "mcp-use/oauth/keycloak";
47
+ *
48
+ * const oauth = oauthKeycloakProvider({
49
+ * serverUrl: "https://keycloak.example.com",
50
+ * realm: "production",
51
+ * });
52
+ * ```
25
53
  */
26
54
  export declare function oauthKeycloakProvider(options: KeycloakOAuthProviderOptions): OAuthProvider<KeycloakOAuthUser>;
@@ -30,7 +30,7 @@ export interface CustomOAuthProviderOptions<TUser> extends OAuthResourceOptions
30
30
  /** Maps verified SDK auth information into mcp-use callback identity data. */
31
31
  mapAuthInfo: (authInfo: OAuthAuthInfo) => OAuthExtra<TUser>;
32
32
  }
33
- /** OAuth resource-server provider accepted by {@link MCPServer}. */
33
+ /** OAuth resource-server provider accepted by the mcp-use server constructor. */
34
34
  export type OAuthProvider<TUser> = CustomOAuthProviderOptions<TUser>;
35
35
  /**
36
36
  * Creates an OAuth provider backed by an external authorization server.
@@ -38,5 +38,21 @@ export type OAuthProvider<TUser> = CustomOAuthProviderOptions<TUser>;
38
38
  * @typeParam TUser - Application user type exposed to authenticated callbacks.
39
39
  * @param options - Token verification, discovery metadata, and identity mapping.
40
40
  * @returns A provider for an OAuth-enabled MCP server.
41
+ * @throws A `TypeError` if provider metadata or resource settings are invalid.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * import { oauthCustomProvider } from "mcp-use/oauth";
46
+ *
47
+ * const oauth = oauthCustomProvider({
48
+ * createTokenVerifier: (resource) => tokenVerifierFor(resource),
49
+ * oauthMetadata,
50
+ * mapAuthInfo: (authInfo) => ({
51
+ * user: { id: authInfo.clientId },
52
+ * payload: {},
53
+ * permissions: [],
54
+ * }),
55
+ * });
56
+ * ```
41
57
  */
42
58
  export declare function oauthCustomProvider<TUser>(options: CustomOAuthProviderOptions<TUser>): OAuthProvider<TUser>;
@@ -1,28 +1,52 @@
1
+ /**
2
+ * Verify Supabase access tokens for an mcp-use resource server.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  import { type OAuthProvider, type OAuthResourceOptions } from "./provider.js";
2
7
  /** Verified Supabase user claims exposed to authenticated MCP callbacks. */
3
8
  export interface SupabaseOAuthUser {
9
+ /** Supabase user identifier. */
4
10
  id: string;
11
+ /** Primary email address, when included in the access token. */
5
12
  email?: string;
13
+ /** Display name from `user_metadata.name`. */
6
14
  name?: string;
15
+ /** Full name from `user_metadata.full_name`. */
7
16
  fullName?: string;
17
+ /** Username from `user_metadata.username`. */
8
18
  username?: string;
19
+ /** Profile image URL from `user_metadata.avatar_url`. */
9
20
  avatarUrl?: string;
21
+ /** Supabase Postgres role from the access token. */
10
22
  role?: string;
23
+ /** Authenticator assurance level for the session. */
11
24
  aal?: string;
25
+ /** Authentication methods used for the session. */
12
26
  amr: SupabaseAmr[];
27
+ /** Supabase session identifier. */
13
28
  sessionId?: string;
14
29
  }
15
30
  /** A verified Supabase authentication-method reference. */
16
31
  export interface SupabaseAmr {
32
+ /** Authentication method name, such as `password` or `totp`. */
17
33
  method: string;
34
+ /** Unix timestamp at which the authentication method was completed. */
18
35
  timestamp?: number;
19
36
  }
20
37
  /** Configures Supabase JWT verification and protected-resource metadata. */
21
38
  export interface SupabaseOAuthProviderOptions extends OAuthResourceOptions {
39
+ /** Supabase project identifier used to derive `supabaseUrl`. */
22
40
  projectId?: string;
41
+ /** Full Supabase project URL. Takes precedence over `projectId`. */
23
42
  supabaseUrl?: URL | string;
43
+ /** Legacy HS256 JWT secret. Omit to verify ES256 tokens against project JWKS. */
24
44
  jwtSecret?: string;
25
- /** Expected access-token audience. Defaults to Supabase's `authenticated`. */
45
+ /**
46
+ * Expected access-token audience.
47
+ *
48
+ * @defaultValue `"authenticated"`
49
+ */
26
50
  audience?: string;
27
51
  }
28
52
  /**
@@ -30,5 +54,16 @@ export interface SupabaseOAuthProviderOptions extends OAuthResourceOptions {
30
54
  *
31
55
  * @param options - Supabase project or URL, optional JWT secret/audience, and resource-server settings.
32
56
  * @returns A provider that rejects tokens without a valid configured Supabase signature and issuer.
57
+ * @throws A `TypeError` if project settings are invalid, `audience` is empty,
58
+ * or `jwtSecret` is shorter than 32 bytes.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { oauthSupabaseProvider } from "mcp-use/oauth/supabase";
63
+ *
64
+ * const oauth = oauthSupabaseProvider({
65
+ * projectId: "example-project",
66
+ * });
67
+ * ```
33
68
  */
34
69
  export declare function oauthSupabaseProvider(options: SupabaseOAuthProviderOptions): OAuthProvider<SupabaseOAuthUser>;
@@ -1,20 +1,37 @@
1
+ /**
2
+ * Verify WorkOS AuthKit access tokens for an mcp-use resource server.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  import { type OAuthProvider, type OAuthResourceOptions } from "./provider.js";
2
7
  /** Verified WorkOS user and organization claims exposed to authenticated MCP callbacks. */
3
8
  export interface WorkOSOAuthUser {
9
+ /** WorkOS subject identifier. */
4
10
  id: string;
11
+ /** Primary email address, when included in the access token. */
5
12
  email?: string;
13
+ /** Whether WorkOS has verified {@link WorkOSOAuthUser.email}. */
6
14
  emailVerified?: boolean;
15
+ /** Display name, when included in the access token. */
7
16
  name?: string;
17
+ /** Preferred username, when included in the access token. */
8
18
  preferredUsername?: string;
19
+ /** Given name, when included in the access token. */
9
20
  firstName?: string;
21
+ /** Family name, when included in the access token. */
10
22
  lastName?: string;
23
+ /** Profile image URL, when included in the access token. */
11
24
  picture?: string;
25
+ /** Roles from the access token's `roles` claim. */
12
26
  roles: string[];
27
+ /** Active WorkOS organization identifier. */
13
28
  organizationId?: string;
29
+ /** WorkOS session identifier. */
14
30
  sessionId?: string;
15
31
  }
16
32
  /** Configures WorkOS JWT verification and protected-resource metadata. */
17
33
  export interface WorkOSOAuthProviderOptions extends OAuthResourceOptions {
34
+ /** AuthKit subdomain, with or without the `https://` scheme. */
18
35
  subdomain: string;
19
36
  }
20
37
  /**
@@ -22,5 +39,15 @@ export interface WorkOSOAuthProviderOptions extends OAuthResourceOptions {
22
39
  *
23
40
  * @param options - WorkOS AuthKit origin and resource-server settings.
24
41
  * @returns A provider that rejects tokens not issued for the resolved MCP resource.
42
+ * @throws A `TypeError` if `subdomain` is empty or uses a non-HTTPS URL.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { oauthWorkOSProvider } from "mcp-use/oauth/workos";
47
+ *
48
+ * const oauth = oauthWorkOSProvider({
49
+ * subdomain: "example.authkit.app",
50
+ * });
51
+ * ```
25
52
  */
26
53
  export declare function oauthWorkOSProvider(options: WorkOSOAuthProviderOptions): OAuthProvider<WorkOSOAuthUser>;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  interface ErrorBoundaryProps {
3
+ /** View subtree protected by the boundary. */
3
4
  children: React.ReactNode;
4
5
  /** Custom fallback when an error is caught. */
5
6
  fallback?: React.ReactNode | ((error: Error) => React.ReactNode);
@@ -15,11 +16,13 @@ export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, {
15
16
  error: Error | null;
16
17
  }> {
17
18
  constructor(props: ErrorBoundaryProps);
19
+ /** Records a render failure for the fallback render pass. */
18
20
  static getDerivedStateFromError(error: Error): {
19
21
  hasError: boolean;
20
22
  error: Error;
21
23
  };
22
24
  componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
25
+ /** Renders the child tree or the configured error fallback. */
23
26
  render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
24
27
  }
25
28
  export {};
@@ -2,14 +2,15 @@ import React from "react";
2
2
  /**
3
3
  * Applies host theme, style variables, and fonts to the document root.
4
4
  *
5
- * Subscribes to the host channel (theme, `styles.variables`, `styles.css.fonts`)
6
- * via {@link useHostContextSubscription}. Theme-only consumers should use
7
- * {@link useViewTheme} instead so locale/dimension updates do not rerender them.
5
+ * Subscribes to the runtime's host-context channel for theme,
6
+ * `styles.variables`, and `styles.css.fonts`. Theme-only consumers should use
7
+ * {@link useViewTheme} so locale and dimension updates do not rerender them.
8
8
  *
9
9
  * MCP App views render in srcdoc iframes; the document canvas stays transparent
10
10
  * by default so rounded cards do not expose an opaque `color-scheme` backdrop.
11
11
  */
12
12
  export declare const ThemeProvider: React.FC<{
13
+ /** View subtree that receives the host theme. */
13
14
  children: React.ReactNode;
14
15
  /** Set `color-scheme` on the document root to match the active theme. */
15
16
  colorScheme?: boolean;
@@ -20,9 +20,9 @@ export type ViewToolDefinition = Pick<ToolDefinition, "name" | "title" | "descri
20
20
  * the ext-apps handle's `update()`, passing explicit `undefined` so omitted
21
21
  * fields are cleared. Toggling `enabled` calls `enable()` / `disable()`
22
22
  * without re-registering. The handler is kept in a ref so calls always see
23
- * current React state. Registration goes through
24
- * {@link McpAppRuntime.registerViewTool} (never `app.registerTool` directly)
25
- * so the runtime can perform the empty-handler handoff on first registration.
23
+ * current React state. Registration goes through the document runtime rather
24
+ * than the guest App directly, allowing the runtime to perform the
25
+ * empty-handler handoff on first registration.
26
26
  *
27
27
  * Cleanup captures the registration handle inside the effect so an older
28
28
  * cleanup cannot remove a newer registration (e.g. after a rapid `name`
@@ -1,11 +1,10 @@
1
1
  /**
2
- * React view runtime for MCP Apps (`mcp-use/react`).
2
+ * Build MCP App views with React components and hooks.
3
3
  *
4
- * Browser-only — built on the ext-apps guest `App` class. Layout:
5
- * `types/` (the zero-codegen typing layer and vendored host types),
6
- * `runtime/` (per-document `McpAppRuntime`, snapshots, and iframe bootstrap),
7
- * `hooks/` (the user-facing hook surface), and `components/`
8
- * (provider/utility components).
4
+ * This browser-only entry point provides the view runtime, typed tool context,
5
+ * host integration hooks, and reusable view components.
6
+ *
7
+ * @packageDocumentation
9
8
  */
10
9
  export { bootstrapView, disposeView, type ViewModule, } from "./runtime/bootstrap-view.js";
11
10
  export { type ViewConfig } from "./runtime/view-config.js";
@@ -26,13 +25,6 @@ export { useViewState } from "./hooks/use-view-state.js";
26
25
  export { useToolContext, type ToolContextHandle, } from "./hooks/use-tool-context.js";
27
26
  export { useViewTool, type ViewToolDefinition } from "./hooks/use-view-tool.js";
28
27
  export { type DeepPartial, type Register, type RegisteredTools, } from "./types/register.js";
29
- /**
30
- * Deprecated temporary v1 widget compatibility. New views must use the
31
- * focused native v2 hooks exported above. Removed in mcp-use v3.
32
- *
33
- * @deprecated Use the native v2 view exports above. Removed in mcp-use v3.
34
- */
35
- export { McpUseProvider, WidgetControls, useWidget, useWidgetProps, useWidgetState, useWidgetTheme, type CallToolResponse, type McpUseProviderProps, type SafeArea, type Theme, type UnknownObject, type UseWidgetResult, type UserAgent, type WidgetMetadata, } from "./compat-v1.js";
36
28
  export type { FileMetadata, UseFilesResult } from "./types/file-types.js";
37
29
  export type { DisplayMode, HostCapabilities, HostContext, HostInfo, SafeAreaInsets, } from "./types/host-types.js";
38
30
  export { ToolError, toolResultText, type CallToolResult, type CallToolSuccess, type ToolContextError, } from "./types/result-types.js";
@@ -9,6 +9,7 @@ var ErrorBoundary = class extends React.Component {
9
9
  super(props);
10
10
  this.state = { hasError: false, error: null };
11
11
  }
12
+ /** Records a render failure for the fallback render pass. */
12
13
  static getDerivedStateFromError(error) {
13
14
  return { hasError: true, error };
14
15
  }
@@ -16,6 +17,7 @@ var ErrorBoundary = class extends React.Component {
16
17
  console.error("[mcp-use] View error:", error, errorInfo);
17
18
  this.props.onError?.(error, errorInfo);
18
19
  }
20
+ /** Renders the child tree or the configured error fallback. */
19
21
  render() {
20
22
  if (this.state.hasError && this.state.error) {
21
23
  if (this.props.fallback !== void 0) {
@@ -457,7 +459,6 @@ var defaultToolSnapshot = {
457
459
  toolOutput: void 0,
458
460
  content: void 0,
459
461
  toolInput: void 0,
460
- isToolInputPartial: false,
461
462
  meta: void 0,
462
463
  error: void 0
463
464
  };
@@ -599,17 +600,11 @@ function createMcpAppRuntime(config, options) {
599
600
  function installRuntimeEventHandlers(app2) {
600
601
  app2.ontoolinput = (params) => {
601
602
  if (disposed || toolSnapshot.status !== "pending") return;
602
- patchTool({
603
- toolInput: params.arguments ?? {},
604
- isToolInputPartial: false
605
- });
603
+ patchTool({ toolInput: params.arguments ?? {} });
606
604
  };
607
605
  app2.ontoolinputpartial = (params) => {
608
606
  if (disposed || toolSnapshot.status !== "pending") return;
609
- patchTool({
610
- toolInput: params.arguments ?? {},
611
- isToolInputPartial: true
612
- });
607
+ patchTool({ toolInput: params.arguments ?? {} });
613
608
  };
614
609
  app2.ontoolresult = (params) => {
615
610
  if (disposed || toolSnapshot.status !== "pending") return;
@@ -625,8 +620,7 @@ function createMcpAppRuntime(config, options) {
625
620
  error: new ToolError(result),
626
621
  toolOutput: void 0,
627
622
  content,
628
- meta,
629
- isToolInputPartial: false
623
+ meta
630
624
  });
631
625
  return;
632
626
  }
@@ -635,8 +629,7 @@ function createMcpAppRuntime(config, options) {
635
629
  error: void 0,
636
630
  toolOutput: params.structuredContent,
637
631
  content,
638
- meta,
639
- isToolInputPartial: false
632
+ meta
640
633
  });
641
634
  };
642
635
  app2.ontoolcancelled = () => {
@@ -1617,172 +1610,13 @@ function useViewTool(definition, handler) {
1617
1610
  }
1618
1611
  }, [enabled]);
1619
1612
  }
1620
-
1621
- // src/react/compat-v1.tsx
1622
- import {
1623
- StrictMode,
1624
- useCallback as useCallback5,
1625
- useEffect as useEffect4,
1626
- useMemo as useMemo2,
1627
- useRef as useRef5,
1628
- useState as useState4
1629
- } from "react";
1630
- import { jsx as jsx8 } from "react/jsx-runtime";
1631
- function McpUseProvider({
1632
- children,
1633
- debugger: enableDebugger = false,
1634
- viewControls = false,
1635
- colorScheme = true
1636
- }) {
1637
- let content = children;
1638
- if (enableDebugger || viewControls) {
1639
- content = /* @__PURE__ */ jsx8(ViewControls, { debugger: enableDebugger, viewControls, children: content });
1640
- }
1641
- return /* @__PURE__ */ jsx8(StrictMode, { children: /* @__PURE__ */ jsx8(ThemeProvider, { colorScheme, children: content }) });
1642
- }
1643
- function useWidget(defaultProps) {
1644
- const runtime = useViewRuntime();
1645
- const tool = useToolContext();
1646
- const host = useHostContext();
1647
- const display = useDisplayMode();
1648
- const [state, setLocalState] = useState4(null);
1649
- const stateRef = useRef5(null);
1650
- const stateUpdateQueue = useRef5(Promise.resolve());
1651
- const structured = tool.status === "ready" && isRecord(tool.toolOutput) ? tool.toolOutput : void 0;
1652
- const input = isRecord(tool.toolInput) ? tool.toolInput : {};
1653
- const props = useMemo2(
1654
- () => ({
1655
- ...isRecord(defaultProps) ? defaultProps : {},
1656
- ...input,
1657
- ...structured ?? {}
1658
- }),
1659
- [defaultProps, input, structured]
1660
- );
1661
- const callTool = useCallback5(
1662
- async (name, args) => {
1663
- const result = await runtime.callServerTool({ name, arguments: args });
1664
- return {
1665
- ...result,
1666
- result: result.content.flatMap(
1667
- (block) => block.type === "text" && "text" in block ? [block.text] : []
1668
- ).join("\n")
1669
- };
1670
- },
1671
- [runtime]
1672
- );
1673
- const setState = useCallback5(
1674
- async (next) => {
1675
- const resolved = typeof next === "function" ? next(stateRef.current) : next;
1676
- stateRef.current = resolved;
1677
- setLocalState(resolved);
1678
- const update = stateUpdateQueue.current.then(async () => {
1679
- const app = await runtime.connect();
1680
- if (app.getHostCapabilities()?.updateModelContext !== void 0) {
1681
- await app.updateModelContext({
1682
- content: [{ type: "text", text: JSON.stringify(resolved) }],
1683
- structuredContent: resolved
1684
- });
1685
- }
1686
- });
1687
- stateUpdateQueue.current = update.catch(() => {
1688
- });
1689
- await update;
1690
- },
1691
- [runtime]
1692
- );
1693
- const sendFollowUpMessage = useCallback5(
1694
- async (content) => {
1695
- await runtime.sendMessage({
1696
- role: "user",
1697
- content: typeof content === "string" ? [{ type: "text", text: content }] : content
1698
- });
1699
- },
1700
- [runtime]
1701
- );
1702
- const openExternal = useCallback5(
1703
- (href) => {
1704
- void runtime.openLink({ url: href });
1705
- },
1706
- [runtime]
1707
- );
1708
- const requestDisplayMode = useCallback5(
1709
- async (mode) => {
1710
- await display.requestDisplayMode({ mode });
1711
- return { mode };
1712
- },
1713
- [display]
1714
- );
1715
- const pendingInput = tool.status === "pending" && runtime.getToolSnapshot().isToolInputPartial && Object.keys(input).length > 0;
1716
- const browserPlatform = host.platform === "mobile" ? "mobile" : "desktop";
1717
- const publicUrl = typeof window === "undefined" ? "" : window.__mcpPublicUrl ?? "";
1718
- return {
1719
- props,
1720
- isPending: tool.status === "pending",
1721
- toolInput: input,
1722
- output: structured ?? null,
1723
- metadata: tool.status === "ready" || tool.status === "error" ? tool.meta ?? null : null,
1724
- state,
1725
- setState,
1726
- theme: host.theme,
1727
- displayMode: host.displayMode,
1728
- safeArea: { insets: host.safeArea },
1729
- maxHeight: host.maxHeight ?? 600,
1730
- ...host.maxWidth !== void 0 && { maxWidth: host.maxWidth },
1731
- userAgent: {
1732
- device: { type: browserPlatform },
1733
- capabilities: {
1734
- hover: typeof window !== "undefined" && window.matchMedia("(hover: hover)").matches,
1735
- touch: typeof navigator !== "undefined" && navigator.maxTouchPoints > 0
1736
- }
1737
- },
1738
- locale: host.locale,
1739
- timeZone: host.timeZone,
1740
- mcp_url: publicUrl,
1741
- callTool,
1742
- sendFollowUpMessage,
1743
- openExternal,
1744
- requestDisplayMode,
1745
- isAvailable: host.isAvailable,
1746
- partialToolInput: pendingInput ? input : null,
1747
- isStreaming: pendingInput,
1748
- ...host.hostInfo !== void 0 && { hostInfo: host.hostInfo },
1749
- ...host.hostCapabilities !== void 0 && {
1750
- hostCapabilities: host.hostCapabilities
1751
- },
1752
- ...host.hostContext !== void 0 && {
1753
- hostContext: host.hostContext
1754
- }
1755
- };
1756
- }
1757
- function useWidgetProps(defaultProps) {
1758
- return useWidget(defaultProps).props;
1759
- }
1760
- function useWidgetTheme() {
1761
- return useViewTheme();
1762
- }
1763
- function useWidgetState(defaultState) {
1764
- const widget = useWidget();
1765
- const { isAvailable, setState, state } = widget;
1766
- useEffect4(() => {
1767
- if (state === null && defaultState !== void 0 && isAvailable) {
1768
- void setState(defaultState);
1769
- }
1770
- }, [defaultState, isAvailable, setState, state]);
1771
- return [state, setState];
1772
- }
1773
- var WidgetControls = ViewControls;
1774
- function isRecord(value) {
1775
- return typeof value === "object" && value !== null && !Array.isArray(value);
1776
- }
1777
1613
  export {
1778
1614
  ErrorBoundary,
1779
1615
  Image,
1780
- McpUseProvider,
1781
1616
  ModelContext,
1782
1617
  ThemeProvider,
1783
1618
  ToolError,
1784
1619
  ViewControls,
1785
- WidgetControls,
1786
1620
  bootstrapView,
1787
1621
  disposeView,
1788
1622
  toolResultText,
@@ -1797,9 +1631,5 @@ export {
1797
1631
  useToolContext,
1798
1632
  useViewState,
1799
1633
  useViewTheme,
1800
- useViewTool,
1801
- useWidget,
1802
- useWidgetProps,
1803
- useWidgetState,
1804
- useWidgetTheme
1634
+ useViewTool
1805
1635
  };
@@ -57,12 +57,12 @@ export interface BootstrapViewOptions {
57
57
  */
58
58
  export declare function bootstrapView(module: ViewModule, options?: BootstrapViewOptions): void;
59
59
  /**
60
- * Unmount the document's view and dispose its {@link McpAppRuntime}.
60
+ * Unmount the document's view and dispose its guest MCP App runtime.
61
61
  *
62
62
  * React unmounts first so hook cleanup (e.g. {@link useViewTool} removal) can
63
63
  * run while the App connection still exists; then the runtime closes the App
64
- * and transport. After this resolves, {@link bootstrapView} may create a
65
- * fresh runtime.
64
+ * and transport. After this resolves, the view bootstrap can create a fresh
65
+ * runtime.
66
66
  *
67
67
  * No-ops when nothing is mounted.
68
68
  *
@@ -29,8 +29,6 @@ export interface ToolSnapshot {
29
29
  * notifications replace the same snapshot; last write wins.
30
30
  */
31
31
  toolInput: Record<string, unknown> | undefined;
32
- /** Whether the latest pending input notification was progressive/partial. */
33
- isToolInputPartial: boolean;
34
32
  /** View-only result `_meta` channel. */
35
33
  meta: Record<string, unknown> | undefined;
36
34
  /**
@@ -1,5 +1,6 @@
1
1
  /** Opaque file reference returned by {@link useFiles}. */
2
2
  export type FileMetadata = {
3
+ /** Host-assigned opaque file identifier. */
3
4
  fileId: string;
4
5
  };
5
6
  /** Value returned by {@link useFiles}. */
@@ -10,6 +11,7 @@ export interface UseFilesResult {
10
11
  upload(file: File): Promise<FileMetadata>;
11
12
  /** Request a temporary download URL for an uploaded file. */
12
13
  getDownloadUrl(file: FileMetadata): Promise<{
14
+ /** Temporary URL from which the file can be downloaded. */
13
15
  downloadUrl: string;
14
16
  }>;
15
17
  }
@@ -7,7 +7,9 @@ export type SafeAreaInsets = NonNullable<McpUiHostContext["safeAreaInsets"]>;
7
7
  * Host application identity from the initialization handshake.
8
8
  */
9
9
  export type HostInfo = {
10
+ /** Host product name. */
10
11
  name: string;
12
+ /** Host product version. */
11
13
  version: string;
12
14
  };
13
15
  /**
@@ -9,9 +9,13 @@ import type { CallToolResult } from "@modelcontextprotocol/server";
9
9
  */
10
10
  export interface TypedCallToolResult<T extends Record<string, unknown> = Record<string, unknown>> {
11
11
  [x: string]: unknown;
12
+ /** Model-visible content blocks. */
12
13
  content: CallToolResult["content"];
14
+ /** Whether the result represents a tool-domain error. */
13
15
  isError?: CallToolResult["isError"];
16
+ /** Protocol extension metadata. */
14
17
  _meta?: CallToolResult["_meta"];
18
+ /** Typed structured payload. */
15
19
  structuredContent?: T;
16
20
  }
17
21
  /**
@@ -22,9 +26,13 @@ export interface TypedCallToolResult<T extends Record<string, unknown> = Record<
22
26
  */
23
27
  export interface ToolContentResult {
24
28
  [x: string]: unknown;
29
+ /** Model-visible content blocks. */
25
30
  content: CallToolResult["content"];
31
+ /** Whether the result represents a tool-domain error. */
26
32
  isError?: CallToolResult["isError"];
33
+ /** Protocol extension metadata. */
27
34
  _meta?: CallToolResult["_meta"];
35
+ /** Content-only helpers never provide structured content. */
28
36
  structuredContent?: never;
29
37
  }
30
38
  /**
package/dist/server.d.ts CHANGED
@@ -341,7 +341,9 @@ export declare class MCPServer<TUser = never, TEnv extends Env = Env> {
341
341
  * already mounted the app without Host validation.
342
342
  */
343
343
  listen(port?: number | undefined, options?: ListenOptions): Promise<{
344
+ /** Actual bound port, including an ephemeral port chosen for `0`. */
344
345
  port: number;
346
+ /** HTTP URL of the bound MCP endpoint. */
345
347
  url: string;
346
348
  }>;
347
349
  /**
@@ -41,8 +41,8 @@ export interface InlineViewManifestEntry {
41
41
  /** Discriminant for the embedded bundle shape. */
42
42
  kind: "inline";
43
43
  /**
44
- * Minified ES module source embedded in a `<script type="module">` by
45
- * {@link synthesizeViewDocument}.
44
+ * Minified ES module source embedded in the generated view document's
45
+ * `<script type="module">` element.
46
46
  */
47
47
  js: string;
48
48
  /**
@@ -88,7 +88,7 @@ export interface ExternalViewManifestEntry {
88
88
  * emits origin-absolute Vite URLs.
89
89
  */
90
90
  export type ViewManifestEntry = InlineViewManifestEntry | ExternalViewManifestEntry;
91
- /** Map of view name → registry entry, primed via {@link registerViews}. */
91
+ /** Map of view name to registry entry, primed by `registerViews()`. */
92
92
  export interface ViewsManifest {
93
93
  [viewName: string]: ViewManifestEntry;
94
94
  }