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

Ollama MCP Agent

MCP Server

Ollama MCP Agent是一款基于Ollama和Model Context Protocol的本地AI代理工具,能够执行命令、管理Kubernetes、故障排除系统等,完全离线运行并具备系统感知能力。

工具数

6

提示词数

0

GitHub Stars

1

资源数

0
AI代理本地运行PythonClaude命令行工具Claude

安装说明

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

作者 / 组织

Pete1979

提供方

Pete1979

最后核验

2026/5/17 20:21

快速接入

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

命令预览

pip install --user -r mcp-server/requirements.txt

详细介绍

Ollama MCP代理

由Ollama+模型上下文协议驱动的AI代理,可以执行命令、管理Kubernetes、排除系统故障等。完全本地,支持离线,具有系统感知能力。

类似于Claude Code或GitHub Copilot CLI,但100%免费并可在本地运行!

![License: MIT](https://opensource.org/licenses/MIT) ![Python](https://www.python.org/downloads/) ![Ollama](https://ollama.com/)

✨ 特性

  • 🤖 MCP代理 -LLM可以实际执行命令,而不仅仅是建议它们
  • 🧠 对话记忆 -记住之前的输出,以便提出智能后续问题
  • 智能汽车审批 -安全操作立即执行,危险操作需要确认
  • 🖥️ 系统感知 -了解您的操作系统、硬件、桌面环境、k8s上下文、Docker状态
  • ☸️ Kubernetes工具 -健康检查、pod日志、描述资源、多命名空间查询
  • 🪟 Sway/Waybar管理 -查看配置、添加键绑定、重新启动/重新加载
  • 🌐 网络管理 -显示界面、配置DNS、管理连接
  • ⚙️ 系统控制 -服务状态、重启、日志、启用/禁用
  • 🔒 安全第一 -文件写入、删除和危险操作需要批准
  • 💾 离线功能 -100%本地,没有API密钥,没有订阅
  • 🎨 多重模型 -选择速度与质量(默认为3b,快速且功能强大)

🆚 比较

Ollama MCP代理Claude代码GitHub Copilot CLI
成本免费每月20美元每月10美元
隐私100%本地基于云基于云
离线✅ 是❌ 否❌ 没有
命令执行✅ 是✅ 是✅ 是的
系统上下文✅ 是有限有限
K8s集成✅ 内置手动手动
对话记忆✅ 是✅ 是有限
开源✅ 是❌ 否❌ 没有

🚀 快速开始

先决条件

  • 奥拉玛 已安装并正在运行
  • Python 3.8+(用于MCP代理)
  • Linux/macOS(Windows通过WSL)

安装

# Clone the repo
git clone https://github.com/Pete1979/ollama-mcp-agent.git
cd ollama-mcp-agent

# Install MCP dependencies
pip install --user -r mcp-server/requirements.txt

# Pull the default model (fast and capable)
ollama pull qwen2.5-coder:3b

# Make scripts executable
chmod +x agent chat ask code-helper models quick-fix

# Try the agent!
./agent -i

第一步

# Interactive agent mode
./agent -i
> check my disk space
> show my sway keybindings
> restart waybar
> check my kubernetes cluster for issues

# One-off commands - System Management
./agent "show my waybar config"
./agent "restart docker service"
./agent "list network connections"

# Kubernetes Management
./agent "show pods in prometheus namespace"
./agent "check for failing pods"

# Traditional chat without command execution
./chat
./ask "How do I optimize Docker on my system?"

🎯 默认模型

qwen2.5编码器:3b -快速且功能强大的编码模型,具有完全的系统感知能力

其他选项:

  • 7b -速度较慢,但更能进行复杂的推理
  • 14b -功能最强大,需要16GB+RAM

🔍 系统上下文功能

所有脚本现在都会自动为LLM提供:

  • 您的系统信息(操作系统:Fedora Linux 43,内核:6.18.8)
  • 硬件:AMD Ryzen AI 9 HX PRO 375(24核,62GB RAM,Radeon 890M GPU)
  • NPU:AMD Strix/Krackan神经处理单元(检测到)
  • 当前目录和git状态
  • Kubernetes上下文(k8s/grafana命名空间)
  • Docker状态
  • ~/projects中的可用项目

LLM了解您的系统,可以为您的设置提供具体建议!

要跳过系统上下文,请添加 --no-context 旗帜。

🤖 MCP代理(新!)

LLM现在可以执行命令了! 使用模型上下文协议,代理可以:

  • 执行bash命令
  • 读取和写入文件
  • 检查系统状态(磁盘、内存、CPU、网络)
  • 管理Kubernetes资源
  • 显示网络接口
  • 自动批准安全操作 (文件写入仍需确认)
  • 记住对话背景 后续问题
./agent -i                              # Interactive mode
./agent "check my k8s cluster health"
./agent "show pods in prometheus namespace"
./agent "list all namespaces"

MCP-AGENT-README.md 获取完整文档。

📚 脚本

agent 🆕

可以执行命令和管理系统的AI代理。

./agent -i                                    # Interactive mode (recommended)
./agent "check disk space"                    # One-off command
./agent "find pods with issues"               # Kubernetes health check
./agent "show logs for that pod"              # Follow-up questions work!

chat

与您的法学硕士进行互动聊天。

./chat                  # Use default model (qwen2.5-coder:3b)
./chat qwen2.5-coder:7b # Use smarter/slower model

ask

一次性问题,不开始聊天。

./ask "How do I use grep?"
./ask "Explain async/await in Python"
./ask --no-context "What is 2+2?"  # Skip system context for speed

code-helper

专门解决编程问题。

./code-helper          # Start interactive coding assistant

quick-fix

分析错误并获得修复建议。

./quick-fix "TypeError: cannot read property 'foo' of undefined"
cat error.log | ./quick-fix

models

管理您的Olama模型。

./models list          # Show installed models
./models pull          # Download new model
./models switch        # Pick a model to chat with
./models remove        # Delete a model

Bash别名(可选)

./install-aliases.sh 自动安装,或将这些添加到您的 ~/.bashrc:

# LLM aliases
alias llm='~/projects/ollama-mcp-agent/chat'
alias ask='~/projects/ollama-mcp-agent/ask'
alias agent='~/projects/ollama-mcp-agent/agent -i'     # NEW!
alias codehelp='~/projects/ollama-mcp-agent/code-helper'
alias llmfix='~/projects/ollama-mcp-agent/quick-fix'
alias llmodels='~/projects/ollama-mcp-agent/models'

# Model-specific shortcuts
alias llm-coder='~/projects/ollama-mcp-agent/chat qwen2.5-coder:3b'
alias llm-coder-fast='~/projects/ollama-mcp-agent/chat qwen2.5-coder:1.5b'
alias llm-coder-smart='~/projects/ollama-mcp-agent/chat qwen2.5-coder:7b'

然后重新加载: source ~/.bashrc

提示

  1. 使用正确的工具:

- 只是想要建议吗? → ./ask./chat - 需要它做点什么吗? → ./agent - Kubernetes故障排除? → ./agent -i 进行健康检查

  1. 为任务使用正确的模型:

- 快速提问→ qwen2.5编码器:3b(默认,推荐) - 复杂的任务→ qwen2.5编码器:7b(速度较慢,功能更强) - 最大能力→ qwen2.5编码器:14b(最慢,最聪明) - 看 ./performance-guide.sh 用于比较

  1. 管道内容直接:
   cat myfile.py | ./ask "Review this code"
   ./ask "Summarize this"  check my cluster for issues
   > show logs for that pod
   > what's causing this error?  # Remembers previous output!

示例

# Quick Linux command help
./ask "How to find large files in /var/log?"

# MCP Agent - actually DO things
./agent "check my disk space"
./agent "show all kubernetes namespaces"
./agent "find any pods with issues"
./agent "get logs from that error pod"

# Interactive troubleshooting
./agent -i
> check my cluster for issues
> describe that pod
> can you help fix this error?

# Code review
./code-helper
> Review this Python function for bugs: def calc(x): return x/0

# Error debugging
./quick-fix "fatal: unable to access 'https://github.com/...': SSL certificate problem"

# Learn new concepts with system context
./chat
> How do I deploy an app to MY kubernetes cluster?
# LLM knows you're on k8s context and can give specific advice!

# Generate code
./ask "Write a bash script to backup a directory with timestamp"

高级:API模式

您还可以使用Ollama的REST API:

# Generate completion
curl http://localhost:11434/api/generate -d '{
  "model": "qwen2.5-coder:3b",
  "prompt": "Write a Python hello world",
  "stream": false
}'

# Chat endpoint
curl http://localhost:11434/api/chat -d '{
  "model": "qwen2.5-coder:3b",
  "messages": [{"role": "user", "content": "Hello!"}],
  "stream": false
}'

故障排除

奥拉玛不跑?

sudo systemctl start ollama
systemctl status ollama

找不到模型?

./models list           # Check installed models
ollama pull qwen2.5-coder:3b  # Download model

反应迟钝?

  • 使用1.5b型号: ./agent -m qwen2.5-coder:1.5b -i
  • 跳过系统上下文: ./ask "question" --no-context
  • 检查 ./performance-guide.sh 优化提示

代理没有生成好的命令?

  • 尝试使用7b模型处理复杂任务: ./agent -m qwen2.5-coder:7b -i
  • 在你的要求中更加具体
  • 使用互动模式进行后续澄清

🤝 贡献

欢迎投稿!请随意:

  • 报告错误
  • 建议功能
  • 提交拉取请求
  • 改进文档

📄 许可证

MIT许可证-请参阅 许可证 详细信息文件

🙏 学分

⭐ 明星历史

如果你觉得这很有用,请在repo上加星!

______________________________________________________________________

制作❤️ 对于开源社区

目录标签

目录标签

AI代理本地运行PythonClaude命令行工具本地部署Kubernetes管理系统管理

支持客户端

Claude

接入字段

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

stdio

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

none

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdionone部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP