use rmcp::handler::server::wrapper::Json;
use rmcp::{ErrorData, elicit_safe};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
pub type ToolResult<T> = Result<Json<T>, ErrorData>;
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct PingResult {
#[schemars(description = "Connection status: ok or error")]
pub status: String,
#[schemars(description = "Query latency in milliseconds")]
pub latency_ms: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct TableInfo {
#[schemars(description = "Table name")]
pub name: String,
#[schemars(description = "Table type: TABLE, VIEW, SYNONYM, etc.")]
pub table_type: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ColumnInfo {
#[schemars(description = "Column name")]
pub name: String,
#[schemars(description = "HANA data type: VARCHAR, INTEGER, DECIMAL, TIMESTAMP, etc.")]
pub data_type: String,
#[schemars(description = "Whether column accepts NULL values")]
pub nullable: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct TableSchema {
#[schemars(description = "Table name")]
pub table_name: String,
#[schemars(description = "List of column definitions")]
pub columns: Vec<ColumnInfo>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct QueryResult {
#[schemars(description = "Column names in result set")]
pub columns: Vec<String>,
#[schemars(description = "Result rows as JSON arrays")]
pub rows: Vec<Vec<serde_json::Value>>,
#[schemars(description = "Number of rows returned")]
pub row_count: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[schemars(description = "Schema name")]
pub struct SchemaName {
#[schemars(description = "Name of the schema")]
pub name: String,
}
elicit_safe!(SchemaName);
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ListTablesParams {
#[serde(default)]
#[schemars(
description = "Schema name to filter tables. Leave empty to use CURRENT_SCHEMA (default behavior). Example: 'SYSTEM', 'MY_SCHEMA'"
)]
pub schema: Option<SchemaName>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct DescribeTableParams {
#[schemars(description = "Name of the table to describe. Example: 'EMPLOYEES', 'ORDERS'")]
pub table: String,
#[serde(default)]
#[schemars(
description = "Schema name where the table is located. Leave empty to use CURRENT_SCHEMA. Example: 'SYSTEM', 'MY_SCHEMA'"
)]
pub schema: Option<SchemaName>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ExecuteSqlParams {
#[schemars(
description = "SQL query to execute. In read-only mode, only SELECT, WITH, EXPLAIN, and CALL are allowed"
)]
pub sql: String,
#[serde(default)]
#[schemars(description = "Optional row limit. Server may enforce maximum limit")]
pub limit: Option<u32>,
}