lmstudio-ollama-mcp
lmstudio-ollama-mcp
npm install -g lmstudio-ollama-mcp
lmstudio-ollama-mcp doctor # or: forge doctor
lmstudio-ollama-mcp "add unit tests for src/utils/logger.ts"本地优先。私密。免费。无需 API 密钥。 前沿模型(GPT-4o、Claude 4)可选——仅用作规划器,实际工作由小型本地模型完成。别名
forge/forgecode让你保留肌肉记忆。
为什么选择 lmstudio-ollama-mcp
Claude Code / Codex | lmstudio-ollama-mcp | |
运行环境 | 云端 API(付费,数据离开本机) | LM Studio · Ollama · llama.cpp(离线、私密) |
成本 | 按 token 计费 | $0(下载模型后) |
子代理 | 单线程或云端并行 | 硬件感知的本地并行 |
模型选择 | 厂商锁定 | 任意 GGUF / 兼容 OpenAI 的模型 |
混合模式 | — | 前沿模型规划,本地模型执行(可选) |
沙箱 | 云端容器 | 你的文件系统,你的规则 |
MCP | — | 已就绪:将本地运行时桥接为 MCP 工具 |
一句话: lmstudio-ollama-mcp 将 Claude Code 的智能体循环——读取 → 规划 → 编辑 → 借助工具验证——带到你的 MacBook 上:内置智能路由器,简单任务交给本地 7B 模型,仅在需要复杂推理时才调用前沿模型。
Related MCP server: Shared Workspace MCP
演示
# 1 — Diagnose
lmstudio-ollama-mcp doctor
# Hardware: Apple M3 (8 cores / 16GB) • Recommended: 8 agents
# ● lmstudio (LM Studio) http://localhost:1234/v1 available
# models: gemma-3-12b-qat, qwen3-27b-ud-iq2_s …
lmstudio-ollama-mcp models
# ● lmstudio ▸ gemma-3-12b-qat 6.5GB Q4_0
# ▸ qwen3-27b 7.8GB IQ2_S
# 2 — One-shot
lmstudio-ollama-mcp "refactor src/providers into a registry + add tests. keep public API stable"
# 3 — Parallel (auto-splits into sub-agents)
lmstudio-ollama-mcp --parallel 4 "implement auth module, write tests, and update docs"
# forge alias also works:
forge --parallel 4 "implement auth module, write tests, and update docs"
# 4 — Force a specific model
lmstudio-ollama-mcp --model ollama:qwen2.5-coder:14b "explain this repo's error handling"
lmstudio-ollama-mcp --provider lmstudio --model gemma-3-12b "fix the failing test in tests/tools.test.ts"
# 5 — Interactive
lmstudio-ollama-mcp
# lmstudio-ollama-mcp> add dark mode to docs/index.html快速开始
前置要求
Node.js >= 18
以下任选其一:
安装
npm install -g lmstudio-ollama-mcp
# aliases also available: forge, forgecode
# or one-off
npx lmstudio-ollama-mcp doctor首次运行
git clone https://github.com/your-org/your-project && cd your-project
lmstudio-ollama-mcp init # creates lmstudio-ollama-mcp.json (also reads forgecode.json for compat)
lmstudio-ollama-mcp doctor # verify providers + hardware
lmstudio-ollama-mcp "list the codebase structure and suggest 3 small improvements"纯本地模式无需 API 密钥。混合模式(前沿 + 本地)请设置以下环境变量:
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...架构
┌─────────────────────────────────────────────────────────┐
│ CLI lmstudio-ollama-mcp "task" • doctor • models │
│ aliases: forge, forgecode │
├─────────────────────────────────────────────────────────┤
│ Router (strategy: auto | local-first | frontier-first)│
│ ├─ classify(prompt) → trivial | small | medium | large │
│ └─ thresholds.preferLocalFor: lint/format/test/search │
├─────────────────────────────────────────────────────────┤
│ Orchestrator (decompose → batch by deps → schedule) │
│ ├─ Planner LLM decomposes goal → SubTasks[] │
│ └─ Scheduler (hardware-aware p-limit, preserves order) │
├─────────────────────────────────────────────────────────┤
│ Agent Loop (provider.chat ↔ tool executor) │
│ ├─ Tools: read_file, write_file, edit_file, bash, │
│ │ glob, grep, list_dir │
│ └─ Max 25 tool turns, exact-string edits │
├─────────────────────────────────────────────────────────┤
│ Providers (OpenAI-compatible) │
│ ├─ LM Studio http://localhost:1234/v1 (+ fs scan) │
│ ├─ Ollama http://localhost:11434 (+ /api/tags) │
│ ├─ llama.cpp http://localhost:8080/v1 │
│ └─ Frontier OpenAI / Anthropic (optional) │
├─────────────────────────────────────────────────────────┤
│ Hardware Detector • Scheduler │
│ cores × overcommit, free mem / perAgent → maxParallel │
│ Apple Silicon bonus, clamp 1..16 │
└─────────────────────────────────────────────────────────┘数据流:
User prompt
→ Router.classify → pick provider+model (local for small, frontier for large)
→ If parallel & non-trivial: Orchestrator.decompose → 2-6 SubTasks
→ Scheduler.runAll(SubTasks) with maxParallel = f(cores, RAM)
→ Each SubTask → Agent(provider, model, ToolExecutor) → tool loop
→ Synthesis agent merges results
→ Final summary提供商
提供商 | 默认 URL | 发现机制 | 备注 |
LM Studio |
|
| 支持 |
Ollama |
| 原生使用 | 需要先运行 |
llama.cpp |
|
| 通过 |
OpenAI |
| API | 设置 |
Anthropic |
| API | 设置 |
所有提供商都使用带 tools(函数调用)的 OpenAI 兼容 Chat Completions 接口,并自动规范化 reasoning_content(Qwen/Gemma)。
添加自定义端点
// lmstudio-ollama-mcp.json
{
"providers": {
"my-local": { "type": "openai", "baseUrl": "http://192.168.1.10:1234/v1", "enabled": true }
}
}并行子代理
通过规划器 LLM(有前沿模型则用前沿模型,否则用本地模型)将复杂目标拆分为 2–6 个独立子任务。执行受硬件能力约束:
// hardware/detector.ts — recommendParallelism()
cpuLimit = floor(cores * overcommit) - 1
memLimit = floor((totalGb*1024 - 2048) / perAgentMb)
maxParallel = min(cpuLimit, memLimit) + appleSiliconBonus
// clamp: 1..8 default, up to 16 on 64GB machineslmstudio-ollama-mcp --parallel 8 "migrate codebase from Jest to Vitest"
# Decomposed:
# t1 Explore & plan → search (routed to local 7B)
# t2 Implement → code (routed to local or frontier)
# t3 Verify → test (routed to local)
# Runner: Scheduler.runAll with p-limit = 8带有 dependsOn 的任务按拓扑顺序分批运行——第 N 批只有等第 N-1 批完成后才会启动。
对本地模型友好: 简单任务(lint、format、summarize、explain)始终路由到本地,无论采用何种策略。
配置
配置解析优先级:DEFAULT < ~/.lmstudio-ollama-mcp/config.json < ./lmstudio-ollama-mcp.json < 环境变量。
旧版配置文件 ~/.forgecode/config.json 及 forgecode.json / forge.json 仍会被读取以保持向后兼容(新路径优先)。
lmstudio-ollama-mcp config --show # resolved JSON
lmstudio-ollama-mcp config --path # file locations
lmstudio-ollama-mcp init # scaffold lmstudio-ollama-mcp.jsonlmstudio-ollama-mcp.json 配置参考
{
"version": 1,
"providers": {
"lmstudio": { "type": "lmstudio", "baseUrl": "http://localhost:1234/v1", "enabled": true },
"ollama": { "type": "ollama", "baseUrl": "http://localhost:11434", "enabled": true },
"llamacpp": { "type": "llamacpp", "baseUrl": "http://localhost:8080", "enabled": true },
"openai": { "type": "openai", "baseUrl": "https://api.openai.com/v1", "apiKey": "sk-..." }
},
"router": {
"strategy": "auto", // auto | local-first | frontier-first | local-only
"frontierProvider": "openai",
"frontierModel": "gpt-4o-mini",
"thresholds": {
"smallTaskMaxTokens": 2000,
"preferLocalFor": ["lint","format","test","search","summarize","explain"]
}
},
"hardware": {
"maxParallelAgents": 4, // auto if omitted
"maxMemoryPerAgentMb": 1200,
"cpuOvercommit": 1
},
"permissions": {
"allowBash": true,
"allowWriteOutsideWorkspace": false,
"allowNetwork": true
}
}策略:
auto—— 简单/小型任务 → 本地;中/大型任务 → 前沿模型(若可用),否则本地。(推荐)local-first—— 只有中/大型任务才使用前沿模型。local-only—— 绝不调用前沿模型(完全离线)。frontier-first—— 始终优先使用前沿模型。
工具
代理提供 7 个工具——与 Claude Code 相同的工具集,并限制在工作区沙箱内:
工具 | 说明 |
| 读取文件(上限 2 MB,超出则用 grep) |
| 创建/覆盖文件(自动 mkdir -p) |
| 精确字符串替换(必须且只能匹配一次) |
| 运行命令( |
|
|
| 正则搜索(跳过 |
| 列出目录内容 |
安全机制:除非设置 permissions.allowWriteOutsideWorkspace=true,否则会阻止路径逃逸;危险命令(rm -rf /)会被拒绝;过大的输出会被截断(30k)。
对比:何时使用哪种模型
任务 | 为何本地模型更优 | 示例 |
Lint / format / grep | 0.2 秒 vs 2 秒 RTT |
|
解释 / 总结 | 私有代码库保留在本地 |
|
小改动 | 无需排队,零成本 |
|
大型重构 | 前沿模型规划,本地模型并行执行 |
|
复杂推理 | 需要 70B / 前沿模型 |
|
开发
npm install
npm run build # tsc
npm test # vitest
npm run dev -- doctor项目结构:
src/
cli/ commander CLI + commands (doctor, models, config, init)
config/ Zod schema + layered store (global ↔ project)
hardware/ detector (cores/RAM/GPU) + p-limit scheduler
providers/ base + openai-compatible + lmstudio/ollama/llamacpp + registry + router
core/ Agent (tool loop) + Orchestrator (decompose + parallel)
tools/ definitions + executor (fs/glob/grep/bash)
utils/ logger, format
tests/ vitest suites (hardware, tools, router, config, providers)
docs/ GitHub Pages landing (WizardZ-inspired, lime/black)路线图
流式输出(
--stream)MCP(Model Context Protocol)服务器——将本地模型作为 MCP 工具开放给其他代理
持久化记忆(
.lmstudio-ollama-mcp/memory.md)lmstudio-ollama-mcp plan——仅演练分解,不实际执行视觉模型(Gemma 12B 多模态),用于截图驱动的 UI 工作
hooks——工具执行前/后的钩子Windows / Linux GPU(CUDA/Vulkan)调度器提示
贡献
欢迎提交 PR。请保持核心原则:本地优先、依赖最少、硬件感知、拒绝 AI 垃圾内容。
npm run build && npm test关键词
lm-studio lmstudio ollama llama.cpp local-llm local-first coding-agent autonomous-agent claude-code codex sub-agents parallel-agents mcp model-context-protocol hardware-aware openai-compatible gguf agentic dev-tools ai-coding on-device-ai privacy
许可证
MIT — 参见 LICENSE。
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.
Related MCP Servers
- AlicenseAqualityAmaintenanceA fully featured coding agent that uses symbolic operations (enabled by language servers) and works well even in large code bases. Essentially a free to use alternative to Cursor and Windsurf Agents, Cline, Roo Code and others.2928,582MIT
- AlicenseNot gradedqualityBmaintenanceLocal-first memory, pipelines, learning, feedback, and safe code tools for AI coding agents.MIT
- FlicenseNot gradedqualityDmaintenanceMulti-agent continuous development system with local LLM orchestration.1
- AlicenseCqualityBmaintenanceEnables AI coding agents to navigate massive codebases through fast code property graph queries, sandboxed recursive language model execution, durable semantic memory, and swarm concurrency coordination.4MIT
Related MCP Connectors
Cross-agent artifact workspace with provenance across Claude Code, Codex, Cursor, LangGraph.
Coding agents from Claude Code, Cursor and Codex claim jobs and lock files on one shared board.
Coding agents build full-stack apps in persistent workspaces and share them by link.
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/fthsrbst/lmstudio-ollama-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server