Stacks MCP Server
Enables interaction with the Stacks blockchain through Claude Desktop. Manage wallets, trade tokens on DEXs, stack STX for Bitcoin rewards, and track portfolio—all through natural conversation.
README
Stacks MCP Server
A Model Context Protocol (MCP) server that enables Claude Desktop to interact with the Stacks blockchain. Manage your wallet, trade tokens, stack STX, and track your portfolio—all through natural conversation.
Note: This is an MVP (Minimum Viable Product) release. Some features use mock data and are being actively developed. See Limitations for details.
Features
Wallet Management
- Create new wallets with secure encryption (AES-256-GCM)
- Import existing wallets from mnemonic or private key
- View balances for STX and tokens
- Encrypted keystore with password protection
Market Data & Trading
- Get real-time token prices
- View trending tokens and liquidity pools
- Get DEX swap quotes (Alex, Velar, Bitflow)
- Execute token swaps with slippage protection
- Add/remove liquidity from pools
Stacking (PoX)
- Check current cycle and stacking info
- View your stacking status and rewards
- Stack STX to earn Bitcoin rewards
- Delegate to stacking pools
Portfolio Management
- Comprehensive portfolio summary
- Transaction history
- Portfolio value tracking over time
- P&L calculations
Installation
Prerequisites
- Node.js 18 or higher
- Claude Desktop app (Download)
Quick Start
Option 1: Install from npm (when published)
npm install -g stacksagent-mcp
Option 2: Build from source (recommended for now)
- Clone the repository:
git clone https://github.com/kai-builder/stacksagent-mcp.git
cd stacksagent-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
- Note the absolute path to your
dist/index.jsfile - you'll need this for configuration.- On macOS/Linux: Run
pwdin the project directory, then append/dist/index.js - On Windows: Run
cdin the project directory, then append\dist\index.js
- On macOS/Linux: Run
Configuration
1. Configure Claude Desktop
Add the MCP server to your Claude Desktop configuration file.
Configuration file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Create the file if it doesn't exist, or edit it to add the stacks MCP server.
If installed via npm:
{
"mcpServers": {
"stacks": {
"command": "npx",
"args": ["-y", "stacksagent-mcp"],
"env": {
"STACKS_NETWORK": "mainnet"
}
}
}
}
If built from source:
macOS/Linux:
{
"mcpServers": {
"stacks": {
"command": "node",
"args": ["/absolute/path/to/stacksagent-mcp/dist/index.js"],
"env": {
"STACKS_NETWORK": "mainnet"
}
}
}
}
Windows:
{
"mcpServers": {
"stacks": {
"command": "node",
"args": ["C:\\absolute\\path\\to\\stacksagent-mcp\\dist\\index.js"],
"env": {
"STACKS_NETWORK": "mainnet"
}
}
}
}
Important: Replace /absolute/path/to/stacksagent-mcp with the actual path where you cloned the repository.
Example paths:
- macOS:
/Users/yourname/Projects/stacksagent-mcp/dist/index.js - Linux:
/home/yourname/projects/stacksagent-mcp/dist/index.js - Windows:
C:\\Users\\YourName\\Projects\\stacksagent-mcp\\dist\\index.js
2. Restart Claude Desktop
After editing the configuration file:
- Completely quit Claude Desktop (not just close the window)
- Restart Claude Desktop
- The MCP server should now be available
You can verify it's working by asking Claude: "What Stacks blockchain tools do you have available?"
3. Server Configuration (Optional)
The server creates a config file at ~/.stacks-mcp/config.json on first run. You can customize:
{
"network": "mainnet",
"wallet": {
"keystorePath": "~/.stacks-mcp/wallet.enc",
"autoLockMinutes": 15
},
"rpc": {
"primary": "https://api.hiro.so",
"fallback": "https://api.mainnet.hiro.so"
},
"trading": {
"defaultSlippage": 0.5,
"maxSlippage": 5.0,
"preferredDex": "auto"
},
"limits": {
"maxSingleTxUsd": 1000,
"dailyTxLimitUsd": 5000,
"requireConfirmation": true
},
"protocols": {
"alex": { "enabled": true },
"velar": { "enabled": true },
"bitflow": { "enabled": true }
}
}
Usage
First Time Setup
After installing and configuring the MCP server:
- Restart Claude Desktop completely (quit and reopen)
- Start a new conversation with Claude
- Verify the tools are available by asking:
What Stacks blockchain tools do you have access to? - Create or import a wallet to start using the features
Security First
⚠️ Important: Your wallet and private keys are stored locally on your machine in encrypted format at ~/.stacks-mcp/wallet.enc.
Before creating a wallet:
- Choose a strong password (store it in a password manager)
- You'll receive a 24-word mnemonic phrase - write it down and store it securely offline
- Never share your mnemonic or private key with anyone
- The wallet auto-locks after 15 minutes of inactivity
Example Conversations
Create a New Wallet
You: Create a new Stacks wallet for me with password "MySecurePassword123"
Claude: I'll create a new wallet for you...
[Creates wallet and returns address and mnemonic]
Check Balance
You: What's my STX balance?
Claude: Let me check your balance...
Your wallet holds 1,234.56 STX (~$892 USD) and 3 other tokens.
Get a Swap Quote
You: How much WELSH can I get for 100 STX?
Claude: Let me get a quote...
You can swap 100 STX for approximately 4,521,304 WELSH.
Rate: 1 STX = 45,213 WELSH
Fee: 0.3 STX (0.3%)
Slippage: 0.5%
Best route: STX → WELSH via Alex
Execute a Swap
You: Swap 100 STX for WELSH
Claude: I'll need to unlock your wallet first. You'll receive ~4.52M WELSH for 100 STX.
Should I proceed with this swap?
You: Yes, my password is "MySecurePassword123"
Claude: [Unlocks wallet, executes swap]
✓ Swap complete! Transaction: 0x7f3a...
You received 4,512,893 WELSH.
Check Stacking Info
You: What's the current stacking APY?
Claude: Current Stacking info:
- Cycle: 82
- APY: ~8% (paid in BTC)
- Minimum: 100,000 STX
- Next cycle starts: 2025-02-15
View Portfolio
You: Show me my portfolio
Claude: Portfolio Summary:
Total Value: $15,234.56
Holdings:
- 1,234.56 STX ($892.00)
- 4,512,893 WELSH ($1,200.45)
- 500.00 USDA ($500.00)
Stacking: Not currently stacking
Available Tools
Wallet Tools
wallet_create- Create a new walletwallet_import- Import wallet from mnemonic/private keywallet_unlock- Unlock wallet with passwordwallet_lock- Lock walletwallet_get_address- Get current wallet addresswallet_get_balance- Get STX and token balanceswallet_status- Check if wallet exists and is unlocked
Market & DEX Tools
market_get_price- Get token price in USDmarket_get_tokens- List trending/new tokensmarket_get_pools- Get liquidity pools with APYdex_quote- Get swap quotedex_swap- Execute token swapdex_add_liquidity- Add liquidity to pooldex_remove_liquidity- Remove liquidity from pool
Stacking Tools
stacking_get_info- Get current PoX cycle infostacking_get_status- Check stacking statusstacking_stack- Stack STX for rewardsstacking_delegate- Delegate to stacking pool
Portfolio Tools
portfolio_summary- Get portfolio summaryportfolio_transactions- View transaction historyportfolio_history- Get portfolio value over time
Security
Key Storage
- Private keys are encrypted using scrypt + AES-256-GCM
- Keys never leave your local machine
- Encrypted keystore stored at
~/.stacks-mcp/wallet.enc
Transaction Safety
- All write operations require wallet to be unlocked
- Configurable transaction limits
- Slippage protection on swaps
- Post-conditions ensure transaction safety
Best Practices
- Use a strong password for your wallet
- Backup your mnemonic phrase securely
- Never share your mnemonic or private key
- Lock your wallet when not in use
- Review transaction details before confirming
Development
Project Structure
stacksagent-mcp/
├── src/
│ ├── index.ts # Main MCP server
│ ├── services/ # Core services
│ │ ├── wallet.ts # Wallet management
│ │ ├── stacks-api.ts # Stacks API client
│ │ ├── price.ts # Price data
│ │ ├── dex.ts # DEX operations
│ │ ├── stacking.ts # Stacking/PoX
│ │ └── portfolio.ts # Portfolio tracking
│ ├── tools/ # MCP tool definitions
│ │ ├── wallet-tools.ts
│ │ ├── market-tools.ts
│ │ └── stacking-tools.ts
│ ├── types/ # TypeScript types
│ └── utils/ # Utilities
│ ├── config.ts
│ ├── constants.ts
│ └── encryption.ts
├── package.json
├── tsconfig.json
└── README.md
Build
npm run build
Development Mode
npm run dev
Testing
npm test
Limitations (MVP)
This is an MVP release. Some features are not yet fully implemented:
- DEX Integration: Currently uses mock quotes. Full Alex/Velar/Bitflow integration coming soon.
- Stacking: Core stacking contract calls need implementation.
- Price Data: Limited to major tokens.
- Multi-wallet: Only supports single wallet currently.
- Hardware Wallets: Not yet supported.
Roadmap
Phase 2
- [ ] Full DEX API integration (Alex, Velar, Bitflow)
- [ ] Complete stacking contract implementation
- [ ] Multi-wallet support
- [ ] Enhanced portfolio tracking
- [ ] LP position management
Phase 3
- [ ] Lending/borrowing (Zest, Granite)
- [ ] sBTC operations
- [ ] Hardware wallet support
- [ ] Automated strategies
- [ ] Price alerts
Troubleshooting
Claude Desktop doesn't see the tools
- Check that
claude_desktop_config.jsonis valid JSON - Restart Claude Desktop completely
- Check logs:
~/Library/Logs/Claude/mcp*.log(macOS)
"Wallet is locked" error
You need to unlock your wallet first:
You: Unlock my wallet with password "YourPassword"
Transaction fails
- Check your STX balance is sufficient
- Verify slippage tolerance isn't too low
- Ensure the token pair has liquidity
- Try again after a few minutes
Price data unavailable
Some tokens may not have price data available yet. Major tokens (STX, WELSH, USDA, sBTC) are supported.
Publishing to npm (For Maintainers)
If you want to publish this package to npm:
-
Update
package.jsonwith your details:- Set
authorfield - Update
repositoryfield - Ensure version is correct
- Set
-
Create an npm account at npmjs.com
-
Login to npm:
npm login
- Publish the package:
npm publish
- Users can then install via:
npm install -g stacksagent-mcp
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests (when test infrastructure is ready)
- Submit a pull request
Please ensure your code:
- Follows the existing code style
- Includes appropriate error handling
- Doesn't expose private keys or sensitive data
- Works on macOS, Windows, and Linux
License
MIT License - see LICENSE file for details
Disclaimer
This software is provided "as is" without warranty. Use at your own risk. Always verify transactions before confirming. Never share your private keys or mnemonic phrase.
Support
- GitHub Issues: Report bugs and feature requests on the GitHub repository
- Stacks Documentation: https://docs.stacks.co
- MCP Protocol: https://modelcontextprotocol.io
- Stacks Discord: https://discord.gg/stacks
Acknowledgments
Built with:
- Model Context Protocol by Anthropic
- Stacks.js by Hiro Systems
- Stacks Blockchain
Made with ❤️ for the Stacks community
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.