One‑Click Design‑to‑Code with Lanhu MCP: Setup, Pitfalls, and Why It Fails

This article documents the end‑to‑end process of using Lanhu MCP to convert UI design files into HTML/CSS, covering environment setup, installation, Cursor integration, common errors such as Python 3.13 incompatibility and HTTP 418 responses, and practical work‑arounds when the core API is blocked.

Frontend AI Walk
Frontend AI Walk
Frontend AI Walk
One‑Click Design‑to‑Code with Lanhu MCP: Setup, Pitfalls, and Why It Fails

Environment Requirements

Python 3.10 – 3.12 (Python 3.13 unsupported)

Git (installed)

Lanhu account (logged in)

Installation

Clone the repository

git clone https://github.com/dsphper/lanhu-mcp.git
cd lanhu-mcp

Create a virtual environment

# Verify Python versions
python3 --version
python3.12 --version
python3.11 --version
# Create venv with Python 3.12
python3.12 -m venv venv
# Activate venv
source venv/bin/activate   # macOS/Linux
# Windows: venv\Scripts\activate

Install dependencies

# One‑click install (recommended)
bash easy-install.sh
# Manual install
pip install -r requirements.txt
playwright install chromium

Configure Lanhu Cookie Open Lanhu web, open DevTools, copy the Cookie header from any request, then set the environment variable: export LANHU_COOKIE="<em>your‑cookie</em>" Or run the helper script: bash setup-env.sh # prompts for Cookie Start the service

# Run directly
python lanhu_mcp_server.py
# Or via Docker
docker-compose up -d

Service reports Server running at http://localhost:8000/mcp .

Cursor Configuration

Open Cursor settings ( Cmd + ,), search for “MCP”.

Add a new server with JSON:

{
  "mcpServers": {
    "lanhu": {
      "url": "http://localhost:8000/mcp?role=Developer&name=YourName"
    }
  }
}

Validate connection – a green check indicates success.

Usage Commands

In the Cursor chat window, issue prompts such as:

请帮我看看这个设计稿:https://lanhuapp.com/web/#/item/project/detailDetach?pid=xxx&image_id=xxx
把这个页面还原成 HTML 代码
帮我下载"首页设计"的所有切图

Available Tool Functions

lanhu_get_pages

– fetch prototype page list lanhu_get_ai_analyze_page_result – analyze page content lanhu_get_designs – list UI design files lanhu_get_ai_analyze_design_result – analyze design file lanhu_get_design_slices – obtain slice information lanhu_say – post team comment lanhu_say_list – view comment list lanhu_get_members – list collaborators

Common Issues and Fixes

Python 3.13 error

ModuleNotFoundError: No module named 'cgi'

Solution: delete the existing venv, recreate with Python 3.12, reactivate, and reinstall.

rm -rf venv
python3.12 -m venv venv
source venv/bin/activate
bash easy-install.sh

Cannot connect to MCP server

Check:

Service is running ( python lanhu_mcp_server.py)

URL is correct ( http://localhost:8000/mcp)

Port 8000 is free ( lsof -i :8000)

Cookie expired

Refresh the Cookie and reset the environment variable, then restart the service.

export LANHU_COOKIE="<em>new‑cookie</em>"
# restart service

Design‑analysis API returns HTTP 418

HTTP 418 Unknown
https://lanhuapp.com/api/project/images?... (418)

The Lanhu backend now blocks the analysis endpoint, returning 418 for any request. This is an API‑level restriction that prevents automatic design restoration.

Work‑arounds

Method 1 – Copy code from Lanhu Open the design page, click the built‑in “Code” panel, copy the generated HTML + CSS, then feed it to an AI assistant to convert to target frameworks (e.g., Vue, UnoCSS, Vant).

Method 2 – Describe layout Write a brief textual description of the page structure (header, body, footer) and key styles; let an AI model generate the code.

Failure Observation

Initial tests produced correct layout, colors, and font sizes. When switching to a different design, the tool consistently returned HTTP 418, making the core functionality unusable.

Additional Notes

Visual AI models such as Claude, GPT‑4, Gemini, or Kimi are required for AI analysis.

Lanhu cookies expire; refresh regularly for continued use.

Some advanced features may require a Lanhu membership.

Related Links

GitHub: https://github.com/dsphper/lanhu-mcp

Lanhu website: https://lanhuapp.com

MCP protocol: https://modelcontextprotocol.io

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerPythonAI code generationCursorHTML/CSSLanhu MCPUI design to code
Frontend AI Walk
Written by

Frontend AI Walk

Looking for a one‑stop platform that deeply merges frontend development with AI? This community focuses on intelligent frontend tech, offering cutting‑edge insights, practical implementation experience, toolchain innovations, and rich content to help developers quickly break through in the AI‑driven frontend era.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.