Skip to content
Merged
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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ It accepts the following props:
{ type: 'link', payload: { url: string } }
```
- **`supportedContentTypes`**: Optional array to restrict which content types are allowed (`['rawHtml', 'externalUrl', 'remoteDom']`)
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.
- **`htmlProps`**: Optional props for the `<HTMLResourceRenderer>`
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`remoteDomProps`**: Optional props for the `<RemoteDOMResourceRenderer>`
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.

### Supported Resource Types

Expand Down
16 changes: 8 additions & 8 deletions docs/src/guide/client/resource-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import type { Resource } from '@modelcontextprotocol/sdk/types';
interface UIResourceRendererProps {
resource: Partial<Resource>;
onUIAction?: (result: UIActionResult) => Promise<unknown>;
style?: React.CSSProperties;
iframeProps?: Omit<React.HTMLAttributes<HTMLIFrameElement>, 'src' | 'srcDoc' | 'ref' | 'style'>;
library?: ComponentLibrary;
remoteElements?: RemoteElementConfiguration[];
supportedContentTypes?: ResourceContentType[];
htmlProps?: Omit<HTMLResourceRendererProps, 'resource' | 'onUIAction'>;
remoteDomProps?: Omit<RemoteDOMResourceProps, 'resource' | 'onUIAction'>;
}
```

Expand All @@ -45,10 +43,12 @@ interface UIResourceRendererProps {
{ type: 'link', payload: { url: string } }
```
- **`supportedContentTypes`**: Optional array to restrict which content types are allowed (`['rawHtml', 'externalUrl', 'remoteDom']`)
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.
- **`htmlProps`**: Optional props for the `<HTMLResourceRenderer>`
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`remoteDomProps`**: Optional props for the `<RemoteDOMResourceRenderer>`
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.

## Basic Usage

Expand Down
18 changes: 12 additions & 6 deletions examples/remote-dom-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ function App() {
<UIResourceRenderer
key={`basic-${scriptContent}`}
resource={mockResourceReact}
library={basicComponentLibrary}
remoteElements={remoteElements}
remoteDomProps={{
library: basicComponentLibrary,
remoteElements: remoteElements,
}}
/>
</div>

Expand All @@ -163,8 +165,10 @@ function App() {
<UIResourceRenderer
key={`radix-${scriptContent}`}
resource={mockResourceReact}
library={radixComponentLibrary}
remoteElements={remoteElements}
remoteDomProps={{
library: radixComponentLibrary,
remoteElements: remoteElements,
}}
/>
</div>

Expand All @@ -180,8 +184,10 @@ function App() {
<UIResourceRenderer
key={`webcomponents-${scriptContent}`}
resource={mockResourceWebComponents}
library={basicComponentLibrary}
remoteElements={remoteElements}
remoteDomProps={{
library: basicComponentLibrary,
remoteElements: remoteElements,
}}
/>
</div>
</div>
Expand Down
10 changes: 6 additions & 4 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ It accepts the following props:
{ type: 'link', payload: { url: string } }
```
- **`supportedContentTypes`**: Optional array to restrict which content types are allowed (`['rawHtml', 'externalUrl', 'remoteDom']`)
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.
- **`htmlProps`**: Optional props for the `<HTMLResourceRenderer>`
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`remoteDomProps`**: Optional props for the `<RemoteDOMResourceRenderer>`
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.

### Supported Resource Types

Expand Down
23 changes: 10 additions & 13 deletions packages/client/src/components/UIResourceRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import type { Resource } from '@modelcontextprotocol/sdk/types.js';
import { ResourceContentType } from '../types';
import { ResourceContentType, UIActionResult } from '../types';
import { HTMLResourceRenderer, HTMLResourceRendererProps } from './HTMLResourceRenderer';
import { RemoteDOMResourceProps, RemoteDOMResourceRenderer } from './RemoteDOMResourceRenderer';
import { basicComponentLibrary } from '../remote-dom/component-libraries/basic';

type UIResourceRendererProps = Omit<
HTMLResourceRendererProps & RemoteDOMResourceProps,
'resource'
> & {
type UIResourceRendererProps = {
resource: Partial<Resource>;
onUIAction?: (result: UIActionResult) => Promise<unknown>;
supportedContentTypes?: ResourceContentType[];
htmlProps?: Omit<HTMLResourceRendererProps, 'resource' | 'onUIAction'>;
remoteDomProps?: Omit<RemoteDOMResourceProps, 'resource' | 'onUIAction'>;
};

function getContentType(
Expand All @@ -35,11 +35,9 @@ export const UIResourceRenderer: React.FC<UIResourceRendererProps> = (props) =>
const {
resource,
onUIAction,
style,
iframeProps,
supportedContentTypes,
library,
remoteElements,
htmlProps,
remoteDomProps,
} = props;
const contentType = getContentType(resource);

Expand All @@ -60,17 +58,16 @@ export const UIResourceRenderer: React.FC<UIResourceRendererProps> = (props) =>
<HTMLResourceRenderer
resource={resource}
onUIAction={onUIAction}
style={style}
iframeProps={iframeProps}
{...htmlProps}
/>
);
case 'remoteDom':
return (
<RemoteDOMResourceRenderer
resource={resource}
onUIAction={onUIAction}
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

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

By only mapping library and remoteElements, any future props on RemoteDOMResourceProps will be ignored. Consider spreading ...remoteDomProps and then overriding library and remoteElements to preserve extensibility.

Suggested change
onUIAction={onUIAction}
onUIAction={onUIAction}
{...remoteDomProps}

Copilot uses AI. Check for mistakes.
library={library || basicComponentLibrary}
remoteElements={remoteElements}
library={remoteDomProps?.library || basicComponentLibrary}
{...remoteDomProps}
/>
);
default:
Expand Down
10 changes: 6 additions & 4 deletions packages/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ It accepts the following props:
{ type: 'link', payload: { url: string } }
```
- **`supportedContentTypes`**: Optional array to restrict which content types are allowed (`['rawHtml', 'externalUrl', 'remoteDom']`)
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.
- **`htmlProps`**: Optional props for the `<HTMLResourceRenderer>`
- **`style`**: Optional custom styles for iframe-based resources
- **`iframeProps`**: Optional props passed to iframe elements (for HTML/URL resources)
- **`remoteDomProps`**: Optional props for the `<RemoteDOMResourceRenderer>`
- **`library`**: Optional component library for Remote DOM resources (defaults to `basicComponentLibrary`)
- **`remoteElements`**: Optional remote element definitions for Remote DOM resources. REQUIRED for Remote DOM snippets.

### Supported Resource Types

Expand Down