Content
<!-- mcp-name: io.github.blantian/lanhu-design-mcp -->
# Tool List
`v0.1.1` is a MCP server for reading Lanhu design and exporting fine-grained UI resources, targeting macOS.
## Features
- Reads Lanhu design project URL and lists all design images
- Analyzes specified design drafts and returns platform-adjusted UI structures (Android dp / iOS pt / Web px / WeChat rpx)
- Returns complete design images and fine-grained Sketch, Figma, Photoshop slice resources, as well as Web, iOS, and Android multi-ratio addresses
- Exports complete Agent UI restoration context with assets and analysis
- Hosts Chrome Profile for automatic login without manual cookie copying
## System Requirements
- macOS
- Google Chrome (installed)
- Python 3.10 and above
## Installation
```bash
pip install lanhu-design-mcp
```
## Initial Login
```bash
lanhu-design-mcp auth login
lanhu-design-mcp auth status
```
Login uses a dedicated local Chrome Profile. After interactive login, subsequent MCP processes automatically reuse the session. Normal design tool invocation does not open a visible browser. When credentials expire, it returns `auth_required` guidance, requiring a re-call to `lanhu_auth_login`.
```bash
lanhu-design-mcp auth logout --confirm
```
## MCP Configuration
```json
{
"mcpServers": {
"lanhu-design": {
"command": "lanhu-design-mcp"
}
}
}
```
## MCP Tools
| Tool | Parameters | Description |
|---|---|---|
| `lanhu_health_check` | None | Returns local configuration status without network access or exposing Cookie values |
| `lanhu_get_designs` | `url` | Retrieves all design image lists for a project |
| `lanhu_analyze_design` | `url`, `design_name_or_index` (optional), `target_platform` (optional, default `android`) | Analyzes specified design drafts and returns platform-adjusted UI structures |
| `lanhu_get_design_assets` | `url`, `design_name_or_index` (optional), `target_platform` (optional, default `android`) | Returns complete design images and fine-grained downloadable slice resources |
| `lanhu_export_ui_context` | `url`, `design_name_or_index` (optional), `target_platform` (optional, default `android`) | Returns complete Agent UI restoration context with assets and analysis |
| `lanhu_auth_login` | None | Opens a dedicated Chrome Profile for interactive Lanhu login |
| `lanhu_auth_status` | `session_id` (optional) | Reports hosted authentication status without credentials |
| `lanhu_auth_logout` | `confirm` (optional, default `false`) | Logs out and deletes the hosted Profile, requiring `confirm=true` |
## Fine-Grained Slices
`lanhu_get_design_assets` returns complete design images and designer-declared fine-grained slices. The complete image is always the first item in `assets`; other `kind: "slice"` items may include:
- `remote_url`: Lanhu-stored original PNG or SVG address
- `svg_url`: Vector address when both PNG and SVG exist
- `scale_urls`: Web, iOS, and Android multi-ratio PNG addresses
- `logical_size`, `position_px`: Logical size and canvas coordinates
- `layer_path`: Layer path in the source design
- `suggested_local_path`: Suggested local save path
This tool only returns download mappings and does not write files to the caller's project.
```json
{
"slice_scale": 2,
"total_assets": 2,
"total_slices": 1,
"assets": [
{"kind": "design_image", "remote_url": "https://..."},
{
"kind": "slice",
"name": "Switch",
"format": "png",
"remote_url": "https://...",
"svg_url": "https://...",
"scale_urls": {"1x": "https://...", "2x": "https://...", "android_xhdpi": "https://..."},
"logical_size": {"width": 22, "height": 22},
"position_px": {"x": 1241, "y": 66},
"layer_path": "Switch",
"suggested_local_path": "assets/lanhu/design-id/Switch.png"
}
]
}
```
## Platform Units
- Web: `px` - Original Lanhu annotation unit
- Android: `dp = px / 2` - Verified Lanhu rule (1920x1080px → 960x540dp)
- iOS: `pt = px / 2` - Default logical point conversion
- WeChat Mini Program: `rpx = px * 750 / design_draft_width` - rpx conversion based on design draft width
## Hosted Authentication and Security
- Authentication information exists only in the locally hosted Chrome Profile and is never output through MCP responses or logs
- Startup and health checks do not access the network or trigger the browser
- `auth_required` errors are structured responses without credentials
- Logout only deletes the hosted Profile and does not affect the system Chrome default Profile
## Troubleshooting
| Status | Description | Solution |
|---|---|---|
| `auth_required` | Credentials invalid or expired | Run `lanhu-design-mcp auth login` |
| `unsupported_platform` | Only supported on macOS | Use a macOS device |
| `dependency_missing` | Playwright Python library or Chrome unavailable | `pip install --upgrade lanhu-design-mcp` and confirm Chrome is installed |
| `profile_locked` | Hosted Profile occupied by another process | Wait for the other process to complete and retry |
| `cancelled` | Login window closed before authentication completed | Rerun `lanhu-design-mcp auth login` |
| `timed_out` | Login window authentication not completed within 5 minutes | Rerun `lanhu-design-mcp auth login` |
## Development and Testing
```bash
git clone https://github.com/blantian/lanhu-design-mcp
cd lanhu-design-mcp
uv sync --dev
uv run pytest
```
## v0.1.1 Compatibility Notes
- Only supports macOS; no longer supports configuration credentials through environment variable files or browser default database
- MCP transmission is fixed to stdio
- Playwright Python library is a necessary dependency but will not automatically download Chromium
## License
MIT