AI-Assisted Mining Operations Management via Model Context Protocol
Bridge between AI agents (Claude, Copilot) and Braiins OS miner firmware using Model Context Protocol
- Node.js 20.x LTS
- Docker & Docker Compose
- Git
# Clone repository
git clone https://github.com/Ryno-Crypto-Mining-Services/braiins-os-mcp-server
cd braiins-os-mcp-server
# Install dependencies
npm install
# Build TypeScript
npm run build
# Start development environment
npm run devYou should see:
MCP Server listening on STDIO
โ
Ready to receive requests from Claude
braiins-os-mcp-server is a Model Context Protocol (MCP) server that enables Claude and other AI agents to safely interact with Braiins OS ASIC miners.
Monitor miner status:
Claude: "What's the status of miner-123?"
โโ Server queries gRPC API
โโ Returns: status, hashrate, temperature, uptime
Update firmware:
Claude: "Update miners 1,2,3 to firmware v2.0.1"
โโ Server creates background job
โโ Tracks progress: downloaded, flashing, verifying
โโ Returns job ID and progress tracking
Manage fleet:
Claude: "Show fleet aggregated metrics"
โโ Returns: total hashrate, error rate, avg temp
โโ Cached for performance (30s TTL)
See ARCHITECTURE.md for detailed system design
AI Agents (Claude, Copilot)
โ
[MCP Server] โ This project
โ
โโ gRPC Client โ Braiins OS Miners
โโ REST API โ HTTP Clients
โโ Redis โ Caching & Pub/Sub
| Pattern | Transport | Use Case |
|---|---|---|
| Local | STDIO | On-site technician with local miners |
| Dedicated | HTTP+SSE | Each user gets isolated container |
| Shared | HTTP+OAuth | Multiple users, shared fleet |
| Hybrid | Local + Cloud | On-site + cloud monitoring |
See DEVELOPMENT_PLAN.md for implementation roadmap
src/
โโโ index.ts # MCP server entry point
โโโ server.ts # Transport setup (STDIO, HTTP)
โโโ api/ # API layer
โ โโโ grpc/ # Miner communication
โ โโโ rest/ # REST endpoints
โ โโโ handlers/ # Business logic
โโโ mcp/ # MCP protocol
โ โโโ resources.ts # What Claude reads
โ โโโ tools.ts # What Claude can do
โ โโโ prompts.ts # Claude guidance
โโโ cache/ # Redis caching
โโโ models/ # Data models
โโโ utils/ # Helpers
โโโ config/ # Configuration
โโโ types/ # TypeScript types
tests/
โโโ unit/ # Unit tests
โโโ integration/ # Integration tests
โโโ e2e/ # End-to-end tests
docs/
โโโ ARCHITECTURE.md # System design
โโโ API.md # API documentation
โโโ DEPLOYMENT.md # Deployment guide
โโโ TROUBLESHOOTING.md # Common issues
# Style checking
npm run lint # Check violations
npm run lint:fix # Auto-fix style issues
# Type checking
npm run type-check # Verify TypeScript types
# Testing
npm test # Run all tests with coverage
npm test -- --watch # Watch mode (development)
# Formatting
npm run format # Apply Prettier formattingWe use Test-Driven Development (TDD) with three test levels:
โโโโโโโโโโโโโโโโโโโ
โ E2E Tests (2-3) โ Real miner connections, full workflows
โโโโโโโโโโโโโโโโโโโค
โ Integration (8) โ API boundaries, real cache, mock gRPC
โโโโโโโโโโโโโโโโโโโค
โ Unit (25+) โ Pure logic, all dependencies mocked
โโโโโโโโโโโโโโโโโโโ
Coverage target: >85% across all modules
Run tests:
npm test # All tests + coverage
npm run test:unit # Unit tests only
npm run test:integration # Integration tests
npm run test:e2e # End-to-end tests-
AGENTS.md - Universal instruction manual for all AI agents
- Code standards, testing strategy, security policies
- Git workflow, collaboration patterns
-
CLAUDE.md - Claude-specific instructions
- Leveraging 200K context window
- Workflow patterns with other agents
-
ARCHITECTURE.md - System design & patterns
- High-level architecture
- Technology stack rationale
- Design patterns & examples
-
DEVELOPMENT_PLAN.md - 10-week implementation roadmap
- Phase-by-phase breakdown
- Sprint structure with deliverables
- Risk assessment & mitigation
-
MULTIAGENT_PLAN.md - Multi-agent orchestration
- Agent roles & responsibilities
- Communication protocols
- Quality gates & workflows
-
AGENT_REGISTRY.md - Agent capabilities directory
- Architect, Builder, Validator, Scribe, DevOps, Researcher
- Success criteria & example prompts
-
TODO.md - Actionable task list
- Immediate, short-term, medium-term priorities
- Task format with agent assignments
- docs/API.md - REST API documentation
- docs/DEPLOYMENT.md - Production deployment guide
- docs/TROUBLESHOOTING.md - Common issues & solutions
- OAuth 2.0 for user authentication
- JWT tokens with 1-hour expiry
- Refresh tokens (7-day expiry)
- HttpOnly cookies for secure storage
- Role-based access control (RBAC)
- Tenant isolation for multi-tenant deployments
- Fine-grained resource permissions
- AES-256 encryption at rest
- TLS 1.3 for transport
- No hardcoded secrets (use environment variables)
- Comprehensive audit logging
See AGENTS.md #Security Policies for detailed security guidelines
docker-compose up
# Starts: MCP server + Redis + development environment# Build multi-stage image
docker build -t braiins-os-mcp:1.0.0 .
# Run container
docker run -e NODE_ENV=production \
-e OAUTH_CLIENT_ID=xxx \
-e OAUTH_CLIENT_SECRET=yyy \
braiins-os-mcp:1.0.0# Deploy to Kubernetes
kubectl apply -f k8s/deployment.yaml
# Check status
kubectl get pods -l app=braiins-os-mcp
kubectl logs -f deployment/braiins-os-mcpComplete deployment guide: docs/DEPLOYMENT.md
curl http://localhost:3000/health
# Response
{
"status": "healthy",
"uptime": 3600,
"dependencies": {
"redis": "connected",
"grpc": "ready"
}
}# Endpoint
GET http://localhost:9090/metrics
# Key metrics
grpc_connection_duration_ms
cache_hits_total
api_request_duration_ms
error_rate_total
Access Grafana: http://localhost:3001
Available dashboards:
- System Health (uptime, resource usage)
- API Performance (latency, throughput)
- Miner Operations (status, firmware updates)
- Cache Performance (hit rate, eviction)
Q: gRPC connection timeout
A: 1. Check miner is reachable: ping [miner-ip]
2. Verify gRPC port open: telnet [miner-ip] 50051
3. Check network firewall rules
4. Review logs: docker logs [container]
Q: Cache not working
A: 1. Verify Redis running: redis-cli ping
2. Check cache TTL not 0
3. Monitor: MONITOR in redis-cli
4. Clear cache: redis-cli FLUSHALL (caution!)
Q: Authentication failing
A: 1. Verify OAuth credentials in .env
2. Check token expiration: jwt decode [token]
3. Review auth logs for details
4. Ensure HTTPS (required for OAuth)
See docs/TROUBLESHOOTING.md for more issues
- Read AGENTS.md for standards
- Create feature branch:
git checkout -b feature/your-feature - Code with TDD: write tests first
- Commit using conventional commits
- Push to GitHub:
git push origin feature/your-feature - Create PR with description
-
Automated checks (CI/CD)
- ESLint & Prettier formatting
- TypeScript type checking
- Unit & integration tests
-
Manual review
- Architecture compliance (Architect Agent)
- Code quality (Builder Agent)
- Test coverage (Validator Agent)
- Documentation (Scribe Agent)
-
Merge when all checks pass + 2 approvals
See AGENTS.md #Git Operations for detailed workflow
This project is licensed under the MIT License - see LICENSE file for details.
- Check documentation first (AGENTS.md, ARCHITECTURE.md)
- Search issues on GitHub
- Create new issue with clear description
- Contact: [email protected]
๐ DO NOT open public GitHub issue
Email: [email protected] with details
- Model Context Protocol Specification
- Braiins OS+ API Documentation
- gRPC Node.js Documentation
- TypeScript Handbook
- Jest Testing Framework
| Component | Status | Coverage | Notes |
|---|---|---|---|
| gRPC Client | โ Implemented | 92% | Connection pooling, retry logic |
| REST API | โ Implemented | 88% | Full CRUD operations |
| Authentication | โ Implemented | 91% | OAuth 2.0 + JWT |
| Caching | โ Implemented | 89% | Redis with TTL management |
| Firmware Updates | โ Implemented | 85% | Job tracking, rollback |
| Documentation | โ Complete | โ | API docs, deployment guides |
| Monitoring | โ Implemented | โ | Prometheus + Grafana |
| Testing | โ >85% Coverage | โ | Unit, integration, E2E |
- gRPC client & MCP skeleton
- REST API endpoints
- Authentication & authorization
- Caching layer
- Firmware update workflow
- Monitoring & alerting
- Comprehensive documentation
- E2E testing & validation
- Advanced analytics
- Predictive maintenance
- GPU mining support
- Custom pool integration
Built with guidance from:
- Braiins team (API design consultation)
- Anthropic (Model Context Protocol)
- Open-source community (npm ecosystem)
Project: braiins-os-mcp-server
Repository: GitHub
Last Updated: December 2025
Maintained By: Ryno Crypto Mining Services
Get started: npm install && npm run dev ๐