DGX Spark MCP服务器
  ](https://nodejs.org/)
通过模型上下文协议对NVIDIA DGX系统进行硬件感知Spark优化
______________________________________________________________________
概述
DGX Spark MCP服务器是 模型上下文协议 服务器,为Claude提供有关NVIDIA DGX硬件和智能Apache Spark优化功能的持久上下文。Claude不会重复描述您的GPU配置,而是自动知道您的硬件规格,并可以为您的工作负载生成最佳的Spark配置。
问题
与Claude合作进行Spark优化时:
- ❌ 您必须反复描述DGX硬件配置
- ❌ Claude无法检查实时GPU可用性
- ❌ 生成的Spark配置可能不适合您的特定硬件
- ❌ 无法访问DGX特定的最佳实践和调优指南
解决方案
MCP服务器为Claude提供:
- ✅ 持久硬件上下文 -DGX规格的自动检测和缓存
- ✅ 实时GPU监控 -实时可用性和利用率数据,通过
nvidia-smi - ✅ 智能火花优化 -基于工作负载分析生成最佳配置
- ✅ 文档访问 -DGX Spark最佳实践的可搜索知识库
- ✅ 资源量估算 -执行前预测工作要求
特性
MCP资源
Claude可以随时读取的静态上下文:
| 资源 | 描述 |
|---|---|
dgx://hardware/specs | 完整的DGX硬件规格(GPU、内存、CPU) |
dgx://hardware/topology | GPU互连拓扑和NVLink配置 |
dgx://system/capabilities | 系统功能和支持的功能 |
dgx://docs/spark/{topic} | DGX Spark文档和最佳实践 |
MCP工具
Claude可以调用的动态操作:
| 工具 | 说明 |
|---|---|
check_gpu_availability | 查询当前GPU利用率和可用性 |
get_optimal_spark_config | 生成针对工作负载和硬件进行优化的Spark配置 |
search_documentation | 搜索DGX Spark文档 |
estimate_resources | 估算工作负载的资源需求 |
get_system_health | 检查系统运行状况和状态 |
validate_spark_config | 根据最佳实践验证Spark配置 |
安装
先决条件
- Node.js 18.0.0或更高
- NVIDIA GPU驱动程序 和
nvidia-smi在PATH中 - 操作系统:Linux(在Ubuntu 22.04上测试)
- 硬件:NVIDIA DGX或兼容GPU系统
选项1:从npm安装(推荐)
npm install -g dgx-spark-mcp选项2:从源代码安装
# Clone the repository
git clone https://github.com/raibid-labs/dgx-spark-mcp.git
cd dgx-spark-mcp
# Install dependencies
npm install
# Build the project
npm run build
# Optionally link globally
npm link选项3:使用npx运行
npx dgx-spark-mcp配置
克劳德桌面
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"dgx-spark": {
"command": "dgx-spark-mcp"
}
}
}配置文件位置:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
克劳德代码(CLI)
添加到MCP设置配置中:
{
"mcpServers": {
"dgx-spark": {
"command": "dgx-spark-mcp"
}
}
}高级配置
创建一个 config/local.json 用于自定义服务器行为的文件:
{
"mcp": {
"serverName": "dgx-spark-mcp",
"serverVersion": "0.1.0"
},
"logging": {
"level": "info",
"enableConsole": true,
"enableFile": true
},
"hardware": {
"cacheDuration": 3600000,
"enableGPUMonitoring": true
},
"docs": {
"indexPath": "docs/index.json",
"autoRebuild": true
}
}看 docs/configuration.md 对于所有配置选项。
用法
配置后,Claude将自动访问您的DGX硬件上下文。你可以问这样的问题:
硬件查询
"What GPUs do I have available?"
"Show me the current GPU utilization"
"What's the NVLink topology of my system?"Spark优化
"Generate optimal Spark config for a 1TB ETL job"
"How should I configure executors for ML training on 8 A100 GPUs?"
"What's the best memory configuration for my hardware?"文档搜索
"Search documentation for GPU memory tuning"
"What are the best practices for shuffle operations on DGX?"
"Show me examples of Spark Rapids configuration"资源规划
"Estimate resources needed for processing 5TB of Parquet files"
"Can I run 4 concurrent jobs with my current hardware?"
"What's the optimal partition size for my dataset?"建筑
┌─────────────────┐
│ Claude Desktop │
│ or CLI │
└────────┬────────┘
│ MCP Protocol (stdio)
▼
┌─────────────────────────────────────┐
│ DGX Spark MCP Server │
├─────────────────────────────────────┤
│ ┌──────────┐ ┌────────────────┐ │
│ │Resources │ │ Tools │ │
│ │ Layer │ │ Layer │ │
│ └────┬─────┘ └────────┬───────┘ │
│ │ │ │
│ ┌────▼─────────────────▼────────┐ │
│ │ Intelligence Engine │ │
│ ├────────────────────────────────┤ │
│ │ • Workload Analyzer │ │
│ │ • Config Generator │ │
│ │ • Resource Estimator │ │
│ │ • Best Practices Validator │ │
│ └────────────┬───────────────────┘ │
│ │ │
│ ┌────────────▼───────────────────┐ │
│ │ Hardware Detection Layer │ │
│ ├────────────────────────────────┤ │
│ │ • nvidia-smi Integration │ │
│ │ • /proc filesystem parsing │ │
│ │ • Topology detection │ │
│ └────────────┬───────────────────┘ │
└───────────────┼─────────────────────┘
│
┌──────▼───────┐
│ DGX Hardware │
└──────────────┘有关详细的体系结构信息,请参见 docs/architecture/overview.md.
发展
快速开始
# Clone and install
git clone https://github.com/raibid-labs/dgx-spark-mcp.git
cd dgx-spark-mcp
npm install
# Run tests
npm test
# Build
npm run build
# Run in development mode with hot reload
npm run dev使用Justfile
该项目包括一个全面的 justfile 对于开发任务:
# Show all available commands
just
# Development workflow
just build # Build TypeScript
just test # Run tests
just test-coverage # Run tests with coverage
just lint # Run linter
just format # Format code
# Quality checks
just check # Run all quality checks (lint, format-check, typecheck)
just pre-commit # Full pre-commit validation
just pre-push # Full pre-push validation
# Docker
just docker-build # Build Docker image
just docker-run-gpu # Run with GPU support
# Documentation
just docs-build # Build documentation index
just docs-search "query" # Search documentation看 JUSTFILE-Referance.md 对于所有可用命令。
项目结构
dgx-spark-mcp/
├── src/
│ ├── server.ts # MCP server implementation
│ ├── hardware/ # Hardware detection
│ ├── analyzers/ # Workload analysis
│ ├── optimizers/ # Spark optimization
│ ├── estimators/ # Resource estimation
│ ├── validators/ # Config validation
│ ├── resources/ # MCP resources
│ ├── tools/ # MCP tools
│ └── docs/ # Documentation system
├── tests/
│ ├── integration/ # Integration tests
│ └── benchmarks/ # Performance tests
├── docs/ # Documentation
├── config/ # Configuration files
└── scripts/ # Utility scripts测试
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run with coverage
npm run test:coverage
# Run integration tests
npm run test:integration
# Run with mocked hardware (for development without GPU)
MOCK_HARDWARE=true npm test代码质量
# Lint TypeScript files
npm run lint
# Auto-fix linting issues
npm run lint:fix
# Format code with Prettier
npm run format
# Check formatting
npm run format:check
# Type checking
npm run typecheck文档
综合文档可在 docs/ 目录:
贡献
我们欢迎捐款!该项目旨在最终为 dgx火花剧本 生态系统。
入门指南
- 分叉存储库
- 创建要素分支:
git checkout -b feature/your-feature - 进行更改
- 运行测试:
npm test - 运行质量检查:
just check - 使用常规提交进行提交:
git commit -m 'feat: add your feature' - 推到分支:
git push origin feature/your-feature - 提交拉取请求
看 贡献.md 详细指南。
提交消息格式
此项目使用 约定式提交 用于自动版本控制和更改日志生成:
# Feature (minor version bump)
git commit -m "feat: add GPU topology detection"
# Bug fix (patch version bump)
git commit -m "fix: correct memory calculation"
# Breaking change (major version bump)
git commit -m "feat!: change resource API interface"
# Other types (no version bump)
git commit -m "docs: update README"
git commit -m "chore: update dependencies"
git commit -m "test: add integration tests"看 docs/RELEASING.md 完整的发布流程。
开发工作流程
该项目采用多工作流开发方法:
| 工作流 | 状态 | 描述 |
|---|---|---|
| WS1:MCP服务器基础 | ✅ 完成 | 核心MCP协议实施 |
| WS2:硬件检测 | ✅ 完成 | GPU和系统自检 |
| WS3:MCP资源和工具 | ✅ 完成 | 资源和工具集成 |
| WS4:文档系统 | ✅ 完整 | 带索引的可搜索文档 |
| WS5:DGX Spark Intelligence✅ 完成 | 工作量分析和优化 | |
| WS6:测试与DevOps✅ 完整 | 全面的测试套件和CI/CD |
路线图
- \[\]支持其他GPU架构(H100、Grace Hopper)
- \[\]与NVIDIA Rapids集成,实现GPU加速的Spark
- \[\]历史绩效指标和趋势分析
- \[\]基于作业执行历史的自动调整
- \[\]多节点DGX集群支持
- \[\]容器化Spark的Kubernetes集成
- \[\]与dgx spark剧本集成
故障排除
常见问题
未找到nvidia smi
# Ensure NVIDIA drivers are installed and nvidia-smi is in PATH
which nvidia-smi
nvidia-smi访问GPU信息的权限被拒绝
# Add user to video group (Linux)
sudo usermod -a -G video $USER
# Log out and back in安装后未发现模块错误
# Rebuild the project
npm run clean
npm install
npm run build看 docs/spark/故障排除.md 更多解决方案。
许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
致谢
- 内置于 模型上下文协议SDK
- 灵感来自 NVIDIA DGX Spark播放手册
- 硬件检测由
nvidia-smi和Linux/proc文件系统
支持
- 问题:
- 讨论:
- 文档: docs/
______________________________________________________________________
内置于❤️ DGX和Spark社区
