A beautiful web application and Model Context Protocol (MCP) server that brings dice rolling functionality directly to Claude Desktop. Built with Next.js, shadcn/ui, and the MCP Handler library with server actions for seamless web testing.
- 🎲 Roll Any Dice: Support for any number of sides (minimum 2) - d4, d6, d20, d100, or custom
- 🌐 Beautiful Web Interface: Modern, responsive UI with detailed setup instructions
- 🔄 Server Actions Integration: Web interface uses the same logic as the MCP server
- 🌙 Dark/Light Mode: Toggle between themes with dark mode as default
- 📋 Copy-to-Clipboard: Easy configuration copying for Claude Desktop setup
- 🔧 Multiple Transports: Supports SSE, stdio, and other MCP transport protocols
- 🚀 Vercel Ready: Optimized for deployment on Vercel platform
- 📱 Responsive Design: Works perfectly on desktop and mobile devices
- 🧠 Educational: Detailed explanations of MCP protocol and architecture
Visit the live application: [Your Vercel URL here]
git clone https://github.com/gocallum/rolldice-mcpserver.git
cd rolldice-mcpserver
npm installnpm run devThe application will be available at:
- Web Interface:
http://localhost:3000(setup instructions, documentation, and testing) - MCP Endpoint:
http://localhost:3000/api/[transport](for Claude Desktop)
The web interface at http://localhost:3000 provides detailed, step-by-step instructions with copy-to-clipboard functionality. Here's the quick version:
Download from claude.ai/download
Add this to your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"rolldice": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://localhost:3000/api/mcp"
]
}
}
}Look for the hammer icon (🔨) in the input box - this indicates MCP tools are available!
Ask Claude natural language questions like:
- "Roll a 6-sided die"
- "Roll a d20 for my D&D character"
- "Can you roll a 100-sided die?"
This application uses mcp-handler to provide seamless integration between web applications and AI assistants like Claude Desktop.
Claude Desktop → Transport Protocol → /api/[transport] → Shared Dice Logic (/lib/dice.ts)
Web Interface → Server Actions → Shared Dice Logic (/lib/dice.ts)
- Claude Desktop connects via various transport protocols (SSE, stdio, etc.)
- Transport Layer handles the MCP protocol communication
- MCP Handler processes tool calls and invokes shared dice logic
- Shared Logic (
/lib/dice.ts) contains the single source of truth for validation and randomness - Server Actions (for web) call the same shared dice logic directly
lib/dice.ts: Shared dice rolling logic, schema, and tool definitionsapp/api/[transport]/route.ts: MCP server endpoint using mcp-handler + shared logicapp/actions/mcp-actions.ts: Server actions that use the shared dice logicapp/page.tsx: Beautiful web interface with setup instructions and testingcomponents/: Reusable shadcn/ui components for the interface
The web interface uses Next.js Server Actions that import the same shared logic as the MCP server:
- ✅ Same Zod schema validation (
lib/dice.ts) - ✅ Identical randomness algorithm (single
rollDice()function) - ✅ Consistent output formatting (same result structure)
- ✅ Shared tool definitions (same name, description, schema)
- ✅ True single source of truth architecture
- MCP Tools:
roll_dicetool with Zod validation for parameters
-
Connect to Vercel:
npm i -g vercel vercel
-
Update Claude Desktop Config: Replace
http://localhost:3000with your Vercel URL:{ "mcpServers": { "rolldice": { "command": "npx", "args": [ "-y", "mcp-remote", "https://your-app.vercel.app/api/mcp" ] } } } -
Restart Claude Desktop to use the deployed version
- Framework: Next.js 15 with App Router
- UI Library: shadcn/ui components
- Styling: Tailwind CSS with CSS variables
- MCP Integration: mcp-handler for HTTP-based MCP protocol
- MCP Bridge: mcp-remote for Claude Desktop connectivity
- Validation: Zod for type-safe parameter validation
- Theme: next-themes for dark/light mode
- Icons: Lucide React for beautiful icons
- Deployment: Vercel platform
- 🎮 Tabletop Gaming: Perfect for D&D, Pathfinder, and other RPGs
- 🤔 Decision Making: Use dice rolls to make random choices
- 📚 Education: Demonstrate probability and random number generation
- 🎲 Game Development: Test random mechanics and game balance
- 🎪 Fun & Entertainment: Add randomness to conversations with Claude
Contributions are welcome! This project is open source and MIT licensed.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Model Context Protocol - Official MCP documentation
- mcp-handler - The HTTP-based MCP handler used in this project
- mcp-remote - Bridge tool for Claude Desktop connectivity
- Claude Desktop - Download and setup guide
- Next.js Documentation - Learn about the framework
MIT License - see LICENSE file for details.
Created by Callum Bir
⭐ If you find this project useful, please consider giving it a star on GitHub!
Built with ❤️ using Next.js, shadcn/ui, and the Model Context Protocol