Lanhu Context MCP logo

Lanhu Context MCP

Community
refinist

把蓝湖设计稿整理成让 AI 生成代码还原页面的上下文

Publisherrefinist
Repositorylanhu-context-mcp
LanguageTypeScript
Forks
9
Stars
47
Available tools
0
Transport typestdio
LicenseMIT
Links
  • Connect tools to AI workflows

    Lanhu Context MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    47 stars and 9 forks from the linked repository.

lanhu-context-mcp

简体中文 | English

npm downloads/month Unit Test codecov

✨ 把蓝湖设计稿整理成让 AI 生成代码还原页面的上下文。

Features

  • 🎨 支持输出 HTML+CSS 或 HTML+Tailwind,可以按项目技术栈选择更合适的形态
  • 🖼️ 返回切图资源映射和下载命令,减少手动逐个处理图片资源的步骤
  • 🧱 补充 Design Tokens 和设计预览图,方便下游模型继续实现和视觉校验
  • 🧭 附带面向下游 AI 的实现指引,明确优先级、适配方式和约束条件
  • ⚙️ 支持通过 CLI 参数和环境变量配置 Tailwind 输出、跳过切图、单位缩放和提示语言
  • 📦 提供 inline / files 两种产出模式:默认 inline 直接在 tool result 返回全部内容;files 把 HTML、切图映射、Design Tokens、Guide 打包成 context.md + preview.png 落盘并只回传 resource_link,规避大设计稿命中 MCP 客户端 tool 输出 token 上限(例如 Claude Code 默认 MAX_MCP_OUTPUT_TOKENS=25000)的截断问题

文档

完整文档请访问 lanhu.refineup.com。

快速开始

环境要求

  • Node.js ^20.19.0 || >=22.12.0

设计稿转码

  • 设计稿需要先开启转码功能,然后上传到蓝湖

Step 1. 安装 Lanhu Helper 谷歌浏览器插件

先安装 Lanhu Helper。后面的蓝湖 Token、选中图层链接和示例提示词,都要在蓝湖的图层上右键,从弹出的菜单里复制。

Step 2. 准备环境变量

先创建一个 .env.local 文件。

打开已登录的蓝湖页面,在图层上右键,点击「复制 Token」,把剪贴板内容写入 .env.local。

dotenv
LANHU_TOKEN=刚才复制的内容

Step 3. 配置 MCP

把下面对应客户端的 MCP 配置写入对应文件;如果使用 Qoder,在 MCP 服务页点击“添加”后粘贴配置:

Claude Code(.mcp.json) / Cursor(.cursor/mcp.json)

json
{
  "mcpServers": {
    "lanhu-context-mcp": {
      "command": "npx",
      "args": ["-y", "lanhu-context-mcp"]
    }
  }
}

TRAE(.trae/mcp.json)

json
{
  "mcpServers": {
    "lanhu-context-mcp": {
      "command": "npx",
      "args": ["-y", "lanhu-context-mcp", "--cwd", "${workspaceFolder}"]
    }
  }
}

Codex(.codex/config.toml)

toml
[mcp_servers.lanhu-context-mcp]
cwd = "/absolute/path/to/current-project"
command = "npx"
args = ["-y", "lanhu-context-mcp"]

Qoder(全局 MCP 服务)

json
{
  "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 存在一个设计问题:MCP 子进程的工作目录不会指向当前项目,导致 .env.local 读不到、.lanhu-context-mcp.local/ 写入异常。所以 TRAE 配置里必须固定传入 --cwd 参数;值用编辑器内置变量 ${workspaceFolder} 即可自动指向项目根,无需写死绝对路径。

Codex 的 MCP 配置比较特殊,需要额外设置 cwd,并把它填写为当前项目的绝对路径。由于这个路径通常因人而异,通常不建议把 .codex/config.toml 提交到 Git,建议做好 Git 排除并由每位开发者在本地自行维护。

Qoder 目前只能在全局(用户级)配置 MCP,进程的工作目录通常是 /,会导致写入 .lanhu-context-mcp.local/ 时因为没有权限直接报错。所以 Qoder 配置里必须显式指定 --cwd(或 env.CWD)把工作目录切到项目根,同时通过 env 传入 LANHU_TOKEN(stdio 子进程不会继承 shell 环境变量)。

--cwd 不用写死成绝对路径。支持变量替换的编辑器(如 VSCode 系)可以直接用内置变量,配置就能在团队间复用、也不必每人手改路径:"--cwd", "${workspaceFolder}"。

Windows

如果在 Windows 下直接使用上面的 npx 配置启动失败,可以改用下面的写法:

Claude Code(.mcp.json) / Cursor(.cursor/mcp.json)

json
{
  "mcpServers": {
    "lanhu-context-mcp": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "lanhu-context-mcp"]
    }
  }
}

TRAE(.trae/mcp.json)

json
{
  "mcpServers": {
    "lanhu-context-mcp": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "lanhu-context-mcp",
        "--cwd",
        "${workspaceFolder}"
      ]
    }
  }
}

Codex(WSL2)

toml
[mcp_servers.lanhu-context-mcp]
cwd = "/absolute/path/to/current-project"
command = "npx"
args = ["-y", "lanhu-context-mcp"]

Codex(原生)

toml
[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(全局 MCP 服务)

json
{
  "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 原生 fallback 参考: openai/codex#2555

Step 4. 将蓝湖链接和提示词发给 AI

在要交给 AI 的那个图层上右键,用「复制示例提示词」或「复制选中图层链接」拿到内容,直接发给 AI。

text
请根据这个蓝湖设计稿实现
@https://lanhuapp.com/web/#/item/project/detailDetach?tid={tid}&pid={pid}&project_id={project_id}&image_id={image_id}
text
https://lanhuapp.com/web/#/item/project/detailDetach?tid={tid}&pid={pid}&project_id={project_id}&image_id={image_id}

提示词可以按你的想法来写,但蓝湖 URL 必须确保完整且正确,否则无法正常调用 Tool。

查看更丰富的文档

生态

Lanhu Helper — 配套的蓝湖 Chrome 浏览器扩展,在图层上右键即可复制 Token、选中图层链接和示例提示词

参与开发

欢迎提交 PR 或 issue。下面是把开发环境跑起来的流程。

1. 安装依赖

仓库使用 pnpm workspace(含 playground 子包),在根目录执行:

sh
pnpm install

2. 准备 .env.local

复制示例文件,再去掉 .example 后缀填入凭据:

sh
cp .env.local.example .env.local

字段说明:

字段必填用途
LANHU_TOKEN是调用蓝湖 API 的 Token。用 Lanhu Helper 在已登录蓝湖的图层上右键「复制 Token」后写入
LANHU_TEST_URL跑集成测试时填一条真实可访问的蓝湖设计稿详情链接,集成测试会向它发请求

3. 三层验证矩阵

不同改动建议跑不同层级的验证:

层级命令何时跑依赖
单元测试pnpm test / pnpm test:coverage任何 PR 必过;目标覆盖率 100%无
集成测试pnpm test:integration 及其 :http/:stdio 变体改服务、工具、transport、协议层时建议跑LANHU_TOKEN + LANHU_TEST_URL
端到端验证场地见下方 playground 一节改输出格式、提示词、文件落盘逻辑时手测LANHU_TOKEN + 任何接入 MCP 的 AI 客户端

集成测试更细的子集(仅 files 模式、仅 stdio 等)在 package.json 的 test:integration:* 脚本里。

4. playground — 端到端验证场地(E2E verification harness)

playground/ 是一个 Vue 3 + Vite + Tailwind 工程,专门用来在真实 MCP 客户端(Claude Code / Cursor / Codex / Qoder)里跑实际蓝湖 API、把生成的页面落到 src/pages/、并通过 dev server 实时预览——验证 get_design_context 整条链路的真实行为,是单元/集成测试覆盖不到的层面。

常用命令:

sh
# 启动 playground dev server
pnpm play

# 清理上一轮产物(src/pages 内页面 + src/assets 内切图 + .lanhu-context-mcp.local 目录)
pnpm play:clean

详细工作流和客户端配置看 playground/README.md。

5. 提 PR 前的检查清单

  • pnpm typecheck 通过
  • pnpm test 通过且覆盖率不下降(运行 pnpm test:coverage 确认)
  • pnpm lint 通过
  • 涉及对外行为或产出格式的改动,至少跑一次 pnpm test:integration:files 或在 playground 里实际验收

License

MIT

Copyright (c) 2026-present, REFINIST

Use Lanhu Context MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Lanhu Context MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Lanhu Context MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Lanhu Context MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "lanhu-context-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Lanhu Context MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Lanhu Context MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Lanhu Context MCP to help me with this task?
Lanhu Context MCP
Sure. I read it.
Here is what I found using Lanhu Context MCP.

Frequently asked questions

What is the Lanhu Context MCP MCP server used for?

Lanhu Context MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Lanhu Context MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Lanhu Context MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Lanhu Context MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Lanhu Context MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Lanhu Context MCP MCP to TypingMind?

Lanhu Context MCP runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Lanhu Context MCP MCP provide in TypingMind?

Lanhu Context MCP exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Lanhu Context MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Lanhu Context MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇