Token导航 LogoToken导航TokenDH.com
MCP Local LLM logo
AI代理未说明官方级别未说明来源级核验

MCP Local LLM

MCP Server

一个允许Claude Code将机械任务委托给本地LLM的MCP服务器,核心功能包括总结、分类、提取和草稿生成,适用于需要批量处理文本但不需要前沿推理的场景。

工具数

7

提示词数

0

GitHub Stars

6

资源数

0
AI代理JavaScriptClaude成本优化Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

aplaceforallmystuff

提供方

aplaceforallmystuff

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

mcp本地llm

MCP服务器,允许Claude Code将机械任务委托给本地LLM。克劳德负责思考;您的本地模型处理繁重的工作——摘要、分类、提取、起草。

这是 克劳德的替代者。这是一个成本优化层。Claude保持控制,决定委派什么,并审查输出。局部模型只做体积工作,不需要边界推理。

建筑

mcp-local-llm architecture

Claude Code作为编排者坐在最上面。它通过mcp调用mcp本地llm工具,mcp将请求转发到本地运行的Ollama(或任何与OpenAI兼容的后端)。克劳德决定委派什么,并审查返回的内容。

需求

  • 奥拉玛 已安装并正在运行
  • Node.js 18+
  • Claude Code(或任何兼容MCP的客户端)

设置

1.安装Ollama并拉动模型

# Install Ollama (macOS)
brew install ollama

# Start the Ollama service
ollama serve

# Pull the default model
ollama pull qwen2.5-coder:7b

2.克隆和构建

git clone https://github.com/aplaceforallmystuff/mcp-local-llm.git
cd mcp-local-llm
npm install
npm run build

3.添加到克劳德代码

claude mcp add local-llm -s user -- node /path/to/mcp-local-llm/dist/index.js

或手动添加到 ~/.claude.json:

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

4.验证

在克劳德法典中 local_status 该工具应显示您的Ollama连接和可用型号。

可用工具

local_summarize

使用本地LLM总结文本。

参数:

  • text (必填):总结文本
  • style: "brief" | "detailed" | "bullet_points" | "executive"
  • max_length:大约最大字数(默认值:150)
  • focus:需要强调的具体方面

用途: 大量总结、浓缩研究、会议记录

local_draft

生成初稿以供改进。

参数:

  • task (必填):起草什么
  • context (必填):背景和要求
  • format:输出格式(markdown、纯文本等)
  • tone:期望的语气(专业、休闲、技术)

用途: 样板、初始内容、基于模板的生成

local_classify

将文本分类。

参数:

  • text (必填):要分类的文本
  • categories (必填):可能类别的数组
  • allow_multiple:允许多个类别(默认值:false)
  • explain:包括解释(默认值:false)

用途: 排序、标记、组织内容

local_extract

从文本中提取结构化信息。

参数:

  • text (必填):要提取的文本
  • fields (必填):要提取的字段数组
  • output_format: "json" | "yaml" | "markdown_table"

用途: 解析文档、数据提取

local_transform

根据说明转换文本。

参数:

  • text (必填):要转换的文本
  • instruction (必填):转换说明

用途: 格式化、样式转换、简单重写

local_complete

原始完成,实现最大灵活性。

参数:

  • prompt (必填):提示
  • system:系统消息
  • max_tokens:最大令牌数(默认值:2048)
  • temperature:温度(默认值:0.7)

用途: 不适合其他工具的自定义任务

local_status

检查本地LLM连接状态和可用型号。

配置

环境变量(所有可选--默认值适用于标准Ollama安装):

变量默认值描述
LOCAL_LLM_BASE_URLhttp://localhost:11434/v1API终点
LOCAL_LLM_MODELqwen2.5-coder:7b要使用的模型
LOCAL_LLM_MAX_TOKENS2048默认最大令牌数
LOCAL_LLM_TEMPERATURE0.7默认温度

替代方案:Docker模型运行器

如果你更喜欢Docker Model Runner而不是Ollama:

# Enable Model Runner with TCP access
docker desktop enable model-runner --tcp=12434

# Pull a model
docker model pull ai/gemma3:latest

然后设置环境变量:

export LOCAL_LLM_BASE_URL="http://localhost:12434/engines/v1"
export LOCAL_LLM_MODEL="ai/gemma3:latest"

任何公开与OpenAI兼容的API的后端都可以工作。

代表团理念

克劳德做本地模型做
复杂推理批量总结
架构决策锅炉板生成
质量审查文本提取/格式化
解决新问题简单分类
最终编辑初始草稿生成

克劳德评论,本地模式产生。局部模型处理体积;克劳德负责质量控制。

教克劳德委派

一旦MCP服务器运行,Claude Code可以自动调用这些工具。但克劳德不会知道 *当* 除非你告诉它,否则不要使用它们。以下是设置方法。

选项1:将路由指令添加到CLAUDE.md

最可靠的方法。将委派规则添加到您的项目或全局 CLAUDE.md 文件,这样克劳德每次会话都会应用它们:

## Local LLM Routing

Route mechanical tasks to local models via `mcp__local-llm__*` tools to save API costs.

| Task Type | Tool | Example |
|-----------|------|---------|
| Summarizing content | `local_summarize` | Condensing research notes |
| Initial drafts | `local_draft` | Boilerplate emails, docstrings |
| Classification | `local_classify` | Sorting items, tagging content |
| Data extraction | `local_extract` | Parsing structured data from text |
| Text transformation | `local_transform` | Formatting changes, style conversions |
| Custom simple tasks | `local_complete` | Any mechanical task with clear instructions |

### When NOT to Route Locally

- Complex reasoning or analysis
- Security-sensitive operations
- Tasks requiring multi-step tool chains
- Content requiring voice/style judgment
- Anything you specifically want Claude's opinion on

选项2:直接问克劳德

你可以告诉克劳德在对话中委派:

"Summarize these 20 files using the local model"
"Use local_classify to sort these inbox items into categories: work, personal, spam"
"Draft a README section using local_draft, then review and clean it up yourself"

Claude将调用MCP工具并在向您展示之前查看输出。

选项3:将其构建为自定义代理

如果您使用Claude Code的代理系统,请在代理定义中添加委托说明:

## Agent: inbox-processor

When classifying inbox items, use `local_classify` to categorize each item
before deciding where to file it. Use `local_summarize` to create brief
descriptions for items that need them.

实际例子

批量汇总研究文件:

"Read all the markdown files in ./research/ and use local_summarize to create
a bullet-point summary of each one. Compile the summaries into a single document."

对内容进行分类和排序:

"I have 30 notes in my inbox folder. Use local_classify with categories
[project, reference, action-item, archive] to sort them, then move each
file to the appropriate folder."

起草并完善工作流程:

"Use local_draft to generate initial docstrings for all exported functions
in src/. Then review each one and fix anything that's inaccurate or unclear."

提取结构化数据:

"Extract the name, email, company, and role from each of these email signatures
using local_extract. Output as a JSON array."

模式总是一样的:本地模型产生,克劳德评论。你可以节省7B型号的批量工作成本,克劳德的判断是质量门。

故障排除

“连接被拒绝”或状态显示错误

  • 检查Ollama是否正在运行: ollama list
  • 如果需要,启动它: ollama serve
  • 验证端口: curl http://localhost:11434/v1/models

“找不到模型”

  • 拉动模型: ollama pull qwen2.5-coder:7b
  • 或者通过以下方式设置不同的模型 LOCAL_LLM_MODEL

使用不同的后端

  • LOCAL_LLM_BASE_URL 到后端的OpenAI兼容端点
  • LOCAL_LLM_MODEL 到后端支持的模型

工具未出现在Claude代码中

  • 验证MCP服务器是否已配置: claude mcp list
  • 检查路径 dist/index.js 是正确的
  • 如有需要,进行重建: npm run build

许可证

麻省理工学院

目录标签

目录标签

AI代理JavaScriptClaude成本优化任务委托本地部署文本处理本地LLM集成Claude协作

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

7

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP