• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
dcm31

dcm31

diceMcp

Simple dice rolling MCP server
Public
Like
diceMcp
Home
Code
2
README.md
H
main.ts
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
README.md

Dice MCP Server

A minimal MCP (Model Context Protocol) server that provides dice rolling and coin flipping tools. Great as a starting point for building your own MCP servers.

Tools

ToolDescription
roll_diceRoll 1-10 six-sided dice
flip_coinFlip a coin (heads/tails)

Usage

This MCP server works with any MCP-compatible client:

  • OpenAI Responses API - Add as an MCP tool
  • Claude Desktop - Add to your MCP config
  • MCP Chat - Add via the settings UI

Example with OpenAI

const response = await openai.responses.create({ model: "gpt-4o-mini", input: "Roll 3 dice for me", tools: [{ type: "mcp", server_label: "dice", server_url: "https://your-val-url.web.val.run", require_approval: "never", }], });

Building Your Own MCP Server

This val demonstrates the minimal structure for an HTTP MCP server:

  1. Handle CORS - Required for browser-based clients
  2. Implement initialize - Return server info and capabilities
  3. Implement tools/list - Return available tools with JSON schemas
  4. Implement tools/call - Execute tools and return results
  5. Handle notifications - Return 204 for notifications/initialized

MCP Protocol Basics

MCP uses JSON-RPC 2.0 over HTTP POST:

// Request { "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} } // Response { "jsonrpc": "2.0", "id": 1, "result": { "tools": [...] } }

Tool Response Format

Tools return content as an array of typed blocks:

return jsonRpc(id, { content: [{ type: "text", text: "You rolled a 6!" }] });

Remix This

Fork this val to create your own MCP server with custom tools!

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.