Skip to main content
Glama
zazencodes

Random Number MCP

by zazencodes

random_shuffle

Shuffle any list of items into a new random order using this tool, ideal for generating randomized sequences efficiently. Part of the Random Number MCP server for random generation tasks.

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

Implementation Reference

  • MCP handler function for the 'random_shuffle' tool. Decorated with @app.tool() for registration and delegates execution to the core logic in tools.py.
    @app.tool() 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 """ return tools.random_shuffle(items)
  • Core helper function implementing the shuffling logic using random.sample(population, len(population)) to return a new shuffled list without modifying the original.
    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))
  • Registration of the 'random_shuffle' tool via @app.tool() decorator on the FastMCP server instance.
    @app.tool() 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 """ return tools.random_shuffle(items)

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

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