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.
| Tool | Description |
|---|---|
roll_dice | Roll 1-10 six-sided dice |
flip_coin | Flip a coin (heads/tails) |
This MCP server works with any MCP-compatible client:
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",
}],
});
This val demonstrates the minimal structure for an HTTP MCP server:
initialize - Return server info and capabilitiestools/list - Return available tools with JSON schemastools/call - Execute tools and return resultsnotifications/initializedMCP 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": [...] } }
Tools return content as an array of typed blocks:
return jsonRpc(id, {
content: [{ type: "text", text: "You rolled a 6!" }]
});
Fork this val to create your own MCP server with custom tools!