Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions specification/draft/apps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,43 @@ Host behavior:
* Host SHOULD add the message to the conversation context, preserving the specified role.
* Host MAY request user consent.

`ui/follow-up-message` - Send a follow-up message to continue the conversation

```typescript
// Request
{
jsonrpc: "2.0",
id: 3,
method: "ui/follow-up-message",
params: {
content: ContentBlock[] // Message content blocks (text, image, etc.)
}
}

// Success Response
{
jsonrpc: "2.0",
id: 3,
result: {} // Empty result on success
}

// Error Response (if denied or failed)
{
jsonrpc: "2.0",
id: 3,
result: {
isError: true
}
}
```

Use this to continue the conversation based on user interaction with the app or prompt a follow up app. For example, when a user clicks on a data point, the app can send a follow-up message asking for an analysis of that data point, or to display a new app with more details about that data point.

Host behavior:
* Host SHOULD add the message to the conversation context as a user message.
* Host MAY request user consent before sending.
* Host MAY allow user to review and edit the message before sending.

`ui/request-display-mode` - Request host to change display mode

```typescript
Expand Down
44 changes: 44 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { PostMessageTransport } from "./message-transport";
import {
LATEST_PROTOCOL_VERSION,
McpUiAppCapabilities,
McpUiFollowUpMessageRequest,
McpUiFollowUpMessageResultSchema,
McpUiHostCapabilities,
McpUiHostContext,
McpUiHostContextChangedNotification,
Expand Down Expand Up @@ -783,6 +785,48 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
);
}

/**
* Send a follow-up message to the host's chat.
*
* Use this to continue the conversation based on user interaction with the app.
* For example, when a user clicks on a data point, the app can send a follow-up
* message asking for more details about that item.
*
* @param params - Message role and content
* @param options - Request options (timeout, etc.)
* @returns Result indicating success or error
*
* @throws {Error} If the host rejects the request
* @throws {Error} If the request times out or the connection is lost
*
* @example Send a follow-up question based on user interaction
* ```typescript
* try {
* await app.sendFollowUpMessage({
* role: "user",
* content: [{ type: "text", text: "Tell me more about this item" }]
* });
* } catch (error) {
* console.error("Failed to send message:", error);
* }
* ```
*
* @see {@link McpUiFollowUpMessageRequest} for request structure
*/
sendFollowUpMessage(
params: McpUiFollowUpMessageRequest["params"],
options?: RequestOptions,
) {
return this.request(
<McpUiFollowUpMessageRequest>{
method: "ui/follow-up-message",
params,
},
McpUiFollowUpMessageResultSchema,
options,
);
}

/**
* Send log messages to the host for debugging and telemetry.
*
Expand Down
Loading
Loading