
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@biliboyvansama/mcp-ui-client-simplified
Advanced tools
Simplified MCP-UI Client SDK - HTML and URL rendering only
简化版的 MCP-UI 客户端 SDK,专注于 HTML 和 URL 资源渲染,移除了 RemoteDom 支持以减少包大小和复杂度。
text/html
)text/uri-list
)npm install @biliboyvansama/mcp-ui-client-simplified
import { UIResourceRenderer } from '@biliboyvansama/mcp-ui-client-simplified';
function App() {
const resource = {
mimeType: 'text/html',
text: '<h1>Hello World</h1>'
};
const handleUIAction = async (action) => {
console.log('UI Action:', action);
};
return (
<UIResourceRenderer
resource={resource}
onUIAction={handleUIAction}
/>
);
}
<!-- 引入 Web Component 脚本 -->
<script src="./node_modules/@biliboyvansama/mcp-ui-client-simplified/dist/ui-resource-renderer.wc.js"></script>
<!-- 使用 Web Component -->
<ui-resource-renderer id="renderer"></ui-resource-renderer>
<script>
const renderer = document.getElementById('renderer');
// 设置资源
renderer.resource = {
mimeType: 'text/html',
text: '<h1>Hello from Web Component</h1>'
};
// 监听 UI 动作
renderer.addEventListener('onUIAction', (event) => {
console.log('UI Action:', event.detail);
});
</script>
text/html
)const htmlResource = {
mimeType: 'text/html',
text: '<div><h1>HTML Content</h1><p>This is rendered in an iframe.</p></div>'
};
text/uri-list
)const urlResource = {
mimeType: 'text/uri-list',
text: 'https://example.com'
};
属性 | 类型 | 描述 |
---|---|---|
resource | Partial<Resource> | 要渲染的资源对象 |
onUIAction | (action: UIActionResult) => Promise<unknown> | UI 动作回调函数 |
supportedContentTypes | ResourceContentType[] | 支持的内容类型过滤器 |
htmlProps | HTMLResourceRendererProps | HTML 渲染器的额外属性 |
属性 | 类型 | 描述 |
---|---|---|
resource | Partial<Resource> | 要渲染的资源对象 |
onUIAction | (action: UIActionResult) => Promise<unknown> | UI 动作回调函数 |
style | React.CSSProperties | iframe 样式 |
className | string | CSS 类名 |
proxy | string | 代理服务器 URL(仅用于外部 URL) |
renderOptions | RenderOptions | 渲染选项 |
属性 | 类型 | 描述 |
---|---|---|
autoResize | boolean | 是否自动调整 iframe 大小 |
sandbox | string[] | iframe 沙箱权限 |
# 安装依赖
npm install
# 构建库
npm run build
# 构建 Web Component
npm run build:wc
# 运行测试
npm test
本包还提供了 Model Context Protocol (MCP) 服务器功能,允许 LLM 应用程序通过标准化协议访问 UI 渲染工具。
# 开发模式(使用 tsx 直接运行 TypeScript)
npm run mcp:dev
# 生产模式(需要先构建)
npm run build
npm run mcp:start
渲染 HTML 内容为可视化组件
参数:
html
(string, 必需): 要渲染的 HTML 内容title
(string, 可选): 页面标题allowedContentTypes
(string[], 可选): 允许的内容类型渲染 URL 资源为可视化组件
参数:
url
(string, 必需): 要渲染的 URL 地址title
(string, 可选): 页面标题allowedContentTypes
(string[], 可选): 允许的内容类型生成独立的 Web Component
参数:
content
(object, 必需): 要转换的内容
type
("html" | "url"): 内容类型data
(string): 内容数据elementName
(string, 可选): 自定义元素名称本包已针对浏览器环境进行优化,解决了 Node.js 特定 API 在浏览器中的兼容性问题:
process
对象的依赖npm install -g @biliboyvansama/mcp-ui-client-simplified@latest
{
"mcpServers": {
"mcp-ui-renderer": {
"command": "mcp-ui-renderer"
}
}
}
npm run build
{
"mcpServers": {
"mcp-ui-renderer-local": {
"command": "node",
"args": ["/Users/your-username/path/to/project/dist/mcp/cli.js"]
}
}
}
{
"mcpServers": {
"mcp-ui-renderer-npx": {
"command": "npx",
"args": [
"-y",
"@biliboyvansama/mcp-ui-client-simplified@latest"
]
}
}
}
如果遇到 "MCP error -32000: Connection closed" 错误:
检查命令路径:确保 CLI 文件存在且可执行
# 检查全局安装
which mcp-ui-renderer
# 检查本地文件
ls -la /path/to/your/project/dist/mcp/cli.js
测试 CLI 是否正常工作:
# 测试全局安装
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}}}}' | mcp-ui-renderer
# 测试本地文件
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}}}}' | node /path/to/cli.js
检查 Node.js 版本:确保使用 Node.js 18+
node --version
清理缓存并重新安装:
npm cache clean --force
npm uninstall -g @biliboyvansama/mcp-ui-client-simplified
npm install -g @biliboyvansama/mcp-ui-client-simplified@latest
检查 Claude Desktop 日志:查看 Claude Desktop 的错误日志获取更详细的错误信息
常见问题:
import { createServer } from '@biliboyvansama/mcp-ui-client-simplified/src/mcp/server/server.js';
import { createStdioTransport, startStdioServer } from '@biliboyvansama/mcp-ui-client-simplified/src/mcp/transport/stdio.js';
// 创建 MCP 服务器实例
const server = createServer();
// 创建标准输入输出传输层
const transport = createStdioTransport();
// 启动服务器
await startStdioServer(server, transport);
process
对象的依赖src/browser.ts
)特性 | 简化版 | 完整版 |
---|---|---|
HTML 渲染 | ✅ | ✅ |
URL 渲染 | ✅ | ✅ |
RemoteDom 渲染 | ❌ | ✅ |
MCP 服务器支持 | ✅ | ❌ |
浏览器兼容性 | ✅ 优化 | ❓ 未知 |
依赖数量 | 4 个 | 7 个 |
包大小 | 更小 | 更大 |
复杂度 | 低 | 高 |
Apache-2.0
FAQs
Simplified MCP-UI Client SDK - HTML and URL rendering only
The npm package @biliboyvansama/mcp-ui-client-simplified receives a total of 2 weekly downloads. As such, @biliboyvansama/mcp-ui-client-simplified popularity was classified as not popular.
We found that @biliboyvansama/mcp-ui-client-simplified demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.