Skip to main content
Glama
zazencodes

Random Number MCP

by zazencodes

random_shuffle

Randomize the order of items in a list by returning a new shuffled list.

Instructions

Return a new list with items in random order.

Args: items: List of items to shuffle

Returns: New list with items in random order

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler logic for random_shuffle. Validates the list is not empty, then uses random.sample() to return a new shuffled list (instead of shuffling in place).
    def random_shuffle(items: list[Any]) -> list[Any]:
        """Return a new list with items in random order.
    
        Args:
            items: List of items to shuffle
    
        Returns:
            New list with items in random order
    
        Raises:
            ValueError: If items list is empty
        """
        validate_list_not_empty(items, "items")
    
        # Use random.sample to return a new list instead of shuffling in place
        return random.sample(items, len(items))
  • MCP server handler for random_shuffle. Decorated with @app.tool(), it delegates to tools.random_shuffle. Provides type hints restricting items to str | int | float | bool.
    @app.tool()
    def random_shuffle(
        items: list[str | int | float | bool],
    ) -> list[str | int | float | bool]:
        """Return a new list with items in random order.
    
        Args:
            items: List of items to shuffle
    
        Returns:
            New list with items in random order
        """
        return tools.random_shuffle(items)
  • Tool registration via @app.tool() decorator on the random_shuffle function in the FastMCP server.
    @app.tool()
    def random_shuffle(
        items: list[str | int | float | bool],
    ) -> list[str | int | float | bool]:
        """Return a new list with items in random order.
    
        Args:
            items: List of items to shuffle
    
        Returns:
            New list with items in random order
        """
        return tools.random_shuffle(items)
  • The validate_list_not_empty helper is used by random_shuffle to ensure the input list is not empty.
    from .utils import (
        validate_list_not_empty,
        validate_positive_int,
        validate_range,
        validate_weights_match_population,
    )
  • Input schema: items as list[str | int | float | bool]. Output schema: same list type.
        items: list[str | int | float | bool],
    ) -> list[str | int | float | bool]:
Behavior3/5

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

The description discloses that the operation returns a new list (non-destructive) and uses random order, but lacks details about randomness quality (e.g., cryptographic vs. pseudo-random) or performance implications. With no annotations, the description provides basic transparency but could be more informative.

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

Conciseness5/5

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

The description is extremely concise: two sentences plus standard args/returns docstring. Every sentence is necessary, with no redundant or irrelevant information. Well-structured for quick consumption.

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

Completeness4/5

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

Given the tool's simplicity (one parameter, straightforward purpose), the description covers the essential behavior. It states the return type and action. The presence of an output schema (not shown) likely completes the contract, so the description is adequate.

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 description adds marginal value beyond the input schema by labeling 'items' as a 'List of items to shuffle.' Schema coverage is 0%, but the single-parameter simplicity and clear docstring compensate somewhat. However, no additional constraints or example formats are provided.

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

Purpose5/5

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

The description clearly states 'Return a new list with items in random order,' specifying the verb ('return'), resource ('list'), and operation ('random order'). It distinguishes from siblings like random_choices and random_sample by focusing on shuffling the entire list, not sampling.

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

Usage Guidelines2/5

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

No usage guidance is provided. The description does not indicate when to use this tool over alternatives like random_choices or random_sample, nor does it mention any prerequisites or exclusions.

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

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/zazencodes/random-number-mcp'

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