Local MCP Server
在Termux中运行本地MCP服务器,支持Ollama模型的文件读取与命令执行。
下载 11
在本地设备上运行多个开源代码模型,实现代码生成与审查。
openclaw skills install @twinsgeeks/local-coding命令、参数、文件名以原文为准
在您自己的硬件上运行最优秀的开源代码模型。DeepSeek-Coder、Codestral、StarCoder 和 Qwen-Coder 模型根据需求智能分配至您的各台设备,集群会自动为每次代码生成请求选择最优的计算节点。
您的代码始终保留在本地网络中。无需 GitHub Copilot 订阅,也无云 API 费用。
| 模型 | 参数量 | Ollama 名称 | 优势 |
|---|---|---|---|
| Codestral | 22B | codestral | 支持 80+ 种语言,擅长补全中间代码,Mistral 的代码专用模型 |
| DeepSeek-Coder-V2 | 236B MoE(激活部分约 21B) | deepseek-coder-v2 | 在代码任务上的表现可媲美 GPT-4 Turbo |
| DeepSeek-Coder | 6.7B, 33B | deepseek-coder:33b | 专为代码设计(87% 训练数据来自代码) |
| Qwen2.5-Coder | 7B, 32B | qwen2.5-coder:32b | 强大的多语言代码生成能力 |
| StarCoder2 | 3B, 7B, 15B | starcoder2:15b | 基于 The Stack v2 训练,支持 600+ 种语言 |
| CodeGemma | 7B | codegemma | Google 推出的代码专注型 Gemma 变体 |
pip install ollama-herd # PyPI: https://pypi.org/project/ollama-herd/
herd # 启动路由服务(端口 11435)
herd-node # 在每台设备上运行 —— 自动发现路由服务安装过程中不会下载任何模型。所有模型拉取均需用户确认。
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11435/v1", api_key="not-needed")
response = client.chat.completions.create(
model="codestral",
messages=[{"role": "user", "content": "用 Python 编写一个支持 TTL 的线程安全 LRU 缓存"}],
)
print(response.choices[0].message.content)curl http://localhost:11435/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-coder-v2:16b",
"messages": [{"role": "user", "content": "检查以下代码中的潜在错误和安全问题:\n\n```python\ndef process_payment(amount, card_number):\n ...\n```"}]
}'curl http://localhost:11435/api/chat -d '{
"model": "qwen2.5-coder:32b",
"messages": [{"role": "user", "content": "将这段代码重构为使用 async/await:..."}],
"stream": false
}'该集群在 http://localhost:11435/v1 提供兼容 OpenAI 的 API 接口,可对接任意编码工具:
| 工具 | 配置方式 |
|---|---|
| Aider | aider --openai-api-base http://localhost:11435/v1 --model codestral |
| Continue.dev | 在 VS Code 设置中将 API 基地址设为 http://localhost:11435/v1 |
| Cline | 设置提供者为 OpenAI 兼容,基地址为 http://localhost:11435/v1 |
| Open WebUI | 将 Ollama 地址设为 http://localhost:11435 |
| LangChain | ChatOpenAI(base_url="http://localhost:11435/v1", model="codestral") |
跨平台支持:以下为示例配置。只要内存相当,任何设备(Mac、Linux、Windows)均可使用。
| 设备 | 内存 | 推荐代码模型 |
|---|---|---|
| MacBook Air(8GB) | 8GB | starcoder2:3b 或 deepseek-coder:6.7b |
| Mac Mini(16GB) | 16GB | codestral 或 starcoder2:15b |
| Mac Mini(32GB) | 32GB | qwen2.5-coder:32b 或 deepseek-coder:33b |
| Mac Studio(128GB) | 128GB | deepseek-coder-v2 —— 前沿代码质量 |
# 查看已加载到内存中的模型
curl -s http://localhost:11435/api/ps | python3 -m json.tool
# 查看所有可用模型
curl -s http://localhost:11435/api/tags | python3 -m json.tool
# 查看最近的代码请求记录
curl -s "http://localhost:11435/dashboard/api/traces?limit=5" | python3 -m json.toolLlama 3.3、Qwen 3.5、DeepSeek-R1、Mistral Large —— 通过同一接口处理非代码类任务。
curl http://localhost:11435/api/generate-image \
-d '{"model": "z-image-turbo", "prompt": "开发者工作区插图", "width": 512, "height": 512}'curl http://localhost:11435/api/transcribe -F "file=@standup.wav" -F "model=qwen3-asr"~/.fleet-manager/ 目录下的文件。已收录 1 个 Skill