lanhu-ui
This server provides tools for UI restoration from Lanhu design files, enabling extraction of precise element specifications and download of design assets.
lanhu_ui_region: Retrieves detailed element data, text styles, layout hints, and reference crops. Supports querying by region ID, filtering by layer type/visibility, keyword search, and pagination. Offers output profiles (compact, implementation, raw). Provides text specs (font, size, weight, line height, letter spacing, color, alignment). Infers layout (flow/flex/grid-first, fixed/sticky where indicated) and detects forms, lists, overlaps. Returns a region overview with summaries and risk warnings. Includes coordinate systems (alpha_bbox for pixel and visual_bbox for design coordinates; viewBox for SVG). Can collapse slices and crop images. Reference crops are for visual comparison only.
lanhu_ui_assets: Downloads actual asset slices (cuts) from Lanhu. Provides per-instance metadata: instance_id, layer_id, parent_id, bbox, z-index, render order, path, role. Supports density (1x, 2x, 3x, source, auto) and format (png, webp, source). Composition details include background layers and full render sequence. Tracks download failures and implementation usage via
used_assets. SVG assets remain vector; rasters are not upscaled beyond source resolution.
Both accept a Lanhu detail URL (pid and image_id/docId), support forced refresh, and cache data locally for performance.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@lanhu-uilist design pages for project 'Dashboard'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Lanhu UI MCP
面向 UI 还原 Agent 的蓝湖 MCP,只暴露两个工具:
lanhu_ui_region:读取准确元素、文本样式、布局提示和参考裁剪。lanhu_ui_assets:下载蓝湖切图并返回独立图层实例、组合顺序和覆盖率。
两个工具都接收包含 pid 与 image_id(或 docId)的蓝湖详情 URL。
安装
需要 Python 3.10 或更高版本。
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e ".[dev]"
Copy-Item .env.example .env将登录蓝湖后的完整 Cookie 写入 .env:
LANHU_COOKIE=你的完整Cookie启动:
python -m lanhu_ui_mcpRelated MCP server: Lanhu MCP Server
工具
lanhu_ui_assets
切图输出支持按需选择显示倍率和格式:
density=auto|1x|2x|3x|source,默认auto;未明确指定时,所有满足条件的位图统一输出2x。format=source|png|webp,默认source。每个实例返回
source_pixel_ratio、available_densities、recommended_density和实际pixel_ratio;完整选择原因保存在页面 manifest。可选倍率仍通过
available_densities完整提供;显式传入倍率时按指定倍率输出。源文件始终保留,派生图按参数缓存;源图不足目标倍率时不放大,而是保留源图并写入
density_policy.fallbacks。SVG 始终按矢量源文件返回。
下载蓝湖切图模式中的真实切图。默认返回最多 20 个切图实例;数量更多时使用
cursor 继续分页。
每个实例包含:
instance_idlayer_idparent_idbboxz_indexpathrolerender_orderdiscovery_sourcediscovery_confidence
相同远程图片只保存一份本地文件,但每个图层实例都会独立返回,不会按 URL 合并。
存在蓝湖导出标记时 discovery_source=lanhu_export_metadata;缺少导出标记时才使用
embedded_asset_fallback,并明确返回降级警告。
响应中的 composition.backgrounds 标明背景切图必须叠加的子切图,
composition.render_sequence 给出完整渲染顺序。
可通过 used_assets 传入页面实际使用的 layer_id 或本地路径,返回:
pending_instance_count:仍未分页下载的实例数量,不代表下载失败。download_failures:当前页真实下载失败的资源摘要。implementation_usage:传入used_assets后才计算的实现使用覆盖率。
lanhu_ui_region
返回元素参数和实现建议。常用参数:
profile=compact|implementation|rawcollapse_slices=truevisible_only=truecrop_image=trueclip={x,y,width,height}query=关键词cursor/limit
首次查询完整画布时,响应包含 region_overview:
top_level_regions:顶级区域摘要及可继续查询的region_id。text_summary:重要文本样本和坐标。risk_warnings:分页遗漏、背景叠加和定位风险。
详细图层通过 region_id、cursor 和 limit 分页查询。
bbox 是设计测量数据,不表示必须绝对定位。实现页面时优先使用正常文档流、
Flexbox 或 Grid;只有 layout_hint 明确建议时才使用 absolute、fixed 或 sticky。
表单、列表和纵向区块会附带 padding、gap、margin、对齐方式与 child_order。
切图内部图层默认折叠,避免重复实现。覆盖数据分为:
asset_coverage:当前区域切图实例的检索情况。retrieval_coverage:切图、普通文本、形状和覆盖层的查询情况。implementation_coverage:只有下游提供实际实现证据后才能计算;区域读取默认 返回checked: false。
完整遗漏列表只写入查询 JSON。MCP 响应仅返回数量和最多 5 个样例,避免分页后 又通过覆盖率字段把全部图层塞回上下文。
背景或大切图通过 required_non_asset_layers 标明仍需单独实现的文本、形状和覆盖层。
文本图层在 implementation/raw profile 中返回 text_spec:
可实现的段落与换行。
字体、字号、字重、行高、字间距、颜色和对齐方式。
文本容器宽高、换行和空白处理建议。
PNG/WebP 等栅格切图返回像素坐标 alpha_bbox 和设计坐标 visual_bbox;
SVG 返回基于 viewBox 的 visual_bbox,用于区分透明边缘、阴影和设计图层 bbox。
通用语义与布局推断
不使用页面文案或行业词汇推断表单、列表、背景、fixed 或 sticky。
优先读取
role、semanticRole、layoutRole、componentType、controlType、position等图层元数据。元数据缺失时,仅根据包含、重叠、对齐、间距和重复尺寸等几何结构推断。
fixed/sticky 必须有显式元数据;无法确认时保守返回普通流式布局或
unknown。form由显式角色或通用控件组合识别,list由显式角色或重复结构识别, 与中文、英文及具体业务内容无关。普通兄弟元素的几何重叠不会直接触发 absolute,而是写入
ignored_overlaps,包含双方 layer ID、重叠率、交集 bbox 和 z-index。有序兄弟重叠继续使用 Flow/Flex;
child_margins.overlap_before给出重叠量, 下游仅在视觉还原需要时使用负 margin 或 transform。只有显式 absolute/fixed/sticky、装饰覆盖层或越界装饰元素才输出定位建议; 实际定位元素通过
overlap_with和overlap_evidence标明关联对象。
参考裁剪
区域截图统一标记为:
{
"role": "reference_crop",
"formal_page_resource": false,
"usage": "visual comparison only"
}reference_crop 仅用于视觉对比,禁止作为正式页面图片。兼容字段 paths.crop
暂时保留,并与 paths.reference_crop 指向同一文件。
数据与兼容性
当前 schema_version 为 8。
JSON 使用严格 UTF-8 编码,不转义中文。
非有限浮点数会转换为
null,确保 JSON 合法。读取时兼容 UTF-8 BOM。
lanhu_ui_region写入前执行 UTF-8、严格 JSON round-trip 和结构 Schema 校验, 并在validation中返回结果。两个工具名称和调用参数继续可用。
v7 调整了覆盖率响应:
visible_content_coverage改为retrieval_coverage,implemented/unimplemented改为returned/missing;消费方应检查schema_version。旧缓存会因 Schema 版本变化自动重新生成。
measurement_hint保留旧版绝对坐标,css_hint面向实际布局实现。
内部按职责拆分:
schema_adapter.py:将蓝湖/Sketch Schema 转为统一图层记录。region_pipeline.py:区域过滤、布局分析和检索覆盖率。asset_pipeline.py:切图分页、下载、去重、可见边界和使用校验。contracts.py:Schema v7、UTF-8、JSON、bbox、ID 和渲染顺序校验。projections.py:限制 MCP 响应体积;完整数据保留在本地 JSON。
缓存目录结构:
.lanhu-cache/<project>/designs/<design>/
├── raw-schema.json
├── original.png
├── overview.json
├── regions.json
├── design-tokens.json
├── assets.json
├── queries/
└── downloaded-slices/验证
.\.venv\Scripts\python.exe -m pytest -q
.\.venv\Scripts\python.exe -m ruff check lanhu_ui_mcp tests
.\.venv\Scripts\python.exe -m mypy lanhu_ui_mcp
.\.venv\Scripts\python.exe -m compileall -q lanhu_ui_mcp testsMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityCmaintenanceEnables AI coding agents to access Figma design data by fetching and simplifying layout and styling metadata. This allows developers to accurately implement UI designs in code directly from Figma file links.Last updated84,475MIT
- AlicenseAqualityCmaintenanceEnables AI to directly read and analyze Lanhu design drafts and requirement documents to generate HTML, CSS, and structural analyses. It allows users to extract design slices and process prototype pages directly within AI clients.Last updated323484MIT
- Alicense-qualityAmaintenanceConverts Lanhu design URLs into AI-ready implementation context including HTML+CSS (Tailwind), image downloads, design tokens, and guidance.Last updated50324MIT
- Alicense-qualityCmaintenanceTransforms Figma design data into a compact, LLM-friendly format for code generation, reducing size by 99.5% while preserving UI-critical information.Last updated3604MIT
Related MCP Connectors
UI design from prompts, screenshots, and URLs for AI coding agents and theme tokens.
A design-style library for AI agents: search real styles, fetch a ready-to-apply design spec.
Turn any live website into brand colors, fonts, design tokens, SVGs, Lottie and paste-ready code.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/revfanc/lanhu-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server