1pub mod safety;
2pub mod service;
3pub mod tools;
4
5use crate::client::IndodaxClient;
6use crate::config::IndodaxConfig;
7use crate::errors::IndodaxError;
8use rmcp::ServiceExt;
9use service::ServiceGroup;
10use tools::IndodaxMcp;
11
12pub async fn run(
17 groups_str: &str,
18 allow_dangerous: bool,
19 client: IndodaxClient,
20 config: IndodaxConfig,
21) -> Result<(), IndodaxError> {
22 let enabled_groups = ServiceGroup::parse(groups_str)
23 .map_err(|e| IndodaxError::Other(format!("Invalid service groups: {}", e)))?;
24
25 let safety = safety::SafetyConfig::new(allow_dangerous);
26
27 let mcp_server = IndodaxMcp::new(client, config, safety, enabled_groups);
28
29 let service = mcp_server
30 .serve(rmcp::transport::io::stdio())
31 .await
32 .map_err(|e| IndodaxError::Other(format!("MCP server error: {}", e)))?;
33
34 tracing::info!(
35 "MCP server started with groups: {}, allow_dangerous: {}",
36 groups_str,
37 allow_dangerous
38 );
39
40 service.waiting().await
42 .map_err(|e| IndodaxError::Other(format!("MCP server error: {}", e)))?;
43
44 Ok(())
45}