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
47 changes: 46 additions & 1 deletion specification/draft/apps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,13 @@ interface HostCapabilities {
updateModelContext?: SupportedContentBlockModalities;
/** Host supports receiving content messages (ui/message) from the view. */
message?: SupportedContentBlockModalities;
/** Host supports the `send` and `target` options of ui/message. */
messageOptions?: {
/** Host supports `send: false` with `target: "active"`: add the content to the current draft. */
draft?: {};
/** Host supports `target: "new"`. With `draft` also present, `send: false` opens an editable draft in a new conversation. */
newConversation?: {};
};
/**
* Host supports LLM sampling (sampling/createMessage) from the view.
* Mirrors MCP ClientCapabilities.sampling so hosts can pass it through.
Expand Down Expand Up @@ -1195,7 +1202,9 @@ Host behavior:
content: {
type: "text",
text: string
}
},
send?: boolean, // false: add to the user's draft without sending. Default true.
target?: "active" | "new" // Conversation that receives it. Default "active".
}
}

Expand All @@ -1220,6 +1229,41 @@ Host behavior:
* Host SHOULD add the message to the conversation context, preserving the specified role.
* Host MAY request user consent.

**Drafts and new conversations.** By default, `ui/message` sends the message in the conversation that contains the View. Two optional parameters change that, when the Host advertises them in `hostCapabilities.messageOptions`:

| `send` | `target` | Effect | Capability |
| --- | --- | --- | --- |
| `true` (default) | `"active"` (default) | Send in the current conversation (today's behavior) | none |
| `false` | `"active"` | Add the content to the user's current draft, without sending | `draft` |
| `true` | `"new"` | Start a new conversation with the content as its first message | `newConversation` |
| `false` | `"new"` | Open a new conversation with the content as an editable draft | `draft` and `newConversation` |

```typescript
// "Ask about this": put a prompt and the selected item in the user's draft
{
jsonrpc: "2.0",
id: 4,
method: "ui/message",
params: {
role: "user",
content: [
{ type: "text", text: "Compare this part with the M6 hex bolt: " },
{ type: "resource_link", uri: "cad://parts/m8-hex-bolt", name: "M8 hex bolt" }
],
send: false
}
}
```

Host behavior:
* With `send: false`, Host MUST NOT send the content. Host SHOULD append it to the draft and keep what the user has already typed.
* With `target: "new"`, Host starts a new conversation. Host MAY ask the user to confirm before switching to it, and SHOULD do so only after a user action in the View.
* If Host does not support the requested combination, it MUST return an error (or `isError: true`) and MUST NOT send the content instead.
* Non-text content follows `hostCapabilities.message`. Host MAY show `resource_link` and `image` blocks as attachments on the draft.

View behavior:
* View MUST NOT set `send: false` or `target: "new"` unless the matching `hostCapabilities.messageOptions` field is present. A Host that does not support these options ignores them and sends the message.

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

```typescript
Expand Down Expand Up @@ -2705,6 +2749,7 @@ App tools MUST be tied to the app's lifecycle:
### Other risks

- **Social engineering:** UI can still display misleading content. Hosts should clearly indicate sandboxed UI boundaries.
- **Message drafts and new conversations:** `ui/message` with `send: false` lets the user read and edit View-supplied text before it reaches the model, which limits prompt injection through View content. `target: "new"` changes what the user is looking at, so Hosts tie it to a user action in the View.
- **Resource consumption:** Malicious View can consume CPU/memory. Hosts should implement resource limits.

## Reservations in MCP
Expand Down
18 changes: 18 additions & 0 deletions src/app-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,24 @@ describe("App <-> AppBridge integration", () => {
expect(result).toEqual({});
});

it("app.sendMessage passes the send and target options to the host", async () => {
const receivedMessages: unknown[] = [];
bridge.onmessage = async (params) => {
receivedMessages.push(params);
return {};
};

await app.connect(appTransport);
await app.sendMessage({
role: "user",
content: [{ type: "text", text: "Draft from app" }],
send: false,
target: "new",
});

expect(receivedMessages[0]).toMatchObject({ send: false, target: "new" });
});

it("app.sendMessage returns error result when handler indicates error", async () => {
bridge.onmessage = async () => {
return { isError: true };
Expand Down
55 changes: 55 additions & 0 deletions src/generated/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions src/generated/schema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/spec.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ export interface McpUiMessageRequest {
role: "user";
/** @description Message content blocks (text, image, etc.). */
content: ContentBlock[];
/**
* @description Whether to send the message. `false` adds the content to the user's draft without sending it. Default: `true`.
*
* Only set `false` when `hostCapabilities.messageOptions` advertises the matching option: hosts that do not support it send the message.
*/
send?: boolean;
/**
* @description Conversation that receives the message: `"active"`, the one that contains the View (default), or `"new"`, a new conversation.
*
* Only set `"new"` when `hostCapabilities.messageOptions.newConversation` is present.
*/
target?: "active" | "new";
};
}

Expand Down Expand Up @@ -521,6 +533,13 @@ export interface McpUiHostCapabilities {
updateModelContext?: McpUiSupportedContentBlockModalities;
/** @description Host supports receiving content messages (ui/message) from the view. */
message?: McpUiSupportedContentBlockModalities;
/** @description Host supports the `send` and `target` options of ui/message. */
messageOptions?: {
/** @description Host supports `send: false` with `target: "active"`: add the content to the current draft. */
draft?: {};
/** @description Host supports `target: "new"`. With `draft` also present, `send: false` opens an editable draft in a new conversation. */
newConversation?: {};
};
/**
* @description Host supports LLM sampling (sampling/createMessage) from the view.
* Mirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.
Expand Down