ReadonlyhostCurrent host context
Optional ReadonlytoolCurrent tool input (if any)
Optional ReadonlytoolCurrent tool metadata (if any)
Optional ReadonlytoolCurrent tool output (if any)
ReadonlytoolsTyped tool methods object.
Provides direct method access to tools with the naming convention call{ToolName}.
This is an alternative to using callTool() that provides a more ergonomic API.
OptionalgetGet host capabilities
Returns the capabilities advertised by the host during handshake. Use this to check if features like logging or server tools are supported.
Host capabilities or undefined if not yet connected
Get host version information
Returns the name and version of the host application.
Host version info or undefined if not yet connected
Get persisted widget state On ChatGPT: Returns session-scoped state On MCP Apps: Returns null (silent no-op)
State or null if not set
Log to host console
Log level
Data to log
OptionalnotifyNotify host of widget's intrinsic height (ChatGPT only)
Call this when your widget's content height changes to prevent scroll clipping. The host will adjust the container accordingly.
Widget height in pixels
Subscribe to host context changes
Callback for context changes
Unsubscribe function
Subscribe to teardown events
Callback for teardown
Unsubscribe function
Subscribe to tool cancellation
Callback for cancellation
Unsubscribe function
Subscribe to tool input changes
Callback for tool input
Unsubscribe function
Subscribe to partial/streaming tool input
Called when the host sends partial tool arguments during streaming. Useful for showing real-time input as the user types or as the model generates.
Callback for partial input
Unsubscribe function
Subscribe to tool results
Callback for tool results
Unsubscribe function
Open an external link
URL to open
Read an MCP resource
Resource URI
Resource contents
Request widget close (ChatGPT only, no-op on MCP Apps)
Request a different display mode
Target display mode
Actual mode applied
OptionalrequestRequest a host-owned modal dialog (ChatGPT only)
Spawns a native ChatGPT modal for confirmations, inputs, etc. Returns the user's response when the modal is dismissed.
Modal configuration
User's modal response
Send a follow-up message (convenience alias)
Message text
Send a log message to the host
Unlike the log() method which logs to the local console,
this sends logs through the MCP protocol to the host for
debugging and telemetry purposes.
Log level
Data to log
Send a message to the conversation
Message content
Send size changed notification to host
Notifies the host when the widget's size changes. Use this for manual size reporting.
Size parameters
Set handler for tool calls from the host
When the host calls a tool exposed by this app, this handler will be invoked with the tool name and arguments.
Handler function for tool calls
Set handler for listing app-exposed tools
When the host requests the list of tools this app exposes, this handler will be invoked.
Handler function that returns tool definitions
Set persisted widget state On ChatGPT: Persists session-scoped state On MCP Apps: Silent no-op (graceful degradation)
State to persist
Set up automatic size change notifications
Creates a ResizeObserver that automatically sends size changed notifications to the host when the document body resizes.
Cleanup function to stop observing
Update the host's model context with app state (ext-apps v0.4.0+)
Unlike sendMessage which triggers follow-up actions, context updates inform the model about app state without triggering responses.
Context Persistence:
Platform Implementation Details:
Reserved Keys:
_) in structuredContent are reserved
for internal use and will be filtered outContext content and/or structured content
Optionalupload
Unified client interface for UI code