使用说明
🤖 MCP-CLI
A lightweight MCP playground for rapid testing
Chat with AI agents that can read your files — built to bypass firewalls via OpenRouter.
🤷♂️ 我为什么建造这个
我想用 模型上下文协议(MCP) 和Agent AI,但一直遇到两个问题:
- 防火墙 -企业/大学网络阻止API直接连接
- 复杂性 --大多数现有工具太重或难以配置
所以我写了这个轻量级的Python客户端。它把一切都安排好了 开放路由 (绕过块)并允许您运行以下模型 双子座2.0闪光灯 和 DeepSeek R1 直接在您的终端。
✨ 特性
| 特性 | 描述 |
|---|---|
| 🔥 防火墙旁路 | 通过OpenRouter路由——适用于受限网络 |
| 🧠 推理模型 | 以可见的思维链支持DeepSeek R1 |
| 📂 文件访问 | MCP文件系统服务器允许AI读取/写入您的文件 |
| ⚡ 免费等级优先 | 默认为免费型号(Gemini Flash、Phi-3、Llama 3) |
| 🔄 自动回退 | 如果主模型正忙(429),则建议自动备份 |
| 🎨 富终端 | 具有丰富控制台格式的漂亮输出 |
🚀 快速开始
# 1. Clone
git clone https://github.com/Nikhilchapkanade/MCP-CLI.git
cd MCP-CLI
# 2. Install
pip install -r requirements.txt
npm install
# 3. Add your OpenRouter key (.env)
OPENROUTER_API_KEY=sk-or-your-key-goes-here
# 4. Start chatting
python src/main.py
💬 用法示例
You: "Hey, list the files in this directory."
🔧 Tool Call: list_directory
Assistant: "I see main.py and requirements.txt."
You: "Read main.py and rewrite the connection function to be async."
Assistant: "On it." [Writes code]
⚙️ 配置
通过以下方式交换模型 config/settings.json:
{
"llm_profiles": [
{
"name": "Gemini 2.0 Flash (Daily Driver)",
"model_name": "google/gemini-2.0-flash-exp:free"
},
{
"name": "Microsoft Phi-3 (Backup)",
"model_name": "microsoft/phi-3-mini-128k-instruct:free"
}
]
}
📁 项目结构
MCP-CLI/
├── src/
│ ├── main.py # Entry point — menu + chat loop
│ ├── mcp_client.py # MCP session management
│ ├── llm_handler.py # OpenRouter API client
│ └── config_manager.py # Settings loader
├── config/
│ └── settings.json # Model profiles + MCP servers
├── .env # API keys
└── requirements.txt
🛠️ 技术栈
| 组件 | 技术 |
|---|---|
| AI协议 | 模型上下文协议(MCP) |
| LLM网关 | OpenRouter |
| 终端UI | 丰富 |
| 异步运行时 | 异步 |
| 文件服务器 | MCP文件系统 |
🔧 故障排除
| 问题 | 修复 |
|---|---|
Error 401 Unauthorized |
检查 .env --周围没有空格 = |
Gemini is busy |
自由层受到重创。在设置中重试或切换到Phi-3 |
