简体中文 | English
✨ Turns Lanhu designs into context for AI to generate code and recreate pages.
- 🎨 Supports both
HTML+CSSandHTML+Tailwindoutput, so you can choose the form that fits your stack better - 🖼️ Returns slice asset mappings and download commands to reduce manual image handling
- 🧱 Includes
Design Tokensand a design preview for downstream implementation and visual checking - 🧭 Attaches implementation guidance for downstream AI, including priorities, adaptation rules, and constraints
- ⚙️ Supports CLI flags and environment variables for
Tailwindoutput, skipping slices, unit scaling, and prompt language - 📦 Ships two output modes —
inline(default) returns everything in the tool result;filespacks HTML, slice mappings, Design Tokens, and the implementation guide intocontext.md+preview.pngon disk and only returnsresource_links, side-stepping the truncation you hit on large designs when an MCP client enforces a tool-output token cap (e.g. Claude Code'sMAX_MCP_OUTPUT_TOKENSdefaults to 25000)
For full documentation, visit lanhu.refineup.com.
- Node.js
^20.19.0 || >=22.12.0
- Enable transcoding for the design before uploading it to Lanhu
Install Lanhu Helper first. The Lanhu token, selected-layer link, and sample prompt used below are copied from the menu that appears when you right-click a Lanhu layer.
First, create a .env.local file.
Open a logged-in Lanhu page, right-click a layer, choose “复制 Token” (Copy Token), then paste the clipboard contents into .env.local.
LANHU_TOKEN=the value you just copiedAdd the matching MCP config to the corresponding file. For Qoder, open the MCP Services page, click Add, and paste the config:
Claude Code(.mcp.json) / Cursor(.cursor/mcp.json)
{
"mcpServers": {
"lanhu-context-mcp": {
"command": "npx",
"args": ["-y", "lanhu-context-mcp"]
}
}
}TRAE (.trae/mcp.json)
{
"mcpServers": {
"lanhu-context-mcp": {
"command": "npx",
"args": ["-y", "lanhu-context-mcp", "--cwd", "${workspaceFolder}"]
}
}
}Codex(.codex/config.toml)
[mcp_servers.lanhu-context-mcp]
cwd = "/absolute/path/to/current-project"
command = "npx"
args = ["-y", "lanhu-context-mcp"]Qoder (global MCP service)
{
"mcpServers": {
"lanhu-context-mcp": {
"command": "npx",
"args": [
"-y",
"lanhu-context-mcp",
"--cwd",
"/absolute/path/to/current-project"
],
"env": {
"LANHU_TOKEN": "your_lanhu_token_here"
}
}
}
}TRAE has a design quirk: the MCP child process's working directory does not point at the current project, so .env.local is not found and writes to .lanhu-context-mcp.local/ fail. The TRAE config above therefore must always pass --cwd; use the editor's built-in ${workspaceFolder} variable to point at the project root automatically, with no hardcoded absolute path.
Codex needs one extra field here: set cwd to the absolute path of your current project. Because that path usually differs across developers, .codex/config.toml should usually stay local and not be committed to Git.
Qoder currently only supports global (user-level) MCP configuration, so the spawned server typically runs with cwd = / and fails when it tries to mkdir .lanhu-context-mcp.local/. The Qoder config above therefore must pass --cwd (or env.CWD) pointing to your project root, and also pass LANHU_TOKEN via env (stdio child processes do not inherit your shell env).
--cwd doesn't have to be a hardcoded absolute path. Editors that support variable substitution (VSCode and friends) can use a built-in variable instead, so the config is shareable across the team and nobody has to edit the path by hand: "--cwd", "${workspaceFolder}".
Windows
If the npx config above fails to start on Windows, use the following fallback:
Claude Code (.mcp.json) / Cursor (.cursor/mcp.json)
{
"mcpServers": {
"lanhu-context-mcp": {
"command": "cmd",
"args": ["/c", "npx", "-y", "lanhu-context-mcp"]
}
}
}TRAE (.trae/mcp.json)
{
"mcpServers": {
"lanhu-context-mcp": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"lanhu-context-mcp",
"--cwd",
"${workspaceFolder}"
]
}
}
}Codex (WSL2)
[mcp_servers.lanhu-context-mcp]
cwd = "/absolute/path/to/current-project"
command = "npx"
args = ["-y", "lanhu-context-mcp"]Codex (Native)
[mcp_servers.lanhu-context-mcp]
cwd = "C:\\absolute\\path\\to\\current-project"
command = "C:\\Program Files\\nodejs\\npx.cmd"
args = ["-y", "lanhu-context-mcp"]
[mcp_servers.lanhu-context-mcp.env]
APPDATA = "C:\\Users\\{your-name}\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\{your-name}\\AppData\\Local"
USERPROFILE = "C:\\Users\\{your-name}"
HOME = "C:\\Users\\{your-name}"
SYSTEMROOT = "C:\\Windows"
COMSPEC = "C:\\Windows\\System32\\cmd.exe"Qoder (global MCP service)
{
"mcpServers": {
"lanhu-context-mcp": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"lanhu-context-mcp",
"--cwd",
"C:\\absolute\\path\\to\\current-project"
],
"env": {
"LANHU_TOKEN": "your_lanhu_token_here"
}
}
}
}Codex native fallback reference:
openai/codex#2555
Right-click the layer you want to hand to the AI, then use “复制示例提示词” (Copy Sample Prompt) or “复制选中图层链接” (Copy Selected Layer Link). Send that text to the AI.
Please implement based on this Lanhu design
@https://lanhuapp.com/web/#/item/project/detailDetach?tid={tid}&pid={pid}&project_id={project_id}&image_id={image_id}
https://lanhuapp.com/web/#/item/project/detailDetach?tid={tid}&pid={pid}&project_id={project_id}&image_id={image_id}
You can write the prompt however you like, but the Lanhu URL must be complete and correct or the tool cannot be called properly.
Lanhu Helper — Companion Chrome extension for Lanhu. Right-click a layer to copy the token, the selected layer's URL, and a ready-made prompt.
PRs and issues are welcome. Here is how to get the dev environment running.
The repo is a pnpm workspace (with playground as a sub-package). From the repo root:
pnpm installCopy the example file and drop the .example suffix, then fill in your credentials:
cp .env.local.example .env.localFields:
| Field | Required | Purpose |
|---|---|---|
LANHU_TOKEN |
Yes | Token for calling the Lanhu API. On a logged-in Lanhu page, right-click a layer and use Lanhu Helper’s “复制 Token” (Copy Token) |
LANHU_TEST_URL |
For integration tests | A real, reachable Lanhu design detail URL the integration test harness will hit |
Pick the tier that matches your change:
| Tier | Command | When | Requires |
|---|---|---|---|
| Unit tests | pnpm test / pnpm test:coverage |
Every PR; coverage target is 100% | None |
| Integration tests | pnpm test:integration plus :http / :stdio variants |
When touching services, tools, transports, or protocol | LANHU_TOKEN + LANHU_TEST_URL |
| End-to-end harness | See the playground section below | When changing output format, prompts, or on-disk artifacts | LANHU_TOKEN + any AI client wired to this MCP server |
Finer-grained integration subsets (files mode only, stdio only, etc.) live under test:integration:* in package.json.
playground/ is a Vue 3 + Vite + Tailwind project used to exercise get_design_context end-to-end inside a real MCP client (Claude Code / Cursor / Codex / Qoder): you paste a Lanhu URL into the AI, it calls the MCP server against the real Lanhu API, the generated page lands under src/pages/, and you preview it live via the dev server — covering the layer that unit and integration tests cannot.
Common commands:
# Start the playground dev server
pnpm play
# Reset the last run (pages under src/pages, sliced assets, and .lanhu-context-mcp.local/)
pnpm play:cleanSee playground/README.md for the detailed workflow and per-client setup.
-
pnpm typecheckpasses -
pnpm testpasses and coverage does not regress (verify withpnpm test:coverage) -
pnpm lintpasses - For changes that affect external behavior or output format, also run
pnpm test:integration:filesor verify in the playground against a real design
Copyright (c) 2026-present, REFINIST