datarobot_genai.drmcputils.exceptions
exceptions
Custom exceptions for DataRobot tools.
ToolErrorKind
Bases: StrEnum
High-level category for tool failures (logging and MCP-friendly).
SCHEMA — tool call arguments do not match the tool input schema (MCP/JSON shape, types,
required fields). Use VALIDATION for domain rules enforced inside the tool body.
Source code in datarobot_genai/drmcputils/exceptions.py
ToolError
Bases: Exception
Drop-in replacement for fastmcp.exceptions.ToolError.
This exception provides full compatibility with fastmcp's ToolError while removing the dependency on the fastmcp package. It should be raised when a tool encounters an error during execution that prevents it from completing its task.
The MCP framework expects tools to raise ToolError for user-facing errors that should be reported back to the client. This is distinct from other exceptions which might indicate programming errors or system failures.
Attributes
message: The error message to be displayed to the user.
kind: Semantic category of the failure (defaults to INTERNAL). Use ``ToolErrorKind.SCHEMA``
when MCP tool-call JSON or types do not match the declared input schema.
args: Tuple containing the error message (for compatibility with base Exception).
Examples
>>> raise ToolError("Failed to create deployment: No prediction servers available")
>>> raise ToolError(f"Job failed with status {job.status}", kind=ToolErrorKind.UPSTREAM)
>>> try:
... risky_operation()
... except ValueError as e:
... raise ToolError(f"Invalid input: {e}", kind=ToolErrorKind.VALIDATION)
>>> raise ToolError("Arguments do not match tool schema", kind=ToolErrorKind.SCHEMA)
Source code in datarobot_genai/drmcputils/exceptions.py
__init__
Initialize the ToolError with a descriptive message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
A clear, user-friendly description of what went wrong. This message will be displayed to the end user. |
required |
kind
|
ToolErrorKind
|
Category used for routing, metrics, and MCP error strings. |
INTERNAL
|