Lanhu MCP
Generates Unity UGUI prefabs from Lanhu designs, creating GameObjects, RectTransforms, UI components, and sprite references for Unity projects.
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 MCPConvert Lanhu design page 'Login' to Unity prefab"
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 MCP 0.2
Lanhu MCP is a local, Unity-only MCP server that converts a Lanhu design page into a validated Packet v1, a Unity Plan v1, and an experimental staged UGUI Prefab YAML snapshot.
The current renderer writes Unity YAML directly; it does not run the Unity Editor. Static verification is required but does not prove that the project compiles, imports without Missing Scripts, or visually matches Lanhu. Complete theUnity acceptance checks before treating generated output as production-ready.
What it supports
Unity 2022.3 LTS and Unity 6 LTS.
UGUI hierarchy and presentation components:
GameObject,RectTransform,CanvasRenderer,Image,Text, masks, layout groups,LayoutElement,Outline,Shadow, andCanvasGroup.Conservative best-effort inference for
Button,Slider,Toggle,ToggleGroup,InputField,Dropdown,ScrollRect, andScrollbar.Downloaded sprites, deterministic
.metafiles, a Prefab Source Map, and an ownership manifest.
Semantic inference is not business-logic restoration. Review inferred component bindings in Unity. No C# Unity Editor importer is shipped in 0.2; the current Direct YAML path is best suited to inspectable snapshots, diffs, and pre-generation.
Related MCP server: lanhu-context-mcp
Requirements
Python 3.10 or newer.
A Lanhu session Cookie for private projects; some DDS sources may require a separate DDS Cookie.
A Unity project whose root contains both
Assets/andProjectSettings/.Unity's built-in UGUI package; editable text uses
UnityEngine.UI.Textand the built-in Arial font by default.
Install and run
From a source checkout:
python3 -m venv .venv
.venv/bin/pip install -e .
cp .env.example .env
.venv/bin/lanhu-mcpHTTP mode is loopback-only and listens at http://127.0.0.1:8126/mcp by default. This server has no remote authentication and must not be exposed to the internet.
For a stdio MCP client, point the client at the absolute path to run-stdio.sh. A typical MCP client entry is:
{
"mcpServers": {
"lanhu": {
"command": "/absolute/path/to/lanhu-mcp/run-stdio.sh"
}
}
}Client configuration keys vary by MCP host. The equivalent command is:
MCP_TRANSPORT=stdio /absolute/path/to/lanhu-mcp/.venv/bin/python -m lanhu_mcpConfiguration
Copy .env.example to .env. For an authorized Lanhu browser session, set the complete request Cookie header value; do not commit or share it. DDS_COOKIE is separate and never inherits LANHU_COOKIE.
Variable | Default | Purpose |
| empty | Cookie sent only to the configured Lanhu host and subdomains. |
| empty | Optional Cookie sent only to the configured DDS host and subdomains. |
|
| Managed Packet and downloaded-asset cache. |
|
| Positive request timeout in seconds. |
|
| HTTP bind host; only loopback addresses are accepted. |
|
| HTTP port. |
|
|
|
|
| Maximum node count for a full response. |
|
| Maximum bytes per downloaded asset. |
|
| Maximum aggregate downloaded bytes per Packet. |
|
| Download workers, from 1 to 16. |
|
| Retry count, from 0 to 3. |
| empty | Optional default UGUI |
| empty | Optional inline source-font-name to UGUI |
| empty | Optional path to a UTF-8 UGUI font map JSON file. |
LANHU_BASE_URL and DDS_BASE_URL are advanced HTTPS-only endpoint overrides. Process environment variables take precedence over .env; restart the MCP process after changing configuration.
The server intentionally clears DATA_DIR/packets and DATA_DIR/assets on startup. A packet_id and its downloaded files are therefore valid only for the current server process; call lanhu_prepare_design again after a restart.
Prepare Unity text
Editable UnityEngine.UI.Text output is enabled by default. During generation, Lanhu MCP scans the target project's Assets/ tree for .ttf/.otf files and matches normalized source names in this order: family + style/weight, then family. The matched font's .meta GUID is written internally as m_Font with fileID 12800000; users do not need to configure GUIDs for normal name-based matching.
Explicit text_font_map_json or UNITY_TEXT_FONT_MAP_* values override automatic matches, and text_font_guid/UNITY_TEXT_FONT_GUID supplies a default. These GUIDs must reference imported .ttf/.otf files, not TMP .asset files. Ambiguous or unmatched names produce warnings; unmatched text falls back to built-in Arial. Set use_text_components=false only when intentionally choosing visual-only rasterized text output.
Quick start workflow
The examples below show MCP tool payloads, not shell commands.
1. List designs
{
"url": "https://lanhuapp.com/web/#/item/project/product?..."
}Call lanhu_list_designs, then select a design by exact name, unique partial name, zero-based list index, or the image_id already present in the URL.
2. Prepare and download
Call lanhu_prepare_design:
{
"url": "https://lanhuapp.com/web/#/item/project/product?...",
"design": "Home",
"force_refresh": false
}Keep the returned packet_id. This step fetches sources, normalizes nodes, downloads assets into the managed cache, validates the Packet, and records partial download failures as warnings.
3. Inspect readiness
Call lanhu_inspect_design before writing Unity files:
{
"packet_id": "0123456789abcdef0123",
"view": "summary"
}Review unity_readiness.status, blockers, review_items, missing assets, and missing font mappings. Use view="unity_plan" to inspect the exact creation/component plan, view="assets" for download state, and view="slices" for Sprite candidates.
4. Generate the Prefab snapshot
{
"packet_id": "0123456789abcdef0123",
"unity_project_path": "/absolute/path/to/UnityProject",
"overwrite": false,
"prefab_visual_mode": "layered",
"use_text_components": true,
"component_policy": "conservative"
}The Unity project path must be the project root, not its Assets/ directory.
5. Verify generated files
Generation runs a staged static verification automatically. It also returns prefab_asset_path and source_map_asset_path, which can be checked again with lanhu_verify_unity_prefab:
{
"unity_project_path": "/absolute/path/to/UnityProject",
"prefab_asset_path": "Assets/LanhuMCP/Home/Prefabs/01234567_ViewRoot.prefab",
"source_map_asset_path": "Assets/LanhuMCP/Home/Prefabs/01234567_ViewRoot.design-to-unity.json"
}pass_with_warnings requires review; it is not the same as production acceptance.
Tool reference
lanhu_list_designs
Parameter | Required | Default | Description |
| Yes | — | Lanhu project URL containing |
lanhu_prepare_design
Parameter | Required | Default | Description |
| Yes | — | Lanhu project URL. |
| No |
| Name, unique partial name, list index, or URL |
| No |
| Bypass an intact same-version cache in the current process. |
lanhu_inspect_design
Parameter | Required | Default | Description |
| Yes | — | ID returned by prepare. |
| No |
|
|
| For |
| One node ID or a list of IDs. |
| No |
| Tree depth, clamped to 0–20. |
| No |
| Include style/text fields in tree output. |
| No |
| Include the whole-design reference in slices/plan output. |
| No |
|
|
lanhu_generate_unity_prefab
Parameter | Required | Default | Description |
| Yes | — | Prepared Packet ID. |
| Yes | — | Unity root containing |
| No |
| Generated directory below |
| No |
| Optional generated Prefab name. |
| No |
| Replace only paths owned by the same Packet manifest. |
| No |
| Copy/include the whole-design reference asset. |
| No |
| Generate editable |
| No |
|
|
| No |
|
|
| No | empty | Optional default UGUI Font GUID from an imported |
| No | configured/empty | Optional source-font-name to UGUI Font GUID mapping; overrides automatic name matches. |
lanhu_verify_unity_prefab
Parameter | Required | Default | Description |
| Yes | — | Unity project root. |
| Yes | — | Prefab path beginning with |
| No | adjacent derived name | Source Map path beginning with |
Every tool response includes api_version: "0.2" and an envelope status. Expected failures use {code, message, details, retryable}. A successful envelope may still contain a domain result_status, readiness blockers, generation warnings, or verification status pass_with_warnings; inspect those fields before continuing.
Rendering and overwrite policies
Visual modes
layeredis the default editable output. Recognized and downloaded source assets are copied intoSprites/and bound to layerImagecomponents.flattened_reference_overlayuses the whole-design reference image as the visible baseline. It deliberately suppresses normal source-layer visuals while retaining hierarchy, metadata, and transparent interaction overlays. It requires a usabledesign.reference_asset_ref; if that reference download is missing or failed, do not use this mode.
include_reference=true copies the whole-design reference; it does not control whether normal slices are downloaded or imported.
Component policies
conservativeemits inferred interactive components only when confidence is at least0.8, no semantic review is required, and all required serialized references are available.structure_onlyemits hierarchy and presentation components without inferred interaction.
Overwrite safety and limitation
Output is built in staging, statically verified, and transactionally committed. overwrite=false rejects collisions. overwrite=true can replace only files listed in the same Packet's ownership manifest; failures restore replaced files, and historical orphans are reported rather than deleted.
Ownership protection prevents overwriting unrelated files, but it does not merge edits inside an owned generated Prefab. Direct YAML performs a full snapshot regeneration. Withoverwrite=true, scripts, UnityEvents, animations, extra children, and manual field changes added directly to the generated Prefab may be lost. Keep custom behavior outside the generated Prefab or preserve it manually until an Editor-based incremental importer exists.
Generated output
With the default asset_root, output resembles:
Assets/LanhuMCP/<design-name>/
├── Sprites/
│ ├── <generated images>
│ └── <generated image .meta files>
├── Prefabs/
│ ├── <name>.prefab
│ ├── <name>.prefab.meta
│ ├── <name>.design-to-unity.json
│ └── <name>.design-to-unity.json.meta
└── lanhu-mcp-manifest.jsonThe Source Map records source node IDs, Unity fileIDs, assets, component counts, policies, and expected import gates.
The ownership manifest records the Packet owner and SHA-256 of every generated file; do not delete it if you intend to use
overwrite=truelater.
Unity acceptance checks
Static status means:
pass: no static YAML/schema/reference problem was found.pass_with_warnings: files are structurally usable but listed bindings or resources require review.fail: regenerate or fix the reported files/references before Unity import.
After a static pass or reviewed pass_with_warnings:
Open/refresh the project in the matching supported Unity Editor.
Confirm the project compiles and the Console has no relevant import errors.
Open the Prefab and check for Missing Scripts.
Confirm generated textures import as Sprites and the Source Map imports as a
TextAsset.Review UGUI Text font appearance and inferred Slider, Toggle, InputField, Dropdown, ScrollRect, Scrollbar, mask, and layout bindings.
Capture a Prefab/GameView screenshot and compare it with the Lanhu reference.
Static verification cannot replace these steps.
Troubleshooting
Symptom/code | Meaning and action |
| A target already exists. Inspect its owner; use |
| The prepared Packet points outside or no longer has its managed cached asset. Prepare the design again in the current server process. |
| Inspect |
| Multiple |
| No project font matched the source name, so that text uses built-in Arial. |
Empty/transparent output in | The mode suppresses layer visuals and depends on the reference image. Inspect the reference asset, or regenerate with |
Unsupported Unity version | Use Unity 2022.3 LTS or Unity 6 LTS; other versions are rejected before staging. |
Static pass but broken Unity output | Static verification does not import or compile Unity. Run the full acceptance checklist above. |
Data contracts and migration
Version 0.2 intentionally does not load or migrate legacy/unversioned Packets or Source Maps. Canonical JSON Schemas live in schemas/ and can be regenerated with:
python -m lanhu_mcp.schema_export schemasSee Security, Architecture, Data contracts, 0.2 migration, Unity support, and the Changelog.
Development
uv sync --extra dev
.venv/bin/ruff check src tests
.venv/bin/mypy src/lanhu_mcp
.venv/bin/pytestLicense
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/isolamenter/lanhuMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server