@0gfoundation/0g-cc
v1.0.2
Published
0G Code to Coin - MCP server for decentralized AI compute and storage on 0G Network
Readme
0G Code to Coin (0g-cc)
Decentralized AI Coding Assistant - MCP server bridging 0G's decentralized compute network for AI inference, fine-tuning, storage, and VIBEZ token marketplace.
Overview
0G Code to Coin enables AI assistants like Claude Code, Cursor, and Windsurf to leverage 0G's decentralized AI infrastructure:
- Decentralized Inference - Route AI requests to 0G's compute network
- Up to 96% Cost Savings - Intelligent routing between 0G and cloud providers
- TEE Verification - Trusted Execution Environment for sensitive workloads
- Decentralized Storage - Store context, RAG data, and model artifacts on 0G Storage
- Fine-tuning - Fine-tune models on 0G's compute network
- VIBEZ Integration - Launch tokens, trade, and earn from your AI apps (coming soon)
Quick Start
New to 0G? Check out the User Guide for a complete walkthrough with natural language examples.
Installation
npm install @0gfoundation/0g-ccAdd to Claude Code
# Minimal setup (free testnet)
claude mcp add 0g-cc npx @0gfoundation/0g-cc
# Full setup (with wallet and cloud fallback)
claude mcp add 0g-cc npx @0gfoundation/0g-cc \
-e ZEROG_NETWORK=mainnet \
-e ZEROG_PRIVATE_KEY=0x_your_private_key \
-e OPENROUTER_API_KEY=sk-or-v1-_your_key \
-e OPENROUTER_MODEL=deepseek/deepseek-chatConfiguration
Create .env with your settings:
# Network (testnet or mainnet)
ZEROG_NETWORK=testnet
# Optional: Cloud fallback (OpenRouter)
# Both are required for cloud fallback to work
OPENROUTER_API_KEY=your-key-here
OPENROUTER_MODEL=deepseek/deepseek-chat
# Optional: 0G Wallet (for paid operations)
ZEROG_PRIVATE_KEY=your-private-key
# Optional: Logging (see Logging section below)
LOG_FILE=/path/to/logfile.log
LOG_LEVEL=infoLogging
By default, logs are written to stderr. For debugging or monitoring, you can configure file logging:
| Variable | Description | Default |
|----------|-------------|---------|
| LOG_FILE | Path to write logs (in addition to stderr) | Not set (stderr only) |
| LOG_LEVEL | Minimum log level: debug, info, warn, error | info |
Example: Enable file logging for debugging
# In your MCP server config or .env
LOG_FILE=/tmp/0g-cc.log
LOG_LEVEL=debugThen monitor logs in real-time:
tail -f /tmp/0g-cc.logClaude Code MCP configuration with logging:
{
"mcpServers": {
"0g-cc": {
"command": "npx",
"args": ["@0gfoundation/0g-cc"],
"env": {
"ZEROG_NETWORK": "mainnet",
"ZEROG_PRIVATE_KEY": "your-key",
"LOG_FILE": "/tmp/0g-cc.log",
"LOG_LEVEL": "info"
}
}
}
}MCP Tools
Compute
| Tool | Status | Description |
|------|--------|-------------|
| compute_inference | ✅ | Run AI inference via 0G or cloud providers |
| compute_list_providers | ✅ | List available inference providers |
| compute_verify_provider | ✅ | Verify provider TEE attestation |
| compute_get_balance | ✅ | Check wallet and ledger balances |
| compute_deposit | ✅ | Deposit funds to compute ledger |
| compute_estimate_cost | ❌ | Estimate cost before running inference |
| compute_set_preferences | ❌ | Set routing preferences |
Storage
| Tool | Status | Description |
|------|--------|-------------|
| storage_info | ⚠️ | Get file info from 0G Storage (mock) |
| storage_upload | ❌ | Upload files to 0G Storage |
| storage_download | ❌ | Download files from 0G Storage |
| storage_list | ❌ | List stored files |
Fine-tuning
| Tool | Status | Description |
|------|--------|-------------|
| finetune_create | ❌ | Start a fine-tuning job |
| finetune_status | ❌ | Check job status |
| finetune_list | ❌ | List fine-tuned models |
VIBEZ Token Launch (Coming v0.6+)
| Tool | Status | Description |
|------|--------|-------------|
| vibez_launch_wizard | 🔮 | Guided token creation flow |
| vibez_launch_quick | 🔮 | Quick launch with parameters |
| vibez_estimate_fees | 🔮 | Estimate trading fees |
| vibez_preview_curve | 🔮 | Visualize bonding curve |
VIBEZ Marketplace (Coming v0.7+)
| Tool | Status | Description |
|------|--------|-------------|
| vibez_get_token | 🔮 | Get token details (price, mcap, health) |
| vibez_trending | 🔮 | List trending tokens |
| vibez_search | 🔮 | Search tokens by name/category |
| vibez_buy | 🔮 | Buy tokens |
| vibez_sell | 🔮 | Sell tokens |
| vibez_quote | 🔮 | Get price quote before trading |
| vibez_portfolio | 🔮 | View all holdings |
| vibez_my_tokens | 🔮 | List tokens you created |
| vibez_earnings | 🔮 | See creator fee earnings |
| vibez_health_alerts | 🔮 | Get alerts for struggling tokens |
| vibez_fund_compute | 🔮 | Add funds to token's compute treasury |
0G Knowledge (Coming v0.8+)
| Tool | Status | Description |
|------|--------|-------------|
| zerog_explain | 🔮 | Explain any 0G concept |
| zerog_docs | 🔮 | Fetch specific documentation |
| zerog_examples | 🔮 | Show code examples |
| zerog_best_practices | 🔮 | Get recommended patterns |
Wallet (Coming v0.9+)
| Tool | Status | Description |
|------|--------|-------------|
| wallet_status | 🔮 | Check current wallet connection |
| wallet_connect | 🔮 | Connect via WalletConnect |
| wallet_balance | 🔮 | Check 0G balance |
| wallet_transactions | 🔮 | View recent transactions |
System
| Tool | Status | Description |
|------|--------|-------------|
| system_ping | ✅ | Health check |
| system_session_info | ❌ | Get detailed session info |
| system_switch_network | ❌ | Switch network |
Legend: ✅ Implemented | ⚠️ Partial | ❌ Planned | 🔮 Future Vision
Intelligent Routing
0G Code to Coin uses an LLM Router inspired by agentic-flow to automatically select the best provider:
User Request
│
▼
┌─────────────┐
│ LLM Router │
└─────────────┘
│
├─── Local? ────────▶ Ollama (free, private)
│ │
├─── Prefer 0G? ───▶ 0G Compute (up to 96% cheaper)
│ │
│ TEE Verified ✓
│ │
└─── Fallback ─────▶ Cloud (OpenRouter)
│
High reliabilityRouting Criteria
- Cost: Prefer cheaper providers
- Latency: Stay within acceptable limits
- Capability: Match required features (code, chat, vision)
- TEE: Use verified compute for sensitive data
- Availability: Automatic fallback if provider down
- Local: Detect and use local Ollama when available
Cost Savings
| Provider | Input $/MTok | Output $/MTok | vs Cloud | |----------|--------------|---------------|----------| | 0G DeepSeek V3 | $0.30 | $0.48 | -90% | | 0G Qwen 7B | $0.05 | $0.10 | -97% | | Claude Sonnet (Cloud) | $3.00 | $15.00 | baseline |
Example: 1M tokens of coding assistance
- Cloud: ~$18.00
- 0G: ~$0.78
- Savings: 96%
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ 0G Code to Coin MCP Server │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Compute │ │ Storage │ │Fine-tune │ │ VIBEZ │ │
│ │ Tools │ │ Tools │ │ Tools │ │ Tools │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Router Service │ │
│ │ (Intelligent provider selection + fallback) │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │0G Serving│ │0G Storage│ │OpenRouter│ │ VIBEZ │ │
│ │ Broker │ │ SDK │ │(Fallback)│ │Contracts │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘Development
Build
npm install
npm run buildRun locally
npm run start:devTest
npm test # Watch mode
npm run test:run # Unit + integration tests
# E2E Tests
npm run test:e2e:mock # Fully mocked (no network)
npm run test:e2e:testnet # Real 0G testnet
npm run test:e2e:mainnet # Real 0G mainnet (requires funded wallet)Resources
- User Guide - Complete guide with natural language examples
- API Contracts - Detailed tool specifications
- 0G Documentation
- MCP Protocol
- agentic-flow - LLM Router inspiration
- VIBEZ Vision - Future product vision
Roadmap
v0.1.0 - MVP ✅ Complete
Foundation: Basic MCP server with 0G compute
- [x] Project structure and MCP server core
- [x] Tool registry with Zod validation
- [x] Session manager with capabilities
- [x] Router service with provider selection
- [x]
compute_inferencetool - [x]
compute_list_providerstool - [x]
system_pingtool - [x] Real 0G SDK integration (
@0glabs/0g-serving-broker) - [x] Cloud fallback (OpenRouter with configurable model)
- [x] E2E test suite (mock/testnet/mainnet modes)
v0.2.0 - Differentiation & Core Value
Strategic priority: Features that differentiate from competitors
Inference Receipts
- [ ] Cryptographic audit trails for compliance
- [ ] Store receipts in 0G Storage (optional)
- [ ] Receipt verification tool
Hybrid Routing
- [ ] Detect local Ollama installation
- [ ] Route intelligently: local → 0G → cloud
- [ ] User preferences for routing priority
Response Caching
- [ ] Cache deterministic responses (temperature=0)
- [ ] Configurable cache duration
- [ ] Cache invalidation controls
Infrastructure
- [ ] Provider health checks (auto-exclude unhealthy)
- [ ] Streaming responses support
- [ ] Better error messages and recovery
v0.3.0 - Enhanced Compute
Complete the compute toolkit
Cost Management
- [ ]
compute_estimate_cost- Estimate before running - [ ]
compute_set_preferences- User routing config - [ ] Cost comparison across providers
Ledger Integration
- [ ]
compute_get_balance- Check 0G balance - [ ]
compute_deposit- Add funds to ledger - [ ] Balance alerts (low balance warning)
TEE Features
- [ ] TEE attestation capture and storage
- [ ] Verification proof generation
- [ ] Compliance reporting
v0.4.0 - Storage Integration
0G decentralized storage for AI workflows
Core Storage
- [ ]
storage_upload- Upload files to 0G - [ ]
storage_download- Download from 0G - [ ]
storage_list- List user's files - [ ]
storage_info- Real SDK integration (replace mock) - [ ]
storage_delete- Remove files
AI Workflow Integration
- [ ] RAG document storage
- [ ] Model artifact storage
- [ ] Context persistence across sessions
v0.5.0 - Fine-tuning & System
Complete the 0G compute suite
Fine-tuning
- [ ]
finetune_create- Start fine-tuning jobs - [ ]
finetune_status- Check job progress - [ ]
finetune_list- List fine-tuned models - [ ]
finetune_deploy- Deploy fine-tuned model
System Tools
- [ ]
system_session_info- Detailed session info - [ ]
system_switch_network- Network switching (testnet/mainnet) - [ ] Usage analytics dashboard
- [ ] Performance metrics
v0.6.0 - VIBEZ Token Launch
Enable vibecoders to launch tokens for their apps
Launch Tools
- [ ]
vibez_launch_wizard- Guided token creation- Step-by-step: name, symbol, curve, description
- Curve visualization
- Fee explanation
- [ ]
vibez_launch_quick- Quick launch for experienced users- Single command with parameters
- Sensible defaults
- [ ]
vibez_estimate_fees- Show expected trading fees - [ ]
vibez_preview_curve- Interactive curve preview
Launch Flow
User: "Launch my app as a token called MYAPP"
│
▼
┌─────────────────────────────────────────┐
│ VIBEZ Launch Wizard │
│ │
│ 1. Name: My App │
│ 2. Symbol: MYAPP │
│ 3. Curve: Quadratic (recommended) │
│ 4. Description: An AI assistant app │
│ │
│ Quadratic curves reward early │
│ supporters 2-3x more │
│ │
│ [Launch] [Preview Curve] [Cancel] │
└─────────────────────────────────────────┘
│
▼
Token MYAPP deployed to VIBEZ marketplace!Educational Tips
- Explain bonding curves during launch
- Show fee breakdown
- Explain health tiers
v0.7.0 - VIBEZ Marketplace
Full marketplace integration: read, trade, earn
Market Data
- [ ]
vibez_get_token- Token details (price, mcap, health, volume) - [ ]
vibez_trending- Trending tokens list - [ ]
vibez_search- Search by name, category, creator - [ ]
vibez_health_check- Check app health status
Trading
- [ ]
vibez_quote- Get price quote before trading - [ ]
vibez_buy- Buy tokens with slippage protection - [ ]
vibez_sell- Sell tokens - [ ]
vibez_portfolio- View all holdings with P&L
Creator Dashboard
- [ ]
vibez_my_tokens- List tokens you created - [ ]
vibez_earnings- See creator fee earnings - [ ]
vibez_health_alerts- Alerts for struggling tokens - [ ]
vibez_fund_compute- Add funds to compute treasury
Example Interactions
User: "How's my MYAPP token doing?"
Claude: "MYAPP Status:
Price: 0.0023 0G ($0.012)
Market Cap: $12,450
Health: HEALTHY (94 days runway)
24h Volume: $2,340
Your Holdings: 50,000 MYAPP ($115)
Creator Earnings: 45.2 0G ($226) lifetime"v0.8.0 - 0G Knowledge & Education
Built-in 0G expertise for vibecoders
Knowledge Tools
- [ ]
zerog_explain- Explain any 0G concept- TEE, DA, Storage, Compute, Serving Broker
- Bonding curves, health tiers, graduation
- [ ]
zerog_docs- Fetch specific documentation - [ ]
zerog_examples- Show code examples - [ ]
zerog_best_practices- Recommended patterns
Proactive Education
- [ ] Contextual tips during operations
- [ ] Explain concepts when relevant
- [ ] Warn about common mistakes
- [ ] Suggest optimizations
Example
User: "What is TEE?"
Claude: "TEE (Trusted Execution Environment) is a secure area
of a processor that guarantees code and data are protected.
In 0G Compute, TEE verification means:
• Your inference runs in an isolated enclave
• Even the provider can't see your data
• Results are cryptographically verified
Use `compute_inference` with `tee: true` for sensitive workloads.
Would you like to see an example?"v0.9.0 - Wallet & Authentication
Multiple auth methods for different use cases
Wallet Tools
- [ ]
wallet_status- Current connection status - [ ]
wallet_balance- Check 0G balance - [ ]
wallet_connect- WalletConnect integration - [ ]
wallet_transactions- Recent transaction history
Auth Methods
- [ ] Private key in env (current)
- [ ] WalletConnect support
- [ ] Hardware wallet support (Ledger)
- [ ] Social login (Privy integration)
Onboarding Flow
- [ ] Guided wallet creation for new users
- [ ] Import existing wallet
- [ ] Security best practices tips
v1.0.0 - Full Integration
Production-ready vibecoder toolkit
Polish
- [ ] Comprehensive error handling
- [ ] Retry logic with backoff
- [ ] Offline mode (queue operations)
- [ ] Multi-language support
Analytics
- [ ] Usage tracking (opt-in)
- [ ] Cost analytics dashboard
- [ ] ROI calculations for creators
Enterprise
- [ ] Team wallet support
- [ ] Role-based permissions
- [ ] Audit logging
- [ ] SLA monitoring
Vision
0G Code to Coin aims to be the command center for vibecoders - enabling anyone to:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ │ │ │ │ │
│ BUILD │ ───▶ │ LAUNCH │ ───▶ │ EARN │
│ │ │ │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
• 0G Compute • Token wizard • Portfolio view
• 0G Storage • VIBEZ deploy • Fee tracking
• BYOK routing • Health setup • Alerts
• Cost savings • Curve selection • TradingSee docs/VISION.md for the complete product vision.
License
MIT License - see LICENSE for details.
Contributing
Contributions welcome! Please read CONTRIBUTING.md for:
- Test-driven development practices
- Test pyramid (unit/integration/E2E)
- Code quality standards
- Documentation requirements
- Pre-commit hooks and CI/CD
