1use thiserror::Error;
4
5#[derive(Error, Debug)]
7#[allow(dead_code)]
8pub enum McpError {
9 #[error("Configuration error: {0}")]
11 Configuration(String),
12
13 #[error("Cloud API error: {0}")]
15 CloudApi(String),
16
17 #[error("Enterprise API error: {0}")]
19 EnterpriseApi(String),
20
21 #[error("Redis error: {0}")]
23 Redis(String),
24
25 #[error("Authentication error: {0}")]
27 Auth(String),
28
29 #[error("Tool execution error: {0}")]
31 ToolExecution(String),
32
33 #[error("Invalid parameters: {0}")]
35 InvalidParameters(String),
36
37 #[error("Operation not permitted: server is in read-only mode")]
39 ReadOnlyMode,
40}
41
42impl From<anyhow::Error> for McpError {
43 fn from(err: anyhow::Error) -> Self {
44 McpError::ToolExecution(err.to_string())
45 }
46}
47
48impl From<redisctl_core::ConfigError> for McpError {
49 fn from(err: redisctl_core::ConfigError) -> Self {
50 McpError::Configuration(err.to_string())
51 }
52}
53
54#[cfg(feature = "database")]
55impl From<redis::RedisError> for McpError {
56 fn from(err: redis::RedisError) -> Self {
57 McpError::Redis(err.to_string())
58 }
59}