Skip to main content
Glama

vonmises_random

Generate random numbers from the von Mises distribution for circular data analysis by specifying the mean angle in radians.

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π

Implementation Reference

  • The main handler function for the 'vonmises_random' tool. It takes mu as input, elicits kappa from the user, validates it, and returns a random sample from the von Mises distribution using Python's 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): # type: ignore[misc] 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(): # type: ignore[misc] await ctx.warning("User declined to provide kappa (κ). Using default value of 1.0.") case CancelledElicitation(): # type: ignore[misc] 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)
  • Pydantic-based input schema definition for the 'mu' parameter, including description and range constraints (0 to 2π). Kappa is elicited at runtime.
    mu: Annotated[ float, Field( description="The mean angle mu (μ), expressed in radians between 0 and 2π", ge=0, le=2 * math.pi, ), ], ) -> float:
  • Tool registration entry in the PyMCP class 'tools' list, specifying the function name and tags.
    {"fn": "vonmises_random", "tags": ["experimental", "elicitation", "example"]},

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