You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-48Lines changed: 36 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,68 +5,70 @@
5
5
6
6
**mcp-ui** is a TypeScript SDK that adds UI capabilities to the [Model-Context Protocol](https://modelcontextprotocol.io/introduction) (MCP). It provides packages to create interactive HTML components on the server and handle their rendering on the client.
7
7
8
-
The library will evolve as a playground to experiment with the many exciting ideas in the community.
8
+
This project is a playground for new ideas in the MCP community. Expect it to evolve rapidly!
The primary goal is to facilitate the creation and rendering of `HtmlResource` objects. These blocks are designed to be part of an MCP response, allowing a model or tool to send a structured HTML component or URL for a client for display.
14
+
Make it simple to create and render HTML resource blocks. These are special objects you can send in an MCP response, letting your MCP server deliver a structured interactive web component for the host to display.
15
15
16
-
### `HtmlResource`
16
+
### `HtmlResource` at a Glance
17
17
18
-
This is the fundamental object exchanged. It has the following structure (simplified):
18
+
This is the main object exchanged between server and client:
19
19
20
20
```typescript
21
-
interfaceHtmlResourceBlock {
21
+
interfaceHtmlResource {
22
22
type:"resource";
23
23
resource: {
24
-
uri:string; //Primary identifier. e.g., "ui://my-component/1" or "ui-app://my-app/instance-1"
25
-
mimeType:"text/html";// Always text/html for this SDK's purpose
26
-
text?:string; // HTML content or an iframe URL
27
-
blob?:string; // Base64 encoded HTML content or iframe URL
24
+
uri:string; // e.g., "ui://my-component/1" or "ui-app://my-app/instance-1"
25
+
mimeType:"text/html";
26
+
text?:string; // HTML content OR external app URL
27
+
blob?:string; // Base64 encoded HTML content or external app URL
28
28
}
29
29
}
30
30
```
31
31
32
-
***`uri`**: A unique identifier for the resource.
33
-
*`ui://<unique-id>`: Indicates the resource content is self-contained HTML, intended to be rendered directly by the client (e.g., in an iframe sandbox with `srcDoc`). The `text` or `blob` field will contain the HTML string.
34
-
*`ui-app://<app-id>/<instance-id>`: Indicates the resource is an external application or a more complex UI that should be rendered within an iframe using a URL. The `text` or `blob` field will contain the URL for the iframe's `src` attribute.
35
-
***`mimeType`**: For this SDK, it will always be `"text/html"`.
36
-
***`text` vs. `blob`**: This defines how the content (HTML string or URL string) is delivered:
37
-
*`text`: The content is provided as a direct string.
38
-
*`blob`: The content is provided as a Base64 encoded string. This is useful for ensuring content integrity or for embedding larger HTML payloads without issues in JSON.
32
+
-**`uri`**: Uniquely identifies the resource.
33
+
-`ui://...` means the content is self-contained HTML (rendered with `srcDoc` in an iframe).
34
+
-`ui-app://...` means the content is an external app or site (rendered with `src` in an iframe).
35
+
-**`mimeType`**: Always `"text/html"` for this SDK.
36
+
-**`text` vs. `blob`**: Use `text` for direct strings, or `blob` for Base64-encoded content (handy for larger payloads or to avoid JSON issues).
39
37
40
38
## Packages
41
39
42
-
***`@mcp-ui/client`**: Provides React components and hooks for the client-side. The primary component is `<HtmlResource />`.
43
-
***`@mcp-ui/server`**: Includes helper functions for server-side tools to easily construct `HtmlResource` objects.
40
+
-**`@mcp-ui/client`**: React components for the client. The main export is `<HtmlResource />`—just drop it into your app to render MCP HTML resources.
41
+
-**`@mcp-ui/server`**: Helpers for building `HtmlResource` objects on the server.
44
42
45
-
## Getting Started
43
+
## Quickstart
46
44
47
-
1.**Clone the repository.**
48
-
2.**Install dependencies from the monorepo root:**
45
+
1.**Clone the repo:**
46
+
```bash
47
+
git clone https://github.com/idosal/mcp-ui.git
48
+
cd mcp-ui
49
+
```
50
+
2.**Install dependencies:**
49
51
```bash
50
-
pnpm install
52
+
pnpm install
51
53
```
54
+
52
55
## How to Use
53
56
54
57
### Server-Side (`@mcp-ui/server`)
55
58
56
-
Use `createHtmlResource` to construct the resource block.
59
+
Use `createHtmlResource` to build a resource block:
The `@mcp-ui/client` package provides an `<HtmlResource />` component (example path: `packages/client/src/components/HtmlResource.tsx`) designed to render these blocks.
81
-
82
-
**Conceptual Usage:**
82
+
The main export is the `<HtmlResource />` React component. Use it to render any MCP HTML resource block:
See the specific documentation for each package for more detailed API information and advanced usage.
119
-
107
+
For more details and advanced usage, check out the [docs](./docs/src/guide/client/overview.md) and the [HtmlResource component guide](./docs/src/guide/client/html-resource.md).
120
108
121
109
## 👥 Contributing
122
110
123
-
Contributions, feedback, and ideas are more than welcome! Please review the [contribution](https://github.com/idosal/mco-ui/blob/main/.github/CONTRIBUTING.md) guidelines.
111
+
Ideas, feedback, and contributions are always welcome! See the [contribution guidelines](https://github.com/idosal/mco-ui/blob/main/.github/CONTRIBUTING.md).
124
112
125
113
## 📄 License
126
114
127
-
This project is licensed under the [Apache License 2.0](LICENSE).
115
+
Licensed under the [Apache License 2.0](LICENSE).
128
116
129
117
## Disclaimer
130
118
131
-
MCP UI is provided "as is" without warranty of any kind. Authors are not responsible for any damages or issues that may arise from its use.
119
+
MCP UI is provided "as is" with no warranty. Use at your own risk.
0 commit comments