Skip to main content
Glama
TeglonLabs

Coin Flip MCP Server

by TeglonLabs

flip_coin

Generate true random coin flips with customizable side names and configurations. Use for decision-making, temporal analysis, ordinal progression, or abstraction level guidance. Supports multiple sides and integrates with random.org for true randomness.

Instructions

Flip a coin with n sides using true randomness from random.org. For 3-sided coins, try creative side names like:

  • past/present/future (temporal analysis)

  • true/unknown/false (epistemic states)

  • win/draw/lose (outcome evaluation)

  • rock/paper/scissors (cyclic relationships)

  • less/same/more (abstraction levels)

  • below/within/above (hierarchical positioning)

  • predecessor/current/successor (ordinal progression)

Meta-usage patterns:

  1. Use less/same/more to guide abstraction level of discourse

  2. Use past/present/future to determine temporal focus

  3. Chain multiple flips to create decision trees

  4. Use predecessor/current/successor for ordinal analysis

Ordinal Meta-patterns:

  • Use predecessor to refine previous concepts

  • Use current to stabilize existing patterns

  • Use successor to evolve into new forms

Default ternary values are -/0/+

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sideNamesNoOptional custom names for sides (must match number of sides)
sidesNoNumber of sides (default: 3)

Implementation Reference

  • The handler function for CallToolRequestSchema that implements the flip_coin tool logic. It validates inputs, handles special cases (sides=0,1,<0), fetches random number from random.org API, maps to output (custom names, heads/tails, -/0/+, or side N), and returns the result or error.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name !== "flip_coin") {
        throw new McpError(ErrorCode.MethodNotFound, "Unknown tool");
      }
    
      try {
        const args = request.params.arguments as FlipCoinArgs;
        const sides = args.sides ?? 3;
        const sideNames = args.sideNames;
        if (sideNames && sideNames.length !== sides) {
          return {
            isError: true,
            content: [{
              type: "text",
              text: `Number of side names (${sideNames.length}) must match number of sides (${sides})`
            }]
          };
        }
        
        // Validate and handle special cases that don't need random.org
        if (sides === 0) {
          return {
            content: [{
              type: "text",
              text: "The coin vanished into another dimension! 🌀"
            }]
          };
        }
        
        if (sides === 1) {
          return {
            content: [{
              type: "text",
              text: "_"
            }]
          };
        }
        
        if (sides < 0) {
          return {
            content: [{
              type: "text",
              text: "Cannot flip a coin with negative sides!"
            }]
          };
        }
        
        // Only reach here for sides > 1
        // Use random.org's API to get a random number
        const response = await axios.get('https://www.random.org/integers/', {
          params: {
            num: 1,
            min: 1,
            max: sides,
            col: 1,
            base: 10,
            format: 'plain',
            rnd: 'new'
          }
        });
    
        const result = parseInt(response.data);
        let output: string;
    
        if (sideNames) {
          output = sideNames[result - 1].toLowerCase();
        } else if (sides === 2) {
          output = result === 1 ? "heads" : "tails";
        } else if (sides === 3) {
          output = result === 1 ? "-" : result === 2 ? "0" : "+";
        } else {
          output = `side ${result}`;
        }
    
        return {
          content: [{
            type: "text",
            text: output
          }]
        };
      } catch (error) {
        return {
          isError: true,
          content: [{
            type: "text",
            text: `Error flipping coin: ${error instanceof Error ? error.message : 'Unknown error'}`
          }]
        };
      }
    });
  • TypeScript interface defining the input arguments for the flip_coin tool: optional 'sides' (number, default 3) and 'sideNames' (array of strings). Used for type casting in the handler.
    interface FlipCoinArgs {
      sides?: number;
      sideNames?: string[];
    }
  • JSON schema for the flip_coin tool input, as exposed in the ListTools response. Defines properties for 'sides' and 'sideNames' matching the TypeScript interface.
    {
      name: "flip_coin",
      description: "Flip a coin with n sides using true randomness from random.org. For 3-sided coins, try creative side names like:\n- past/present/future (temporal analysis)\n- true/unknown/false (epistemic states)\n- win/draw/lose (outcome evaluation)\n- rock/paper/scissors (cyclic relationships)\n- less/same/more (abstraction levels)\n- below/within/above (hierarchical positioning)\n- predecessor/current/successor (ordinal progression)\n\nMeta-usage patterns:\n1. Use less/same/more to guide abstraction level of discourse\n2. Use past/present/future to determine temporal focus\n3. Chain multiple flips to create decision trees\n4. Use predecessor/current/successor for ordinal analysis\n\nOrdinal Meta-patterns:\n- Use predecessor to refine previous concepts\n- Use current to stabilize existing patterns\n- Use successor to evolve into new forms\n\nDefault ternary values are -/0/+",
      inputSchema: {
        type: "object",
        properties: {
          sides: {
            type: "number",
            description: "Number of sides (default: 3)"
          },
          sideNames: {
            type: "array",
            items: {
              type: "string"
            },
            description: "Optional custom names for sides (must match number of sides)"
          }
        }
      }
    }
  • src/index.ts:32-57 (registration)
    The ListToolsRequestSchema handler that registers the 'flip_coin' tool by returning it in the tools list, including name, description, and inputSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "flip_coin",
            description: "Flip a coin with n sides using true randomness from random.org. For 3-sided coins, try creative side names like:\n- past/present/future (temporal analysis)\n- true/unknown/false (epistemic states)\n- win/draw/lose (outcome evaluation)\n- rock/paper/scissors (cyclic relationships)\n- less/same/more (abstraction levels)\n- below/within/above (hierarchical positioning)\n- predecessor/current/successor (ordinal progression)\n\nMeta-usage patterns:\n1. Use less/same/more to guide abstraction level of discourse\n2. Use past/present/future to determine temporal focus\n3. Chain multiple flips to create decision trees\n4. Use predecessor/current/successor for ordinal analysis\n\nOrdinal Meta-patterns:\n- Use predecessor to refine previous concepts\n- Use current to stabilize existing patterns\n- Use successor to evolve into new forms\n\nDefault ternary values are -/0/+",
            inputSchema: {
              type: "object",
              properties: {
                sides: {
                  type: "number",
                  description: "Number of sides (default: 3)"
                },
                sideNames: {
                  type: "array",
                  items: {
                    type: "string"
                  },
                  description: "Optional custom names for sides (must match number of sides)"
                }
              }
            }
          }
        ]
      };
    });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the randomness source ('true randomness from random.org') and default behavior ('Default ternary values are -/0/+'), but it doesn't cover potential rate limits, error conditions, or output format details. This provides some behavioral context but leaves gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is overly verbose and poorly structured, with extensive examples and meta-patterns that may not all be necessary. It's front-loaded with the core purpose but then diverges into lengthy lists and patterns, reducing clarity and efficiency. Some content could be trimmed without losing essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (2 parameters, no output schema, no annotations), the description is somewhat complete but excessive. It covers purpose and usage ideas but lacks output details and could be more focused. The richness in examples compensates partially but doesn't fully align with the tool's simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the baseline is 3. The description adds value by explaining creative uses for 3-sided coins and meta-patterns, which indirectly clarifies parameter semantics (e.g., how 'sideNames' might be applied). However, it doesn't explicitly detail parameter meanings beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Flip a coin with n sides using true randomness from random.org.' This specifies the verb ('Flip'), resource ('coin'), and randomness source. However, it doesn't distinguish from siblings since there are none, so it can't achieve a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage through examples of 3-sided coins and meta-usage patterns, suggesting when to use specific configurations. However, it lacks explicit guidance on when to use this tool versus alternatives (none exist) or clear exclusions, keeping it at an intermediate level.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TeglonLabs/coin-flip-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server