当前位置: 首页 > news >正文

[MCP] Consistent

While raw HTML gives us visual interfaces, it has limitations when it comes to creating truly interactive and consistent user experiences. Raw HTML requires you to write all the styling from scratch, handle responsive design manually, and manage complex interactions through custom JavaScript. This leads to inconsistent designs across different UI components and makes it harder to maintain a cohesive user experience.
The solution is Remote DOM, a library from Shopify that allows people to safely render arbitrary HTML from an untrusted source. This is a powerful approach that lets you create UI components using a consistent set of web components that are automatically styled and interactive. Instead of writing raw HTML and CSS, you write JavaScript that creates and manipulates DOM elements using predefined UI components.
Remote DOM uses JavaScript to create and manipulate DOM elements using predefined UI components like ui-stackui-text, and ui-button. These components are automatically styled and provide consistent behavior across the host application.
import { createUIResource } from '@mcp-ui/server'// Create a UI resource with Remote DOM
const resource = createUIResource({uri: 'ui://tag-view/interactive',content: {type: 'remoteDom',framework: 'react',script: `const stack = document.createElement('ui-stack');stack.setAttribute('direction', 'vertical');stack.setAttribute('spacing', '20');stack.setAttribute('align', 'center');const title = document.createElement('ui-text');title.setAttribute('content', 'JavaScript');stack.appendChild(title);const description = document.createElement('ui-text');description.setAttribute('content', 'A programming language for web development');stack.appendChild(description);const deleteButton = document.createElement('ui-button');deleteButton.setAttribute('content', 'Delete Tag');deleteButton.addEventListener('press', () => {window.parent.postMessage({type: 'tool',payload: {toolName: 'deleteTag',params: { tagId: '1' }}}, '*');});stack.appendChild(deleteButton);root.appendChild(stack);`,},encoding: 'text',
})

 

The key advantages of Remote DOM over raw HTML are:
  1. Consistent Design System: All UI components use the same styling and behavior patterns
  2. Built-in Interactivity: Components like ui-button come with built-in event handling
  3. Responsive by Default: Components automatically adapt to different screen sizes
  4. Tool Integration: Easy integration with MCP tools through postMessage API
  5. Framework Agnostic: Works with React, Vue, or any other framework

From the MCP UI documentation: Remote DOM content is delivered as application/vnd.mcp-ui.remote-dom+javascript MIME type and allows you to create interactive UI components using JavaScript that manipulates the DOM with predefined UI elements.

 

The Remote DOM approach transforms your UI from static HTML into dynamic, interactive components. Instead of writing CSS and managing complex interactions manually, you use a consistent set of UI components that handle styling and behavior automatically.

The key difference from raw HTML is that instead of writing static markup, you're writing JavaScript that creates and manipulates DOM elements using a consistent component system. This provides a much more consistent user experience.

http://www.jsqmd.com/news/317468/

相关文章:

  • iterm2 使用 JetBrains Mono 字体
  • 2026年防水电源厂家推荐排行榜:户外/亮化/灌胶/IP68/工业级/工控设备防水电源,专业防护与稳定供电口碑之选
  • Java_线程基础 - 实践
  • [MCP] Simple MCP UI
  • 户外爆品,一站链全球!2026首届“宝品出海”跨境电商嘉年华暨湾区户外科技国际生活节震撼启幕!
  • 塑料垃圾桶价格多少钱,有美工贸性价比高不?
  • 分析大型考研集训基地怎么选,思研考研靠谱吗
  • 盘点湖北中医药大学中医师承深造班,学员真实评价与适用从业者
  • 聊聊智能窑胴体扫描仪品牌推荐与性价比分析
  • 切换node版本--nvm
  • 适合办公室吃的健康零食品牌推荐:独立小包装、低糖高纤维真的很重要
  • 共赴鹏城之约:2026湾区户外科技生活盛会,全景链接全球商机
  • 避坑!长沙小红书服务商实测,刷数据和真种草一眼分清
  • 大话大模型应用(二)--让大模型听话:Prompt EngineeringContext Engineering - 详解
  • AOT编译与JIT编译在性能优化上的具体对比分析,各自适用哪些场景?
  • 精准解码组织微环境:DSP 空间蛋白组技术,赋能疾病研究新维度
  • Java ThreadLocal 源码分析
  • 2026年口碑好的工业温度控制设备公司推荐,常州阿科牧机械靠谱吗
  • Java SPI机制:从原理到实战
  • 国自然热门|中性粒细胞趋化因子作用,一文读懂
  • Java怎么在数据库里配置多个数据源,然后进行动态切换?
  • 总结缙云值得推荐的冷轧钢带公司,排名如何?
  • 推荐窑胴体扫描仪制造商有哪些,铭耀机电价格贵不贵
  • 2026深圳产业园办公室及科技孵化园出租推荐
  • 软银/英伟达/红杉资本/贝佐斯等参投,机器人初创公司Skild AI融资14亿美元,打造通用基础模型
  • 【ES】[其他] ---- 忘记 Elasticsearch 8.0 密钥与账号密码?两步轻松重置与生成?
  • 基差风险管理系统操作日志导出与审计应用
  • 企业风险管理系统派生报表设计与实现
  • 基差风险管理系统冲突预警模块设计与实现
  • 2026年学习桌椅品牌权威推荐榜:预算3-8k配置密度与实木环保颜值深度对比