Skip to content

feat: modality negotiation for ui/message and ui/update-model-context - #119

Open
idosal wants to merge 10 commits into
mainfrom
fix/ui-message-content
Open

feat: modality negotiation for ui/message and ui/update-model-context#119
idosal wants to merge 10 commits into
mainfrom
fix/ui-message-content

Conversation

@idosal

@idosalidosal commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

The spec defines the ui/message's content as a single message. Passing an array would support additional use cases (e.g., prompting the agent with a text message and an image). This is already the implementation in the ext-apps SDK.

Since ContentBlock supports multi-modal inputs, I've added a modality capability negotiation to allow apps and hosts to pass non-textual inputs to messages and context updates.

See #48

@pkg-pr-new

pkg-pr-newBot commented Dec 10, 2025

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/ext-apps

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/ext-apps@119

@modelcontextprotocol/server-basic-react

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-basic-react@119

@modelcontextprotocol/server-basic-vanillajs

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-basic-vanillajs@119

@modelcontextprotocol/server-budget-allocator

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-budget-allocator@119

@modelcontextprotocol/server-cohort-heatmap

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-cohort-heatmap@119

@modelcontextprotocol/server-customer-segmentation

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-customer-segmentation@119

@modelcontextprotocol/server-map

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-map@119

@modelcontextprotocol/server-pdf

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-pdf@119

@modelcontextprotocol/server-scenario-modeler

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-scenario-modeler@119

@modelcontextprotocol/server-shadertoy

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-shadertoy@119

@modelcontextprotocol/server-sheet-music

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-sheet-music@119

@modelcontextprotocol/server-system-monitor

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-system-monitor@119

@modelcontextprotocol/server-threejs

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-threejs@119

@modelcontextprotocol/server-transcript

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-transcript@119

@modelcontextprotocol/server-video-resource

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-video-resource@119

@modelcontextprotocol/server-wiki-explorer

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-wiki-explorer@119

commit: 5bf54d2

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the ui/message specification with the existing implementation in the ext-apps SDK by changing the content parameter from a single object to an array of content blocks. This enables multi-modal messages such as combining text and images in a single message.

Key changes:

  • Updated ui/message content parameter to accept an array of content blocks instead of a single object
  • Maintains consistency with the existing TypeScript implementation which already uses ContentBlock[] from the MCP SDK
  • Enables the use case mentioned in issue #48 for multi-modal messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadspecification/draft/apps.mdx Outdated
Comment on lines +509 to +514
content: [
{
type: "text",
text: string
}
]

CopilotAIDec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specification should document what content types are supported in the content array. While the PR description mentions supporting images (e.g., "prompting the agent with a text message and an image"), the spec only shows a single text content block.

Consider adding:

  1. A reference to the MCP SDK's ContentBlock type definition
  2. Documentation of supported content types (text, image, etc.)
  3. An example showing multiple content items in the array (e.g., text + image)

This would help implementers understand the full capabilities of this API and align with the stated goal of supporting additional use cases like multi-modal messages.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ochafik I see that the SDK supports ContentBlock as-is. There are types that are extremely cool and open up really interesting use cases, but I'm not sure hosts would know how to support and may require negotiation (e.g., audio, embedded resource). Should we limit it to text (and perhaps image if we add negotiation) for now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@idosal let's just make it all negotiable:

exportinterfaceMcpUiHostCapabilities{/* @description Optional support for ui/message and its content types */messages?: {text?: {};image?: {};audio?: {};resource?: {};resourceLink?: {};}
...
}

cc/ @antonpk1 fyi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@idosal what do you think about that one?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ochafik sounds good. Let's merge this one and I'll open a new one for the negotiation

aharvard added a commit to aaif-goose/goose that referenced this pull request Jan 16, 2026
The MCP Apps draft spec (SEP-1865) has been in flux regarding the
ui/message params.content type. After discussion with the spec authors,
the agreed format is ContentBlock[] (array of content blocks) rather
than a single ContentBlock object.
This change:
- Updates McpMethodParams['ui/message'] to expect content as ContentBlock[]
- Adds ContentBlock type supporting text, image, and resource blocks
- Updates the handler to extract text from the first text block in the array
- Returns empty object {} on success per the spec
Related spec discussions:
- modelcontextprotocol/ext-apps#48
- modelcontextprotocol/ext-apps#119
- MCP-UI-Org/mcp-ui#166
@ochafikochafik added the v1 label Jan 21, 2026
@ochafikochafik added this to the v1 milestone Jan 21, 2026
Comment threadsrc/app.ts Outdated
@idosal
idosal requested a review from ochafikJanuary 23, 2026 13:19
Fixes npm ci failures in CI by updating lock file to match current dependency tree.
Updates hono from 4.11.4 to 4.11.5 and @modelcontextprotocol/sdk to 1.25.3.
@idosalidosal changed the title fix: ui/message accepts message arrayfeat: modality negotiation for ui/message and ui/update-model-contextJan 23, 2026
/** Host supports resource link content blocks. */
resourceLink?: {};
/** Host supports structured content (updateModelContext only). */
structuredContent?: {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is structuredContent here? Looking at this thru the lens of a tool result, structued content is supposed to be a sibling to the unstructured content blocks.

Based on my understanding,updateModelContext would be able to set Content[] and StructuredContent. Please correct me if I'm wrong!

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just Opus doing Opus things. Thanks, great catch!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's actually intentional, not all hosts might support structuredContent, it's a modality of its own (JSON vs. text)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I understand the support rationale... but the point I'm attempting to make is "structured content (JSON) vs unstructured content (text, image, resource, etc)" .... as opposed to just "JSON vs text"

@liadyliadyJan 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aharvard you're right, there's a disambguity here. Perhaps we need a separate SupportedModelContextModalities type for the updateModelContext capability:

interfaceSupportedModelContextModalities{content?: SupportedContentBlockModalities,structuredContent?: {}}

And to remove structuredContent from SupportedContentBlockModalities.
This will make it clearer, closer to the impolementation, and will also remove the need for the (updateModelContext only) comment clarification.

wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that feels right @liady

@ochafikochafikMar 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re/ point above @aharvard@liady@idosal , I think we should keep it simple and just rename to McpUiSupportedContentModalities (then structured content is content)

ochafik
ochafik previously approved these changes Jan 23, 2026

@ochafikochafik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ido!

ochafik
ochafik previously approved these changes Jan 23, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@idosal@ochafik@liady@aharvard