具有20种有用服务器配置的增强型MCP服务器管理器
一个全面的Python工具包,用于管理多个MCP(模型上下文协议)服务器,具有适当的资源管理、错误处理和20个不需要API密钥的预先配置的有用服务器。
🚀 快速开始
安装
# Install Python dependencies
pip install -r requirements.txt
# Check prerequisites and list available servers
python install_servers.py --check
python install_servers.py --list
# Install a basic set of servers
python install_servers.py --example basic_setup配置的基本用法
import asyncio
from mcp_config_loader import MCPConfigLoader
# Load configuration and create manager
loader = MCPConfigLoader()
manager = loader.create_manager_from_example("basic_setup")
# Use context manager for automatic cleanup
async with manager.managed_connection():
tools = await manager.tools()
print(f"Found {len(tools)} tools from {len(manager)} servers")
# Execute a tool
result = await manager.execute_tool("tool_name", **args)📦 20个预先配置的MCP服务器(不需要API密钥)
文件和系统管理
- 文件系统:文件操作、目录列表、读/写文件
- 版本控制系统:Git存储库操作、状态、日志、差异、提交
- 外壳:安全shell命令执行
- 系统监视器:CPU、内存、磁盘使用情况监控
数据处理
- SQLite:SQLite数据库操作和查询
- csv处理器:CSV文件处理和分析
- json处理器:JSON验证和转换
- yaml处理器:YAML文件处理
- 文本处理器:文本搜索、替换、分析
Web和网络
- 获取:HTTP请求和web内容获取
- 操纵者:网页抓取和浏览器自动化
- 网络工具:Ping、跟踪路由、端口扫描
开发工具
- 码头工人:集装箱管理和运营
- Kubernetes:K8s集群管理
- 对数分析器:日志文件分析和解析
- markdown处理器:Markdown处理和转换
公用事业
- 时间:时间操作和时区转换
- 记忆:持久内存存储
- 后格雷斯:PostgreSQL数据库操作(本地)
- 勇敢探索:网络搜索(可用免费层)
🎯 使用示例
预定义设置
from mcp_config_loader import MCPConfigLoader
loader = MCPConfigLoader()
# Basic development setup
manager = loader.create_manager_from_example("basic_setup")
# Data analysis setup
manager = loader.create_manager_from_example("data_analysis_setup")
# Web automation setup
manager = loader.create_manager_from_example("web_automation_setup")
# DevOps setup
manager = loader.create_manager_from_example("devops_setup")自定义服务器选择
# Select specific servers
manager = loader.create_custom_manager([
"filesystem", "git", "sqlite", "time"
])
# Select by category
manager = loader.create_manager_from_category("data_processing")🛠 安装选项
使用安装程序脚本
# Install servers for a specific use case
python install_servers.py --example development_setup
# Install servers by category
python install_servers.py --category data_processing
# Install specific servers
python install_servers.py --servers filesystem git sqlite
# Install all Node.js servers
python install_servers.py --all-node
# Install all Python servers
python install_servers.py --all-python手动安装
# Node.js-based servers
npm install -g @modelcontextprotocol/server-filesystem
npm install -g @modelcontextprotocol/server-git
npm install -g @modelcontextprotocol/server-sqlite
# Python-based servers (examples - actual packages may vary)
pip install mcp-server-shell
pip install mcp-server-docker
pip install mcp-server-json📋 原始代码的关键改进
1. 修复关键Bug
- ✅ 修复了中的词典语法错误
tools()方法 - ✅ 添加了适当的资源管理和清理
- ✅ 全面的错误处理
2. 增强功能
- 🔧
get_tool_by_name():查找特定工具 - 🔧
execute_tool():直接执行工具 - 🔧 用于自动清理的上下文管理器
- 🔧 通过服务器跟踪增强工具信息
3. 配置管理
- 📝 基于JSON的服务器配置
- 📝 预定义用法示例
- 📝 基于类别的组织
- 📝 安装自动化
4. 开发者体验
- 📚 全面的文件
- 📚 全程键入提示
- 📚 日志集成
- 📚 示例脚本和测试
🏗 项目结构
/workspace/
├── mcp_server_manager.py # Enhanced main class
├── mcp_config_loader.py # Configuration management
├── mcp_servers_config.json # 20 server configurations
├── install_servers.py # Installation helper
├── example_usage.py # Usage examples
├── test_mcp_manager.py # Basic tests
├── test_with_example_server.py # Integration tests
├── example_mcp_server.py # Example server for testing
├── requirements.txt # Python dependencies
├── README.md # This file
└── FIXES_AND_ENHANCEMENTS.md # Technical details🔒 安全考虑
- 外壳:可以执行任意命令-请谨慎使用
- 码头工人:需要Docker守护进程访问权限
- Kubernetes:需要kubectl配置
- 文件系统:可以读/写文件-适当限制目录
- 网络工具:可以执行网络操作
🧪 测试
# Test the enhanced manager
python test_mcp_manager.py
# Test with example server
python test_with_example_server.py
# Run usage examples
python example_usage.py📖 配置文件
这 mcp_servers_config.json 文件包含:
- 20种有用的MCP服务器配置
- 每种服务器类型的安装命令
- 预定义用法示例
- 安全注意事项
- 服务器分类
🤝 贡献
- 向添加新的服务器配置
mcp_servers_config.json - 根据需要更新安装命令
- 添加新功能的测试
- 更新文档
📄 许可证
该项目通过全面的改进和配置增强了原始的MCP服务器管理器,以供实际使用。
