You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@mcp-apps-kit/ui-react

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mcp-apps-kit/ui-react

React bindings for MCP applications

Source
npmnpm
Version
0.2.4
Version published
Weekly downloads
9
80%
Maintainers
1
Weekly downloads
 
Created
Source

@mcp-apps-kit/ui-react

npm node license

React bindings for MCP applications.

@mcp-apps-kit/ui-react builds on @mcp-apps-kit/ui to provide React context and hooks for tool calls, tool results, and host context.

Table of Contents

Background

React widgets often need host-aware APIs for tool calls and UI state. This package provides a React-first wrapper around the vanilla UI SDK so you can use hooks instead of manual subscriptions.

Features

  • AppsProvider context wrapper
  • Hooks for tools, host context, and widget state
  • Typed tool calls with generics
  • Optional debug logger hook
  • Host capabilities - Query what the host supports (theming, display modes, file upload, etc.)
  • Size notifications - Automatic resize observer integration
  • Partial tool input - React to streaming tool inputs

Compatibility

  • Hosts: MCP Apps and ChatGPT (OpenAI Apps SDK)
  • Node.js: >= 18 for tooling/builds (browser runtime)
  • Peer dependencies: react and react-dom ^18 || ^19

Install

npm install @mcp-apps-kit/ui-react

Usage

Quick start

import { AppsProvider, useAppsClient, useToolResult, useHostContext } from "@mcp-apps-kit/ui-react";

function Widget() {
  const client = useAppsClient();
  const result = useToolResult();
  const host = useHostContext();

  return (
    <div data-theme={host.theme}>
      <button onClick={() => client.callTool("greet", { name: "Alice" })}>Greet</button>
      <pre>{JSON.stringify(result, null, 2)}</pre>
    </div>
  );
}

export function App() {
  return (
    <AppsProvider>
      <Widget />
    </AppsProvider>
  );
}

Typed tools

import { AppsProvider, useAppsClient } from "@mcp-apps-kit/ui-react";
import type { AppClientTools } from "../server";

function Widget() {
  const client = useAppsClient<AppClientTools>();
  return null;
}

export function App() {
  return (
    <AppsProvider>
      <Widget />
    </AppsProvider>
  );
}

Examples

API

Provider

  • AppsProvider - Context wrapper for all hooks

Core Hooks

HookDescription
useAppsClientClient instance for tool calls
useToolResultCurrent tool result data
useToolInputTool input parameters
useHostContextHost info (theme, viewport, locale, etc.)
useWidgetStatePersisted state across reloads
useDisplayModeFullscreen/panel mode control
useDebugLoggerDebug logging configuration

Host Capabilities & Version

import { useHostCapabilities, useHostVersion } from "@mcp-apps-kit/ui-react";

function Widget() {
  const capabilities = useHostCapabilities();
  const version = useHostVersion();

  // Common capabilities (both platforms)
  const themes = capabilities?.theming?.themes; // ["light", "dark"]
  const modes = capabilities?.displayModes?.modes; // ["inline", "fullscreen", "pip"]

  // MCP Apps specific
  const hasPartialInput = !!capabilities?.partialToolInput;

  // ChatGPT specific
  const hasFileUpload = !!capabilities?.fileUpload;

  // Host version (MCP Apps only)
  // { name: "Claude Desktop", version: "1.0.0" }
  return <div>Host: {version?.name}</div>;
}

Size Notifications (MCP Apps)

import { useSizeChangedNotifications } from "@mcp-apps-kit/ui-react";

function Widget() {
  // Attach to container to auto-report size changes
  const containerRef = useSizeChangedNotifications();

  return <div ref={containerRef}>Content that may resize</div>;
}

Partial Tool Input (MCP Apps)

import { useOnToolInputPartial } from "@mcp-apps-kit/ui-react";

function Widget() {
  useOnToolInputPartial((input) => {
    // React to streaming partial input from the model
    console.log("Partial input:", input);
  });

  return <div>Streaming input widget</div>;
}

Theme & Style Hooks

HookDescription
useHostStyleVariablesApply host-provided CSS variables
useDocumentThemeSync document theme with host
useSafeAreaInsetsSafe area insets (ChatGPT)

Lifecycle Hooks

HookDescription
useOnToolCancelledCallback when tool is cancelled
useOnTeardownCleanup callback before widget removal

File Operations (ChatGPT)

HookDescription
useFileUploadUpload files to host
useFileDownloadGet file download URLs

Layout (ChatGPT)

HookDescription
useIntrinsicHeightSet widget intrinsic height
useViewView management

Modals (ChatGPT)

HookDescription
useModalModal dialog management

Contributing

See ../../CONTRIBUTING.md for development setup and guidelines. Issues and pull requests are welcome.

License

MIT

Keywords

mcp

FAQs

Package last updated on 29 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts