App Framework

Runtime APIs

Every hook a View can use, from moonpeak, moonpeak/chatgpt and moonpeak/claude.

View .mdEdit on GitHub

Hooks from moonpeak work in every MCP Apps host. Hooks from moonpeak/chatgpt and moonpeak/claude are safe to call anywhere and return empty values outside their host.

Tool data

Hook Returns
useToolData { input, output, content, isPending, isError, isStreaming, isCancelled, tool, result }
useToolInput the tool input
useToolOutput the structured output
useToolResult the raw CallToolResult

Host context

Hook Returns
useTheme "light" | "dark"
useDisplayMode "inline" | "pip" | "fullscreen"
useRequestDisplayMode a function to request a mode, plus available
useHostContext the whole host context
useLocale · useTimeZone locale and IANA time zone
usePlatform · useDeviceCapabilities web/desktop/mobile, touch and hover
useSafeArea · useContainerSize · useMaxHeight layout limits

Host

Hook Returns
useHost { name, version } of the host
useHostCapabilities what the host supports
useConnection { status, ready, error }
useApp the raw MCP Apps SDK App

Actions

Hook Does
useCallTool call a tool on your server through the host
useSendMessage post a message as the user
useUpdateModelContext tell the model something silently
useOpenLink · useDownloadFile · useLog host actions

State

Hook Does
useAppState one state object per View, persisted in ChatGPT, optionally shared with the model
useResultState local state that resets on every new result

Host extras

Hook From
useIsChatGPT, useWidgetState, useOpenAiGlobal, useUploadFile, useRequestModal, useUserAgent moonpeak/chatgpt
useIsClaude, useClaudeStyles moonpeak/claude

Helpers

import { isHost, connect } from "moonpeak";
isHost(useHost(), "claude");   // forgiving host-name check

connect() is called for you when a View mounts. Call it yourself only if you render without moonpeak's entry (for example in a test harness).