Skip to main content

futu_mcp/tools/
reference_corporate_short_brokers.rs

1//! MCP v10.6 corporate-actions, short-interest, and broker-flow reference tools.
2
3use crate::handlers;
4use crate::tool_args::*;
5use rmcp::{RoleServer, handler::server::wrapper::Parameters, service::RequestContext};
6
7use super::FutuServer;
8
9impl FutuServer {
10    async fn futu_get_daily_short_volume_impl(
11        &self,
12        Parameters(req): Parameters<ShortInfoReq>,
13        req_ctx: RequestContext<RoleServer>,
14    ) -> std::result::Result<String, String> {
15        req.validate("futu_get_daily_short_volume")?;
16        tracing::info!(
17            tool = "futu_get_daily_short_volume",
18            symbol = %req.symbol,
19            next_key = ?req.next_key,
20            num = ?req.num
21        );
22        let client = self
23            .read_client_or_err("futu_get_daily_short_volume", &req_ctx, None, None)
24            .await?;
25        Self::wrap_result(
26            handlers::reference::get_daily_short_volume(
27                &client,
28                &req.symbol,
29                req.next_key.as_deref(),
30                req.num,
31            )
32            .await,
33        )
34    }
35
36    async fn futu_get_corporate_actions_buybacks_impl(
37        &self,
38        Parameters(req): Parameters<ShortInfoReq>,
39        req_ctx: RequestContext<RoleServer>,
40    ) -> std::result::Result<String, String> {
41        req.validate("futu_get_corporate_actions_buybacks")?;
42        tracing::info!(
43            tool = "futu_get_corporate_actions_buybacks",
44            symbol = %req.symbol,
45            next_key = ?req.next_key,
46            num = ?req.num
47        );
48        let client = self
49            .read_client_or_err("futu_get_corporate_actions_buybacks", &req_ctx, None, None)
50            .await?;
51        Self::wrap_result(
52            handlers::reference::get_corporate_actions_buybacks(
53                &client,
54                &req.symbol,
55                req.next_key.as_deref(),
56                req.num,
57            )
58            .await,
59        )
60    }
61
62    async fn futu_get_corporate_actions_dividends_impl(
63        &self,
64        Parameters(req): Parameters<SymbolReq>,
65        req_ctx: RequestContext<RoleServer>,
66    ) -> std::result::Result<String, String> {
67        tracing::info!(
68            tool = "futu_get_corporate_actions_dividends",
69            symbol = %req.symbol
70        );
71        let client = self
72            .read_client_or_err("futu_get_corporate_actions_dividends", &req_ctx, None, None)
73            .await?;
74        Self::wrap_result(
75            handlers::reference::get_corporate_actions_dividends(&client, &req.symbol).await,
76        )
77    }
78
79    async fn futu_get_corporate_actions_stock_splits_impl(
80        &self,
81        Parameters(req): Parameters<ShortInfoReq>,
82        req_ctx: RequestContext<RoleServer>,
83    ) -> std::result::Result<String, String> {
84        req.validate("futu_get_corporate_actions_stock_splits")?;
85        tracing::info!(
86            tool = "futu_get_corporate_actions_stock_splits",
87            symbol = %req.symbol,
88            next_key = ?req.next_key,
89            num = ?req.num
90        );
91        let client = self
92            .read_client_or_err(
93                "futu_get_corporate_actions_stock_splits",
94                &req_ctx,
95                None,
96                None,
97            )
98            .await?;
99        Self::wrap_result(
100            handlers::reference::get_corporate_actions_stock_splits(
101                &client,
102                &req.symbol,
103                req.next_key.as_deref(),
104                req.num,
105            )
106            .await,
107        )
108    }
109
110    async fn futu_get_short_interest_impl(
111        &self,
112        Parameters(req): Parameters<ShortInfoReq>,
113        req_ctx: RequestContext<RoleServer>,
114    ) -> std::result::Result<String, String> {
115        req.validate("futu_get_short_interest")?;
116        tracing::info!(
117            tool = "futu_get_short_interest",
118            symbol = %req.symbol,
119            next_key = ?req.next_key,
120            num = ?req.num
121        );
122        let client = self
123            .read_client_or_err("futu_get_short_interest", &req_ctx, None, None)
124            .await?;
125        Self::wrap_result(
126            handlers::reference::get_short_interest(
127                &client,
128                &req.symbol,
129                req.next_key.as_deref(),
130                req.num,
131            )
132            .await,
133        )
134    }
135
136    async fn futu_get_top_ten_buy_sell_brokers_impl(
137        &self,
138        Parameters(req): Parameters<TopTenBuySellBrokersReq>,
139        req_ctx: RequestContext<RoleServer>,
140    ) -> std::result::Result<String, String> {
141        req.validate()?;
142        tracing::info!(
143            tool = "futu_get_top_ten_buy_sell_brokers",
144            symbol = %req.symbol,
145            days_before = ?req.days_before
146        );
147        let client = self
148            .read_client_or_err("futu_get_top_ten_buy_sell_brokers", &req_ctx, None, None)
149            .await?;
150        Self::wrap_result(
151            handlers::reference::get_top_ten_buy_sell_brokers(
152                &client,
153                &req.symbol,
154                req.days_before,
155            )
156            .await,
157        )
158    }
159}
160
161include!(concat!(
162    env!("OUT_DIR"),
163    "/generated_mcp_routes_reference_corporate_short_brokers.rs"
164));