使用说明
🚀 MCPilot
由Google Gemini提供支持的人工智能助手,实际上可以 做事 -不只是谈论他们。
MCPilot使用模型上下文协议(MCP)与真实工具进行交互:浏览网页、管理文件、运行git命令和自动化浏览器任务——所有这些都是通过自然语言完成的。
✨ 特性
- 🤖 AI驱动:由谷歌Gemini 2.0 Flash提供技术支持
- 🌐 浏览器自动化:浏览网站、截图、填写表格(剧作家)
- 🔍 网页搜索:在互联网上搜索信息(DuckDuckGo)
- 📁 文件操作:读取、写入、创建和管理文件(文件系统)
- 🔧 Git集成:检查状态、创建分支、审核提交(Git)
- 💬 记忆:在交互中保持对话上下文
- 🎨 现代用户界面:使用Gradio构建的干净web界面
🎯 真实世界用例
调试工作流:
"Review my last commit, find the issue, search for solutions, create a fix branch"
研究和文件:
"Search for 'Python async best practices', create a file with the top 5 patterns, then show git status"
代码审查:
"Check my git status, review all changed Python files, and create a summary of modifications"
Web自动化:
"Go to https://example.com, take a screenshot, then search the web for similar sites"
🛠️ 技术栈
- LLM:谷歌双子座2.0 Flash(通过LangChain)
- MCP框架:mcp使用
- 用户界面度: 度
- MCP服务器:
- 剧作家(浏览器自动化)
- DuckDuckGo搜索(网络搜索)
- 文件系统(文件操作)
- Git(版本控制)
📋 先决条件
- Python 3.11+
- 紫外线 (推荐)或pip
- Node.js和npx(用于MCP服务器)
- Google Gemini API密钥
🚀 快速开始
-
克隆存储库
git clone <your-repo-url> cd mcpproj1 -
安装依赖项
uv sync # or pip install -r requirements.txt -
设置环境变量 创建一个
.env文件:GEMINI_API_KEY=your_gemini_api_key_here -
配置MCP服务器 编辑
browser_mcp.json如果需要,可以自定义MCP服务器路径。 -
运行应用程序
uv run python app.py # or python app.py -
访问用户界面 打开浏览器
http://localhost:7860
💡 用法示例
基本命令
"What can you do?"-查看可用功能"servers"-列出已连接的MCP服务器"clear"-重置对话历史记录
文件操作
"Create a file called demo.py with a hello world function"
"List all Python files in the current directory"
"Read app.py and summarize what it does"
Git操作
"Check git status"
"Create a new branch called feature-branch"
"Show me the last 3 commits"
网页搜索
"Search for latest Python 3.13 features"
"Find information about MCP protocol"
浏览器自动化
"Go to https://www.python.org and tell me the latest Python version"
"Navigate to https://github.com/trending and take a screenshot"
组合工作流
"Search for 'best React patterns 2024', create a markdown file with the top 5, then show git status"
"Review my last commit, identify issues, search for solutions, create a fix branch"
🔧 配置
MCP服务器
编辑 browser_mcp.json 添加或修改MCP服务器:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
},
"duckduckgo-search": {
"command": "npx",
"args": ["-y", "duckduckgo-mcp-server"]
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"]
},
"git": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-git", "--repository", "/path/to/repo"]
}
}
}
模型配置
编辑 app.py 要更改Gemini模型:
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash", google_api_key=gemini_api_key)
🐛 故障排除
连接问题:
- 如果您看到“连接已关闭”错误,请单击“🔄 “重新连接”按钮
- 检查所有MCP服务器是否通过npx正确安装
- 验证您的
.env文件具有正确的GEMINI_API_KEY
MCP服务器未连接:
- 确保已安装Node.js和npx
- 检查中的路径
browser_mcp.json是正确的 - 启动后等待几秒钟,以便服务器初始化
空白页:
- 硬刷新浏览器(Cmd+Shift+R或Ctrl+Shift+R)
- 检查终端是否存在初始化错误
- 确保端口7860尚未使用
📝 许可证
这个项目是开源的,可以在MIT许可证下使用。
🤝 贡献
欢迎投稿!请随意:
- bug或功能请求的未决问题
- 提交拉取请求
- 分享您自己的MCP服务器集成
🙏 致谢
内置❤️ 使用MCP、Gemini和Python