Skip to main content
Glama

vonmises_random

Generate random angles from the von Mises distribution by specifying the mean direction and using elicitation to determine the concentration parameter.

Instructions

Generate a random number from the von Mises distribution. This is an example of a tool that uses elicitation to obtain the required parameter kappa (κ).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
muYesThe mean angle mu (μ), expressed in radians between 0 and 2π

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The vonmises_random async method is the tool handler. It takes a 'mu' parameter (radians between 0 and 2π), elicits 'kappa' from the user via ctx.elicit(), validates it, and returns a random value from the von Mises distribution using random.vonmisesvariate().
    async def vonmises_random(
        self,
        ctx: Context,
        mu: Annotated[
            float,
            Field(
                description="The mean angle mu (μ), expressed in radians between 0 and 2π",
                ge=0,
                le=2 * math.pi,
            ),
        ],
    ) -> float:
        """Generate a random number from the von Mises distribution. This is an example of a tool that uses elicitation to obtain the required parameter kappa (κ)."""
        await ctx.info("Requesting the user for the value of kappa for von Mises distribution.")
        response = await ctx.elicit(
            message="Please provide the value of kappa (κ) for the von Mises distribution. It should be a positive number.",
            response_type=float,
        )
        kappa: float = 1.0  # Default value
        match response:  # pragma: no cover
            case AcceptedElicitation(data=kappa):
                await ctx.warning(f"Received kappa: {kappa}")
                if kappa < 0:
                    raise McpError(
                        error=ErrorData(
                            code=INVALID_PARAMS,
                            message="kappa (κ) must be a positive number.",
                        )
                    )
            case DeclinedElicitation():
                await ctx.warning("User declined to provide kappa (κ). Using default value of 1.0.")
            case CancelledElicitation():
                await ctx.warning("User cancelled the operation. The random number will NOT be generated.")
                raise McpError(
                    error=ErrorData(
                        code=INVALID_PARAMS,
                        message="Operation cancelled by the user.",
                    )
                )
        return random.vonmisesvariate(mu, kappa)
  • Input schema: 'mu' parameter is a float annotated with Field constraints (ge=0, le=2*math.pi) describing the mean angle in radians. The return type is float.
    mu: Annotated[
        float,
        Field(
            description="The mean angle mu (μ), expressed in radians between 0 and 2π",
            ge=0,
            le=2 * math.pi,
        ),
    ],
  • Tool registration entry in the PyMCP class's 'tools' list, mapping the function name 'vonmises_random' with tags ['experimental', 'elicitation', 'example'].
    {"fn": "vonmises_random", "tags": ["experimental", "elicitation", "example"]},
  • Uses random.vonmisesvariate(mu, kappa) from Python's standard library to generate the random number from the von Mises distribution.
    return random.vonmisesvariate(mu, kappa)
Behavior3/5

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

With no annotations, the description partially discloses behavior by mentioning elicitation for kappa, but it's vague. It does not explain how elicitation works or what happens when called, leaving uncertainty about the required kappa parameter.

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

Conciseness4/5

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

The description is concise at two sentences, with the main purpose upfront. The second sentence adds useful but non-essential context, though it could be integrated more smoothly.

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

Completeness2/5

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

Despite having an output schema, the description fails to clarify how the elicitation process works for the required kappa parameter. This omission makes the tool incomplete for an agent to invoke correctly, as the agent might assume only mu is needed.

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?

Schema coverage is 100% for mu, with a clear description in the schema. The tool description adds no additional meaning beyond stating the elicitation for kappa, which is not a parameter. Baseline 3 is appropriate.

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 it generates a random number from the von Mises distribution, with a specific verb and resource. However, the mention of elicitation for kappa (κ), which is not in the input schema, could confuse the purpose. The tool differentiates from siblings like generate_password or greet.

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?

There is no guidance on when to use this tool versus alternatives or when not to use it. The description does not provide context 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/anirbanbasu/pymcp'

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