Dice MCP Server

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

Tools

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

Usage

With MCP Chat

Add this server in settings:

  • Name: dice
  • URL: https://dicemcp.val.run

With OpenAI Responses API

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", }], });

Direct Testing

# 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}}}'

Building Your Own MCP Server

This template shows the essential MCP pattern:

  1. Define tools with name, description, and JSON Schema for inputs
  2. Handle protocol methods: initialize, tools/list, tools/call
  3. Return JSON-RPC 2.0 responses

Key methods to implement:

  • initialize - Return server capabilities
  • tools/list - Return array of available tools
  • tools/call - Execute a tool and return results

See the MCP specification for the full protocol.