mcp-dice
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.
A minimal MCP (Model Context Protocol) server example. Use this as a starting point for building your own MCP tools.
URL: https://dicemcp.val.run
| Tool | Description |
|---|---|
roll_dice | Roll 1-10 six-sided dice |
flip_coin | Flip a coin (heads/tails) |
Add this server in settings:
- Name:
dice - URL:
https://dicemcp.val.run
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://dicemcp.val.run",
require_approval: "never",
}],
});
# List tools curl -X POST https://dicemcp.val.run \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' # Roll dice curl -X POST https://dicemcp.val.run \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"roll_dice","arguments":{"count":3}}}'
This template shows the essential MCP pattern:
- Define tools with name, description, and JSON Schema for inputs
- Handle protocol methods:
initialize,tools/list,tools/call - Return JSON-RPC 2.0 responses
Key methods to implement:
initialize- Return server capabilitiestools/list- Return array of available toolstools/call- Execute a tool and return results
See the MCP specification for the full protocol.