nat.plugins.mcp.utils#
Functions#
|
Get a cached enum class or create a new one. |
|
Truncate a session ID for logging purposes. |
|
Create a pydantic model from the input schema of the MCP tool |
Module Contents#
- _get_or_create_enum( ) type[enum.Enum]#
Get a cached enum class or create a new one.
This function ensures that enums with the same name and values always return the same class object. This is critical for Pydantic validation, which checks enum instances by class identity.
Uses cache to automatically cache enum classes by their name and values.
- Args:
name: The name for the enum class values: Frozenset of enum values (frozenset is hashable for caching)
- Returns:
An Enum class (cached or newly created)