mcp-linux代理
一个轻量级的CLI客户端 Linux MCP服务器此工具在无头服务器上运行,不需要X11或其他显示库,可以直接从终端进行交互式Linux系统诊断。
特性
- 🤖 交互式聊天界面,支持人工智能故障排除
- 🔍 通过以下方式进行只读系统诊断 Linux MCP服务器
- 🎨 具有颜色编码输出的丰富控制台UI
- ⚙️ 基于环境的配置
- 🐳 开发容器支持,便于设置
先决条件
- Python 3.10+
- 奥拉玛 在本地运行(默认值:http://localhost:11434)
- linux mcp服务器 安装
安装
开发容器快速入门
- 在VS Code中打开项目
- 出现提示时重新打开容器
- 等待自动设置完成
手动安装
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
pip install linux-mcp-server配置
通过环境变量进行配置:
| 变量 | 默认值 | 描述 |
|---|---|---|
LINUX_MCP_SERVER | .venv/bin/linux-mcp-server | MCP服务器可执行文件的路径 |
LLM_PROVIDER | ollama | LLM后端(ollama 或 googlegenai) |
LLM_MODEL | llama3.2:latest | 所选后端的型号名称 |
LLM_BASE_URL | http://localhost:11434 | Ollama服务器URL(用于 LLM_PROVIDER=ollama) |
REQUEST_TIMEOUT | 90 | 请求超时(秒) |
提供商示例
启动代理之前,请使用以下配置之一。
Ollama(当地)
export LLM_PROVIDER=ollama
export LLM_MODEL=llama3.2:latest
export LLM_BASE_URL=http://localhost:11434谷歌GenAI
export LLM_PROVIDER=googlegenai
export LLM_MODEL=gemini-2.0-flash
export GOOGLE_API_KEY=your_api_key_here用法
# As a module
python -m linux_mcp_agent
# Or directly
python linux_mcp_agent示例会话
You: What is the free disk space?
Agent: [Analyzes system and provides disk usage information]
You: Check if nginx is running
Agent: [Queries service status and reports findings]
You: exit
Goodbye!发展
制定目标
make install # Install dependencies
make format # Format code with black
make lint # Run flake8 and mypy
make test # Run pytest
make all # Run format, lint, and test
make clean # Remove cache files项目结构
linux_mcp_agent/
├── __init__.py # Package initialization
├── __main__.py # Entry point
├── agent.py # Main agent logic
└── config.py # Configuration management
tests/
├── __init__.py
└── test_config.py # Configuration tests建筑
代理人使用:
- 骆驼索引:LLM驱动的应用程序框架
- MCP(模型上下文协议):工具访问的标准协议
- 奥拉玛:本地LLM推理
- 富有的:终端UI格式
代理以只读模式运行,防止系统修改。
许可证
看 许可证 文件以获取详细信息。
