终端MCP代理
一个基于Anthropic模型上下文协议(MCP)的生产就绪、完全自主的AI终端代理。配备42多种高级工具、9种监控资源、多步骤规划,并使用Ollama完成离线操作。
主要特点
- 100%离线 -使用Ollama本地运行,零外部API调用
- 42+高级工具 -终端、文件操作、代码分析、调试、git、监控
- 9监控资源 -实时系统指标和项目分析
- 智能代理 -多步规划、自校正、工具链
- 冠军UI -具有会话持久性的漂亮Streamlit界面
- 完全隐私 -你的代码永远不会离开你的机器
快速入门(3个步骤)
1.安装Ollama并拉动模型
# Install Ollama from https://ollama.ai/download
# Then pull the model:
ollama pull qwen2.5-coder:7b2.安装依赖项
# Install Python packages
pip install streamlit anthropic-mcp psutil --break-system-packages
# Optional: Install code analysis tools
pip install pylint flake8 mypy bandit --break-system-packages3.启动应用程序
# Navigate to client directory
cd c
# Start Streamlit UI
streamlit run app.py\*\*应用程序打开时间 http://localhost:8501\*\*
______________________________________________________________________
📖 用法示例
示例1:代码质量分析
You: analyze the code quality of app.py
Agent: [Runs pylint, flake8, mypy]
Agent: Found 12 style issues, 3 potential bugs, 1 security concern. Overall score: 7.5/10示例2:多文件调试
You: find all functions without error handling
Agent: [Scans entire project]
Agent: Found 8 functions across 4 files without try-except blocks示例3:AI代码审查
You: review src/main.py for security issues
Agent: Overall Score: 85/100
• 2 HIGH: SQL injection risks
• 5 MEDIUM: Long functions______________________________________________________________________
项目结构
terminal-mcp-agent/
├── c/ # Client
│ ├── o.py # Streamlit UI START HERE
│ ├── run.py # CLI interface
│ ├── client.py # MCP client
│ ├── agent.py # Intelligent agent
│ └── config.py # Configuration
├── s/ # Server
│ ├── server.py # MCP server
│ ├── tools.py # All 42 tools
│ └── resources.py # All 9 resources
└── README.md # This file______________________________________________________________________
完整功能
全部42个工具
航站楼(7): run_command、read_file、write_file、list_directory、search_files、沙盒执行
代码分析(6): pylint/flake8/mypy集成、安全扫描、项目结构、依赖关系图
调试(5): 错误跟踪、git平分线、内存泄漏检测、进程检查
测试(3): 单元测试生成、覆盖率报告、测试间隙检测
生产(6): 撤消/重做、备份、缓存、执行跟踪、错误日志
人工智能驱动(3): 代码审查、自动文档、语义搜索
Git(3): 状态、差异、提交
系统(9): 信息、进程、监控、docker、网络
全部9个资源
- project://complexity
- project://dependencies
- project://test-coverage
- monitor://cpu
- monitor://memory
- monitor://disk
- monitor://file-changes
- metrics://tool-performance
- cache://stats
______________________________________________________________________
故障排除
服务器无法连接
ollama list # Check Ollama is running
ollama pull qwen2.5-coder:7b # Verify model工具不工作
pip install pylint flake8 mypy bandit psutil --break-system-packages反应缓慢
ollama pull qwen2.5-coder:3b # Use smaller model
# Update config.py: OLLAMA_MODEL = "qwen2.5-coder:3b"______________________________________________________________________
为什么不托管?
无法部署到云端,因为:
- Ollama需要本地GPU/CPU
- 设计隐私 -专为本地运营而建
- 文件系统访问 必需的
- 资源密集型
演示解决方法: 使用ngrok进行临时共享
______________________________________________________________________
系统要求
最低要求: 4核,8GB RAM,10GB磁盘\ 推荐: 8+核,16GB RAM,20GB SSD
演出
- 简单命令:\<1s
- 代码分析:2-5s
- 多文件调试:10-30s
- 人工智能评论:15-45s
______________________________________________________________________
配置
编辑 c/config.py:
OLLAMA_MODEL = "qwen2.5-coder:7b"
OLLAMA_TIMEOUT_SECONDS = 600
MAX_SUBTASKS = 10
MAX_RETRIES = 3
AGENT_DEBUG_MODE = True______________________________________________________________________
UI功能
- 实时连接状态和正常运行时间
- 实时统计仪表板
- 会话管理(SQLite)
- 工具/资源浏览器
- 克劳德风格的聊天界面
- 导出对话
- 性能指标
______________________________________________________________________
许可证
MIT许可证-免费使用、修改、分发
______________________________________________________________________
致谢
- Anthropic -模型上下文协议
- 奥拉玛 -本地LLM推理
- 溪流 -UI框架
