ExMCP.Transport.SecurityError (ex_mcp v0.10.0)
View SourceStandardized security error handling across transports.
This module provides consistent error formatting and handling for security violations across all MCP transports.
Summary
Functions
Formats a security error for a specific transport.
Creates a new security error.
Checks if an error is a security-related error.
Converts a security error to a standard Elixir error tuple.
Types
@type error_type() ::
:token_passthrough_blocked
| :consent_required
| :consent_denied
| :consent_error
| :security_violation
@type t() :: %ExMCP.Transport.SecurityError{ details: map(), message: String.t(), timestamp: DateTime.t(), type: atom() }
Functions
Formats a security error for a specific transport.
Different transports may need different error formats:
- HTTP: Status codes and JSON responses
- Stdio: JSON-RPC error format
- BEAM: Elixir error tuples
@spec new(error_type(), String.t(), map()) :: t()
Creates a new security error.
Parameters
type- The type of security violationmessage- Human-readable error messagedetails- Additional context about the error
Examples
error = SecurityError.new(:consent_required,
"User consent required",
%{url: "https://api.example.com", user_id: "user123"}
)
Checks if an error is a security-related error.
Converts a security error to a standard Elixir error tuple.