ZhuoS62

cn-llm-mcp

Community ZhuoS62
Updated

cn-llm-mcp

本地 MCP Server,用来让 Claude、Codex、Cursor 等支持 MCP 的 agent 把低风险小任务委托给低成本模型执行,主 agent 负责审核结果。

它按 OpenAI-compatible Chat Completions 接口实现,支持 DeepSeek、通义千问兼容模式、Kimi、智谱、豆包,也支持自定义兼容服务。

适合做什么

  • 摘要、改写、文案初稿
  • README、说明文档、邮件草稿
  • 简单 HTML/CSS/JS 页面初稿
  • 小范围测试草稿
  • 低风险机械代码修改建议

不建议把安全、权限、支付、生产数据、复杂架构判断、密钥、cookie、令牌或隐私数据委托给这个工具。

客户本地安装

客户需要自己准备国内模型或代理服务的 API Key。API Key 留在客户自己的电脑上。

git clone <你的仓库地址> cn-llm-mcp
cd cn-llm-mcp
npm install
npm run build
cp .env.example .env

然后编辑 .env,填入客户自己的 API Key。

DeepSeek 示例:

CN_LLM_PROVIDER=deepseek
CN_LLM_API_KEY=replace_me
CN_LLM_MODEL=deepseek-chat

自定义 OpenAI-compatible 代理示例:

CN_LLM_PROVIDER=custom
CN_LLM_BASE_URL=https://example.com/v1
CN_LLM_MODEL=your-model
CN_LLM_API_KEY=replace_me

服务启动时会自动读取项目根目录的 .env

自检

npm run doctor

自检会检查:

  • Node.js 版本是否 >= 20
  • dist/index.js 是否存在
  • .env 是否存在
  • CN_LLM_API_KEY 是否填写
  • MCP 是否能列出 run_cn_modeldraft_code_patch

doctor 不会真实调用模型生成内容。

常用 provider

# DeepSeek
CN_LLM_PROVIDER=deepseek
CN_LLM_MODEL=deepseek-chat

# 通义千问 OpenAI 兼容模式
CN_LLM_PROVIDER=qwen
CN_LLM_MODEL=qwen-plus

# Kimi
CN_LLM_PROVIDER=kimi
CN_LLM_MODEL=moonshot-v1-8k

# 智谱
CN_LLM_PROVIDER=zhipu
CN_LLM_MODEL=glm-4-flash

# 豆包,需要按火山方舟创建的 endpoint/model 调整
CN_LLM_PROVIDER=doubao
CN_LLM_MODEL=doubao-seed-1-6-250615

Claude Desktop 配置

把下面配置加入 Claude Desktop 的 MCP 配置文件。把路径替换成客户本机的绝对路径。

{
  "mcpServers": {
    "cn-llm-worker": {
      "command": "node",
      "args": ["/absolute/path/to/cn-llm-mcp/dist/index.js"]
    }
  }
}

模板文件:

examples/claude-desktop.json

Codex 配置

把下面配置加入 ~/.codex/config.toml。把路径替换成客户本机的绝对路径。

[mcp_servers.cn-llm-worker]
command = "node"
args = ["/absolute/path/to/cn-llm-mcp/dist/index.js"]
startup_timeout_sec = 30

模板文件:

examples/codex-config.toml

Cursor 配置

Cursor 的 MCP 配置通常也是 JSON。把路径替换成客户本机的绝对路径。

{
  "mcpServers": {
    "cn-llm-worker": {
      "command": "node",
      "args": ["/absolute/path/to/cn-llm-mcp/dist/index.js"]
    }
  }
}

模板文件:

examples/cursor-mcp.json

建议给 agent 的规则

可以把下面规则加入 Claude Project instructions、Codex AGENTS.md 或 Cursor rules:

对于低风险、小范围、机械性任务,可以优先调用 `cn-llm-worker` 让低成本模型生成草稿,例如摘要、文案、README 初稿、简单测试草稿、小型 patch 或简单网页初稿。

不要把 secrets、API key、cookie、令牌、隐私数据或无关的大段上下文发送给 `cn-llm-worker`。

收到 `cn-llm-worker` 的结果后,必须由主 agent 审核;涉及安全、权限、支付、数据一致性、复杂架构判断或高风险代码时,不要委托给该工具。

如果调用了 `cn-llm-worker`,请告诉用户 provider、model 和 token usage。如果没有调用,不要假装调用。

模板文件:

examples/agent-rule.md

暴露的工具

run_cn_model

通用任务委托工具。适合摘要、文案、方案、简单代码草稿。

参数示例:

{
  "task": "把下面内容整理成三点摘要",
  "context": "需要处理的内容",
  "output_format": "text"
}

draft_code_patch

代码 patch 草稿工具。适合小范围、低风险代码任务。

参数示例:

{
  "task": "给 add 函数补一个边界测试",
  "files": [
    {
      "path": "src/math.ts",
      "content": "export function add(a: number, b: number) { return a + b; }"
    }
  ],
  "constraints": "只返回 unified diff"
}

测试提示词

配置完成后,在 agent 里测试:

优先使用 cn-llm-worker。请让低成本模型用三句话解释 MCP 是什么,然后你审核它的回答。

如果调用成功,agent 应该能看到 providermodelusage

常见问题

401 invalid credentials

API Key 无效、过期、填错,或代理服务不接受当前 key。重新生成 API Key 后更新 .env

404 Not Found

通常是 CN_LLM_BASE_URL 不对。OpenAI-compatible 服务一般需要以 /v1 结尾,例如:

CN_LLM_BASE_URL=https://example.com/v1

model not found

CN_LLM_MODEL 不在服务商支持列表里。改成服务商文档里的模型名。

agent 看不到工具

先运行:

npm run doctor

如果 doctor 正常,重启 Claude/Codex/Cursor,确认 MCP 配置里的路径是绝对路径并且指向 dist/index.js

安全说明

  • .env 不要提交到仓库。
  • 客户应使用自己的 API Key。
  • 这个 MCP Server 不会直接修改文件,只返回文本或 patch 草稿。
  • 最终应用 patch、运行测试和判断风险应由主 agent 完成。

MCP Server · Populars

MCP Server · New

    WJZ-P

    Douyin Upload MCP Skill

    MCP Server

    Community WJZ-P
    pwno-io

    pwno-mcp

    MCP for Pwn

    Community pwno-io
    antoinebou12

    UML-MCP: Diagram Generation via MCP

    UML-MCP Server is a UML diagram generation tool based on MCP (Model Context Protocol), which can help users generate various types of UML diagrams through natural language description or directly writing PlantUML and Mermaid and Kroki https://uml-mcp.vercel.app/docs

    Community antoinebou12
    JeremyVyska

    BC Code Intelligence MCP Server

    BC Code Intelligence MCP Server - Persona-driven workflow orchestration for Business Central development. Provides 16+ MCP tools, layered knowledge system, and intelligent BC pattern analysis through Model Context Protocol.

    Community JeremyVyska
    noimank

    FNewsCrawler (该项目已放弃维护)

    一个专门为大模型设计的财经信息MCP(Model Context Protocol)服务,通过高效的爬虫技术从各大财经网站(同花顺、东方财富等)获取实时资讯,为AI模型提供准确、及时的财经数据支持。

    Community noimank