indodax_cli/mcp/tools/
auth.rs1use serde_json::Value;
2use rmcp::model::{CallToolResult, Tool};
3
4use super::IndodaxMcp;
5
6pub fn auth_tools() -> Vec<Tool> {
7 vec![
8 IndodaxMcp::tool_def(
9 "auth_show",
10 "Show current API configuration status",
11 serde_json::json!({}),
12 vec![],
13 ),
14 IndodaxMcp::tool_def(
15 "auth_test",
16 "Test if current API credentials are valid",
17 serde_json::json!({}),
18 vec![],
19 ),
20 ]
21}
22
23impl IndodaxMcp {
24 pub async fn handle_auth_show(&self) -> CallToolResult {
25 let config = self.config.lock().await;
26 Self::json_result(serde_json::json!({
27 "api_key_set": config.api_key.is_some(),
28 "api_secret_set": config.api_secret.is_some(),
29 "callback_url": config.callback_url,
30 }))
31 }
32
33 pub async fn handle_auth_test(&self) -> CallToolResult {
34 match self.client.signer() {
35 Some(_) => {
36 match self
37 .client
38 .private_post_v1::<Value>("getInfo", &std::collections::HashMap::new())
39 .await
40 {
41 Ok(data) => {
42 let name = data
43 .get("name")
44 .and_then(|v| v.as_str())
45 .unwrap_or("unknown");
46 Self::json_result(serde_json::json!({
47 "status": "ok",
48 "name": name,
49 }))
50 }
51 Err(e) => Self::error_from_indodax(&e),
52 }
53 }
54 None => Self::error_result(
55 "No API credentials configured. Use environment variables or config file."
56 .to_string(),
57 ),
58 }
59 }
60}