Dun Protocol MCP Server
Officialby qilinxlabs
README.md
# Dun Protocol MCP Server
A Model Context Protocol (MCP) server for [Dun Protocol](https://dun-dashboard.vercel.app) - enabling AI agents to interact with Solana wallet operations.
Note: Currently this MCP server supports Solana `devnet`. This MCP server only includes tools to generate transaction metadata - no user private keys are required. Raw transaction signing needs to be implemented on the client side (e.g., using wallet adapter).
## š Features
### Wallet Operations
- **Balance Checking**: Real-time SOL and wSOL balance queries
- **SOL Wrapping**: Convert native SOL to wrapped SOL (wSOL)
- **SOL Unwrapping**: Convert wrapped SOL (wSOL) back to native SOL
- **Transaction Preparation**: Server prepares unsigned transactions for client signing
## š ļø Available Tools
| Tool | Description | Returns |
|------|-------------|---------|
| `check_wallet_balance` | Check SOL and wSOL balance | Balance data (read-only) |
| `wrap_sol` | Wrap SOL to wSOL | Base64 unsigned transaction |
| `unwrap_sol` | Unwrap wSOL to SOL | Base64 unsigned transaction |
## š Quick Start
### Prerequisites
- Node.js 18+
- pnpm (or npm/yarn)
### Local Development
```bash
# Clone the repository
git clone <your-repo-url>
cd dun-protocol-mcp-server
# Install dependencies
pnpm install
# Run development server
pnpm dev
```
Server runs on `http://localhost:3000`
### Test with MCP Inspector
The MCP Inspector is a tool to test your MCP server locally before deploying.
```bash
# Install and run MCP Inspector
npx @modelcontextprotocol/inspector
```
**Configuration:**
1. When the inspector opens, configure the connection:
- **Transport**: `SSE` (Server-Sent Events)
- **URL**: `http://localhost:3000/api/mcp`
2. Make sure your dev server is running:
```bash
pnpm dev
```
3. Click "Connect" in the inspector
**Testing Tools:**
Once connected, you can test all available tools:
```javascript
// Example: Check wallet balance
{
"name": "check_wallet_balance",
"arguments": {
"walletAddress": "81NkAdgRGwJfnWaDBnqQQad3iZNtxy8NYgXgCbqHMkWG"
}
}
// Example: Wrap SOL
{
"name": "wrap_sol",
"arguments": {
"walletAddress": "81NkAdgRGwJfnWaDBnqQQad3iZNtxy8NYgXgCbqHMkWG",
"amount": 0.1
}
}
// Example: Unwrap SOL
{
"name": "unwrap_sol",
"arguments": {
"walletAddress": "81NkAdgRGwJfnWaDBnqQQad3iZNtxy8NYgXgCbqHMkWG",
"amount": 0.05
}
}
```
**Expected Responses:**
- **Read operations**: Return data directly (e.g., balance information)
- **Write operations**: Return `{ requiresClientExecution: true, transaction: "base64..." }`
## š¦ Deploy to Vercel
### Quick Deploy
[](https://vercel.com/new/clone?repository-url=https://github.com/YOUR_USERNAME/dun-protocol-mcp-server)
### Manual Deployment
See the complete [Deployment Guide](.kiro/docs/DEPLOYMENT-GUIDE.md) for detailed instructions.
#### Quick Steps:
1. **Push to GitHub**
```bash
git push origin main
```
2. **Deploy on Vercel**
- Go to [vercel.com](https://vercel.com)
- Import your GitHub repository
- Click "Deploy"
3. **Get Your URL**
```
https://your-app.vercel.app/api/mcp
```
4. **Configure AI Client** (see below)
### Environment Variables (Optional)
| Variable | Description | Default |
|----------|-------------|---------|
| `SOLANA_RPC_URL` | Solana RPC endpoint | `https://api.devnet.solana.com` |
## š§ Client Configuration
### Claude Desktop
1. Open Claude Desktop configuration:
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
2. Add the MCP server:
```json
{
"mcpServers": {
"dun-protocol": {
"command": "npx",
"args": [
"mcp-remote",
"https://your-app.vercel.app/api/mcp"
]
}
}
}
```
3. Restart Claude Desktop
### Cursor
1. Open Cursor MCP configuration:
- **macOS/Linux**: `~/.cursor/mcp.json`
- **Windows**: `%USERPROFILE%\.cursor\mcp.json`
2. Add the MCP server:
```json
{
"mcpServers": {
"dun-protocol": {
"command": "npx",
"args": [
"mcp-remote",
"https://your-app.vercel.app/api/mcp"
]
}
}
}
```
3. Restart Cursor
### Other MCP Clients
For other MCP-compatible clients, use the remote MCP connection:
```bash
npx mcp-remote https://your-app.vercel.app/api/mcp
```
## š” Usage Examples
### Check Wallet Balance
```
User: "Check my SOL balance for wallet 81NkAdgRGwJfnWaDBnqQQad3iZNtxy8NYgXgCbqHMkWG"
AI: Uses check_wallet_balance tool
Response: "Your wallet has 2.5000 SOL (native) and 0.1000 wSOL (wrapped)"
```
### Wrap SOL
```
User: "Wrap 0.1 SOL"
AI: Uses wrap_sol tool
Response: "Transaction prepared. Please sign in your wallet."
(Returns base64-encoded transaction for client to sign)
```
### Unwrap SOL
```
User: "Unwrap 0.05 wSOL"
AI: Uses unwrap_sol tool
Response: "Transaction prepared to unwrap 0.05 wSOL. Please sign in your wallet."
(Returns base64-encoded transaction for client to sign)
```
## šļø Architecture
```
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā
ā AI Agent ā āāāāāāāŗ ā MCP Server ā āāāāāāāŗ ā Solana ā
ā (Claude) ā ā (Stateless) ā ā Devnet ā
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā
ā ā
ā ā
ā ā¼
ā Read: Return Data
ā Write: Build Transaction
ā ā
āāāāāāāāāāāāāāāāāāāāāāāāā
Client Signs & Submits
```
### How It Works
1. **Read Operations** (e.g., balance checks)
- Server queries Solana RPC directly
- Returns actual data to AI agent
- No client action needed
2. **Write Operations** (e.g., wrap, unwrap)
- Server builds unsigned transaction with proper instructions
- Returns base64-encoded transaction
- Returns `requiresClientExecution: true` with action metadata
- Client must sign and submit transaction to blockchain
### Transaction Building
The server uses the `wrap-unwrap.ts` service to build transactions:
- `prepareWrapSolTransaction()` - Builds wrap SOL ā wSOL transaction
- `prepareUnwrapSolTransaction()` - Builds unwrap wSOL ā SOL transaction
All functions return base64-encoded unsigned transactions ready for client signing.
## š Security Model
- **No Private Keys**: Server never has access to private keys
- **Client-Side Signing**: All transactions signed by user's wallet
- **Read-Only RPC**: Server only reads blockchain data
- **Stateless**: No database, no sessions, no stored credentials
## š Network Information
- **Network**: Solana Devnet
- **RPC**: `https://api.devnet.solana.com`
## š Documentation
- **[Deployment Guide](.kiro/docs/DEPLOYMENT-GUIDE.md)** - Complete deployment instructions
- **[Tool Reference](.kiro/docs/DUN-MCP-TOOLS.md)** - Complete API documentation
- **[Implementation Status](.kiro/docs/IMPLEMENTATION-STATUS.md)** - What's implemented where
- **[Quick Start](.kiro/docs/QUICK-START.md)** - Development guide
- **[Changelog](.kiro/docs/CHANGELOG.md)** - Version history
## š ļø Development
### Project Structure
```
dun-protocol-mcp-server/
āāā app/
ā āāā api/
ā āāā mcp/
ā āāā route.ts # Main MCP handler
ā āāā services/
ā āāā wrap-unwrap.ts # Transaction building service
āāā .kiro/
ā āāā docs/ # Documentation
ā āāā resources/
ā āāā new_code/ # Latest V3/V5 code examples
ā āāā mcp_code_2/ # Reference implementation
āāā package.json
āāā README.md
```
### Key Services
**`app/api/mcp/services/wrap-unwrap.ts`**
This service handles all transaction building:
```typescript
// Wrap/Unwrap Operations
prepareWrapSolTransaction() // Build wrap SOL ā wSOL transaction
prepareUnwrapSolTransaction() // Build unwrap wSOL ā SOL transaction
```
**Features:**
- Returns base64-encoded unsigned transactions
- Handles token account creation if needed
- Validates balances before unwrapping
### Dependencies
```json
{
"@solana/web3.js": "^1.95.8", // Solana RPC & transaction building
"@solana/spl-token": "^0.4.9", // SPL Token operations
"@vercel/mcp-adapter": "^0.11.1", // MCP protocol adapter
"next": "^16.1.1", // Next.js framework
"zod": "^3.25.71" // Schema validation
}
```
### Build Commands
```bash
# Development
pnpm dev
# Build for production
pnpm build
# Start production server
pnpm start
```
## š¤ Contributing
Contributions are welcome! Please read the documentation in `.kiro/docs/` before contributing.
## š License
MIT
## š Resources
- [Model Context Protocol](https://modelcontextprotocol.io)
- [Solana Documentation](https://docs.solana.com)
- [Vercel Documentation](https://vercel.com/docs)
---
**Built by Qilinxlabs with ā¤ļø for privacy-preserving transactions on Solana**
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues