Provides RPC provider integration for connecting to Base and Base-Sepolia networks through Alchemy's API for blockchain interactions
Manages environment variables for configuration of network connections, contract addresses, and server settings
Integrates with CI/CD for automated testing, including verification of MCP protocol compliance
Enables workflow automation with dedicated endpoints for executing Unlock Protocol functions, supporting the MCP Client Tool node for n8n workflows
Implements input validation for all API calls with Zod schemas, ensuring type safety and proper error handling throughout the codebase
Unlock-MCP
Unlock MCP is an MCP server that provides comprehensive access to Unlock Protocol on Base and Base-Sepolia networks. This server exposes a number of public read and write functions from the Unlock Protocol smart contracts, enabling AI agents to interact with membership, subscription, and access control functionality.
🚀 Features
Complete Function Coverage
- 55 Tools: All public read and write functions from PublicLock contract plus essential Unlock protocol functions
- PublicLock Functions: Complete coverage of membership, pricing, transfers, and access control
- Unlock Protocol Functions: Lock creation, upgrades, and protocol information
- Read Functions: Query membership status, pricing, metadata, configuration, and protocol info
- Write Functions: Purchase keys, manage memberships, configure locks, create locks, and handle upgrades
Two Operating Modes
Mode | Key Location | Gas Payer | Transport | Use Case |
---|---|---|---|---|
stdio | Server .env | Server | stdio | Claude Desktop, MCP clients |
proxy | Browser/Wallet | Client | HTTP/SSE | n8n, web applications |
Enterprise Ready
- ✅ Comprehensive Input Validation with Zod schemas
- ✅ Proper Error Handling with detailed logging
- ✅ Type Safety throughout the codebase
- ✅ n8n Integration with dedicated endpoints
- ✅ Health Monitoring and graceful shutdown
- ✅ Extensive Documentation for all tools
📦 Quick Start
1. Installation
2. Configuration
Edit .env
with your settings:
3. Build
4A. Run stdio Mode (Claude Desktop)
Start the server:
Claude Desktop configuration:
4B. Run proxy Mode (n8n, HTTP APIs)
Start the server:
For Claude Desktop with SSE:
🔧 n8n Integration
The proxy mode is optimized for n8n workflows with:
MCP Client Tool Node
Available Endpoints
GET /tools
- List all available MCP toolsPOST /tools/call
- Execute MCP tools with validationGET /health
- Health check and server statusGET /sse
- Server-Sent Events for real-time connectionGET /
- API documentation
Example n8n Workflow
- Add MCP Client Tool node
- Configure server URL:
http://localhost:3000
- Use tools like
getHasValidKey
,purchase
,grantKeys
, etc.
🛠️ Available Tools
📖 Read Functions (30 tools)
Unlock Protocol Information
chainIdRead
- Get current network chain IDunlockVersion
- Get Unlock protocol versiongovernanceToken
- Get UDT governance token addressgetGlobalTokenSymbol
- Get global token symbolpublicLockLatestVersion
- Get latest lock template version
PublicLock ERC721 & Membership
balanceOf
- Get number of keys ownedownerOf
- Get owner of specific tokentokenURI
- Get metadata URItotalSupply
- Get total keys createdgetHasValidKey
- Check if address has valid keyisValidKey
- Check if specific token is validkeyExpirationTimestampFor
- Get key expiration time
Lock Configuration
keyPrice
- Get current key pricemaxKeysPerAddress
- Get max keys per addressmaxNumberOfKeys
- Get maximum total keysexpirationDuration
- Get key validity durationname
/symbol
- Get lock metadatatokenAddress
- Get payment tokentransferFeeBasisPoints
- Get transfer fee
Pricing & Fees
purchasePriceFor
- Calculate purchase pricegetCancelAndRefundValue
- Get refund amountgetTransferFee
- Calculate transfer fee
Access Control
owner
- Get lock ownerisLockManager
- Check manager statushasRole
- Check role permissions
✍️ Write Functions (27 tools)
Lock Creation & Management
createLock
- Deploy new basic PublicLock contractcreateUpgradeableLock
- Deploy upgradeable lock with custom dataupgradeLock
- Upgrade existing lock to new version
Key Management
purchase
- Buy keys for recipientsgrantKeys
- Issue keys administrativelyextend
- Extend key durationrenewMembershipFor
- Renew membership
Key Transfers
transferFrom
- Transfer key ownershipapprove
- Approve address for transferlendKey
/unlendKey
- Temporary key lendingshareKey
- Share key time with others
Lock Administration
updateKeyPricing
- Change price and payment tokenupdateLockConfig
- Modify lock settingssetLockMetadata
- Update name, symbol, URIwithdraw
- Extract funds from lock
Access Control
grantRole
/revokeRole
- Manage permissionssetOwner
- Transfer ownership
Advanced Features
cancelAndRefund
- Cancel with refundsetReferrerFee
- Configure referral rewardsmergeKeys
- Combine key durations
🔍 Example Usage
Get Protocol Information
Create a New Lock
Check Membership Status
Purchase a Key
Upgrade an Existing Lock
Grant Administrative Keys
🏗️ Architecture
Validation Pipeline
Error Handling
- Input Validation: Comprehensive Zod schemas for all parameters
- Network Errors: Automatic retry and detailed error messages
- Transaction Failures: Clear error reporting with gas estimation
- Logging: Structured logs with timestamps and context
Security Features
- Environment variable validation
- Address format verification
- Role-based access control
- Safe error handling without data leaks
📚 Environment Variables
Variable | Required | Description | Example |
---|---|---|---|
MCP_MODE | No | Operating mode | stdio or proxy |
INFURA_API_KEY | Yes* | Infura project ID | abc123... |
ALCHEMY_API_KEY | Yes* | Alchemy API key | xyz789... |
UNLOCK_ADDRESS | Yes | Unlock factory address | 0x1FF7e338d5E5... |
LOCK_ADDRESS | No | Default lock address | 0x... |
PRIVATE_KEY | stdio only | Wallet private key | 0x... |
PORT | No | Proxy server port | 3000 |
*Choose one RPC provider
🧪 Testing
Comprehensive Test Suite
This project includes a complete testing framework covering:
- 77 Tests across unit, integration, and E2E layers
- Mock Blockchain Interactions for reliable testing
- MCP Protocol Compliance verification
- CI/CD Integration with GitHub Actions
Running Tests
Test MCP Inspector
Health Check API (Proxy Mode)
Test Coverage
Current test coverage includes:
- Schema Validation: 100% coverage of all input validation
- Tool Definitions: Complete verification of 55 tools
- Function Categorization: Read vs write function classification
- Contract Interactions: Mocked blockchain operations
- Error Handling: Comprehensive error scenario testing
📋 Contract Addresses
Base Mainnet (Chain ID: 8453)
- Unlock Protocol:
0x1FF7e338d5E582138C46044dc238543Ce555C963
Base Sepolia (Chain ID: 84532)
- Unlock Protocol:
0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06
🤝 Contributing
This implementation follows MCP best practices:
- Type-safe function signatures
- Comprehensive input validation
- Detailed error handling
- Extensive logging
- Clear documentation
Perfect for building membership systems, subscription services, and access control mechanisms with AI assistance.
⚠️ Security Notice
- Use test networks for development
- Never commit private keys to version control
- Use dedicated wallets with minimal funds
- Validate all inputs in production environments
- Monitor transaction costs and set appropriate limits
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
An MCP server providing comprehensive access to Unlock Protocol on Base and Base-Sepolia networks, enabling AI agents to interact with membership, subscription, and access control functionality.
Related MCP Servers
- AsecurityFlicenseAqualityA Model Context Protocol (MCP) server that provides programmatic access to the Supabase Management API. This server allows AI models and other clients to manage Supabase projects and organizations through a standardized interface.Last updated -857842JavaScript
Armor Crypto MCPofficial
AsecurityAlicenseAqualityAn MCP server providing unified access to blockchain operations, bridging, swapping, and crypto trading strategies for AI agents.Last updated -20177PythonGPL 3.0- AsecurityFlicenseAqualityAn MCP server that enables AI agents to authenticate with and interact with Open eClass platform instances, supporting UoA's SSO authentication system for retrieving course information and performing basic platform operations.Last updated -45Python
- -securityFlicense-qualityAn auto-generated MCP server that enables interaction with the OpenAI API, allowing users to access OpenAI's models and capabilities through the Multi-Agent Conversation Protocol.Last updated -Python