安装-x
一个全面的MCP(模型上下文协议)服务器,可跨多种编程语言(包括Python、JavaScript、Rust、C和C++)自动安装库。此服务器提供智能库检测和安装功能,支持CUDA、PyTorch和专用ML库等复杂依赖关系。
特性
- 多语言支持:Python、JavaScript/Node.js、Rust、C和C++
- 智能检测:自动检测可用的包管理器和库
- CUDA集成:PyTorch和ML库的智能CUDA版本检测
- 图书馆全面覆盖:支持所有语言的流行库
- 缓存管理:高效的缓存系统,避免冗余安装
- MCP服务器:AI助手的完整模型上下文协议集成
安装
先决条件
- Python 3.8或更高版本
- Node.js和npm(用于JavaScript包)
- 货物(适用于防锈包装)
- CUDA(可选,适用于ML库)
设置
- 克隆存储库:
git clone https://github.com/DuinoDu/install-x
cd install-x- 使用rye安装依赖项:
rye sync- 激活虚拟环境:
source .venv/bin/activate用法
作为MCP服务器
使用MCP检查器
npx @wong2/mcp-cli python3 src/install_x/mcp_server.py使用克劳德桌面
添加到您的Claude Desktop配置中:
{
"mcpServers": {
"install-x": {
"command": "python3",
"args": ["/path/to/install-x/src/install_x/mcp_server.py"]
}
}
}可用工具
1. is_supported(library_name)
检查是否支持安装库。
参数:
library_name(str):要检查的库的名称
退货:
library_name:规范化的库名称is_supported:布尔值,指示库是否受支持
例子:
result = is_supported("numpy")
# Returns: {"library_name": "numpy", "is_supported": true}2. install(library_name)
在当前目录中安装库。
参数:
library_name(str):要安装的库的名称
退货:
success:布尔值表示安装成功message:人类可读的状态消息details:每种语言的详细安装结果
例子:
result = install("torch")
# Returns detailed installation results支持的库
python
- ML/AI:火炬、明考斯基发动机、spconv、finegrasp_graspnet1b、graspnetAPI
- 将军:numpy、pandas、matplotlib、requests、flask、django
- 数据科学:scikit-learn、tensorflow、opencv-python、枕头
JavaScript/Node.js
- 框架:express、react、vue、angular、next.js
- 公用事业:lodash、axios、moment、白垩
- 发展:打字、webpack、jest、eslint、更漂亮
锈
- 网络:东京、axum、火箭、reqwest
- 命令行界面:不管怎样,这个错误
- 数据库:柴油,sqlx
- 序列化:serde
C
- 系统:ssl、加密、curl、zlib、sqlite3
- 图形:png、jpeg、opengl
- 可扩展置标语言:libxml2、libxslt
C
- 推进:提升所有开发
- 计算机视觉:opencv-dev
- 数学:特征3开发
- 毫升:tensorflow开发
- 三维:pcl-dev
安装脚本
该项目包括用于复杂库的专用安装脚本:
可用脚本
torch.sh:PyTorch支持CUDA和版本检测MinkowskiEngine.sh:用于稀疏张量运算的NVIDIA Minkowski引擎spconv.sh:用于3D数据的稀疏卷积库finegrasp_graspnet1b.sh:掌握检测模型graspnetAPI.sh:GraspNet API安装RoboTwin.sh:机器人模拟工具
脚本功能
- CUDA自动检测:检测CUDA版本并选择适当的PyTorch版本
- 缓存管理:使用本地缓存加速重复安装
- 依赖性解析:处理复杂的依赖链
- 错误处理:提供有用的错误消息和故障排除指南
测试
运行综合测试套件:
python -m pytest tests/或运行特定测试:
# Test library support detection
python -m pytest tests/test_mcp_server.py::TestLibraryInstaller::test_is_supported_known_python_library
# Test numpy installation (as requested in PRD)
python -m pytest tests/test_mcp_server.py::TestLibraryInstaller::test_numpy_specific_installation
# Run all tests with verbose output
python -m pytest tests/ -v发展
项目结构
install-x/
├── src/install_x/
│ ├── __init__.py
│ ├── mcp_server.py # Main MCP server implementation
│ └── install/ # Installation scripts
│ ├── base.sh # Common utilities
│ ├── torch.sh # PyTorch installation
│ ├── MinkowskiEngine.sh # NVIDIA Minkowski Engine
│ ├── spconv.sh # Sparse convolution
│ ├── _template.sh # Template for new scripts
│ └── *.patch # Patches for specific libraries
├── tests/
│ └── test_mcp_server.py # Comprehensive test suite
├── pyproject.toml # Project configuration
└── requirements.lock # Locked dependencies添加新库
- 对于简单的库:添加到相应的语言类别
LibraryInstaller.SUPPORTED_LANGUAGES - 对于复杂的库:在中创建新的安装脚本
src/install_x/install/ - 对于补丁:创建
.patch安装脚本旁边的文件
环境变量
INSTALL_X_CACHE:自定义缓存目录(默认:~/.cache/install-x)FORCE_CUDA_VERSION特定的CUDA版本(例如“cu121”、“cu124”)FORCE_INSTALL_TORCH:强制重新安装PyTorch,即使已经安装
例子
安装支持CUDA的PyTorch
# The server will automatically detect CUDA version
python3 src/install_x/mcp_server.py
# Then call: install("torch")安装多个库
# Check support for various libraries
python3 -c "
from install_x.mcp_server import is_supported
libraries = ['numpy', 'react', 'tokio', 'opencv-dev']
for lib in libraries:
print(f'{lib}: {is_supported(lib)}')
"与AI助手集成
当用作MCP服务器时,AI助手可以:
- 安装前查询库可用性
- 自动安装所需的依赖项
- 处理复杂的安装场景(CUDA、GPU支持等)
- 提供安装反馈和故障排除
故障排除
常见问题
- CUDA检测问题
- 确保CUDA安装正确: nvcc --version - 集 FORCE_CUDA_VERSION 如果自动检测失败
- 权限错误
- 以适当的权限运行以进行系统范围的安装 - 尽可能使用虚拟环境
- 网络问题
- 检查包下载的互联网连接 - 如果位于公司防火墙之后,请配置代理设置
- 缓存问题
- 清除缓存: rm -rf ~/.cache/install-x - 如果需要,重置虚拟环境
获取帮助
- 查看测试套件中的使用示例
- 查看安装脚本以了解特定的库要求
- 检查详细安装结果中的错误消息
许可证
本项目按原样提供,用于教育和发展目的。安装的各个库可能有自己的许可证。
