Skip to main content

FutuServer

Struct FutuServer 

Source
pub struct FutuServer {
    pub state: ServerState,
}

Fields§

§state: ServerState

Implementations§

Source§

impl FutuServer

Source

pub(crate) async fn resolve_read_trd_account( &self, tool: &'static str, req: &TrdAccReq, req_ctx: &RequestContext<RoleServer>, ) -> Result<ResolvedTrdAccount, String>

Resolve a TrdAccReq account selector for MCP read tools.

This preserves the v1.4.103-v1.4.106 security order:

  1. authenticate caller with the same API key priority as the tool;
  2. open the gateway client;
  3. resolve card_num inside the caller’s allowed account snapshot;
  4. re-check the final acc_id before dispatch.
Source§

impl FutuServer

Source

pub(crate) fn tool_err(msg: impl Display) -> Result<String, String>

v1.4.58 Phase C1: 新 helper — 返 Result<String, String> 让 rmcp 自动 set top-level CallToolResult.is_error = Some(true)(对齐 MCP spec)。

迁移策略(C1/C2/C3 拆 3 commit,都进 v1.4.58 一个版本):

  • C1:加此 helper + 迁移 5-10 pilot handlers
  • C2:批量迁移剩余 70+ handlers
  • C3:删除 Self::err / Self::wrap String hack(v1.4.42 遗留)

Client 双信号(向后兼容):

  • Top-level is_error: true(MCP spec 正确方式)
  • Content JSON 里仍含 {"error": msg, ...}(老 client 兼容)

rmcp IntoCallToolResult for Result<T, E> impl 自动把 Err 转成 CallToolResult { is_error: Some(true), content: [msg.into_contents()] }

Source

fn mcp_reject_to_json( kind: RejectKind, reason: String, tool: &str, audit_key_id: &str, ) -> String

v1.4.106 D1 5d: MCP-specific reject translator (rich context: tool + audit_key_id).

MCP 返 JSON-encoded String (rmcp Err(String) → 自动 CallToolResult { is_error: Some(true), ... }, 见 tool_err 注释).

rich context 路径 (require_acc_read_with_acc_id / require_trading 等): 把 kind + reason + tool + audit_key_id 翻成 user-friendly MCP error JSON. 这里保留 tool name + audit_key_id, 让 LLM agent 知道 是哪个 tool 哪把 key.

不变量 (与 v1.4.105 byte-identical):

  • Unauthenticated → “API key required for {tool}: …”
  • Forbidden → “API key {audit_key_id:?} forbidden: {reason}” (注意: reason 在 MCP 路径保留, 与 REST/gRPC generic 不同; MCP 是 LLM agent 调试场景, 反推风险低 + agent 需要清晰 hint 来纠正参数)
  • RateLimited → “rate limit: {reason}”
  • 其他 → reason
Source

pub(crate) fn wrap_result<E: Display>( res: Result<String, E>, ) -> Result<String, String>

v1.4.58 Phase C1: wrap 新版 —— 返 Result<String, String>。C2 批量迁移时使用。

Source

pub(crate) fn result_as_str(r: &Result<String, String>) -> &str

v1.4.58 Phase C2: 从 Result<String, String> 抽 string content 作 &str。 用于 guard::emit_trade_outcome 等接受 &str 的 side-effect observers — 无论 Ok/Err 都有 string 可引用。

Source

pub(crate) async fn client_or_err(&self) -> Result<Arc<FutuClient>, String>

Source

pub(crate) async fn read_client_or_err( &self, tool: &'static str, req_ctx: &RequestContext<RoleServer>, api_key_override: Option<&str>, acc_id: Option<u64>, ) -> Result<Arc<FutuClient>, String>

Common MCP read path: caller-specific guard first, then gateway client.

Used by read-only tools that do not need the returned caller snapshot for account/card filtering. Account-specific tools still call require_acc_read_with_acc_id directly so they can pass the same snapshot into account locator / response filtering.

Source

pub(crate) fn require_acc_read_with_acc_id( &self, tool: &'static str, req_ctx: &RequestContext<RoleServer>, api_key_override: Option<&str>, acc_id: Option<u64>, ) -> Result<CallerSnapshot, String>

v1.4.103 (codex 51 F1 / 52 F1 / 53 F1 / 54 F4 / 58 F1 — B5 + B6): per-request caller-specific scope 守卫 + acc_id 白名单 check.

require_tool_scope 只看 process-wide state.authed_key (startup 捕获), HTTP 客户端带窄权限 Bearer 时 read tool 仍按 startup key 放行 — 跨账户 leak.

本方法接 req_ctx (rmcp request context) + 可选 api_key_override (tool args 里的 api_key 字段, 与 trade write tools 一致) + 可选 acc_id, 优先级: api_key_override > HTTP Authorization Bearer > startup key.

解析得到 caller-specific KeyRecord 后:

  1. 检查 scope (基于 caller 的 scope, 不是 startup 的)
  2. 若 acc_id 提供 + caller key 有 allowed_acc_ids → 检查 acc_id ∈ allowed

stdio mode (无 Bearer) + 无 api_key_override → fall back 到 startup key 行为, 不破坏 stdio 用户体验.

返 Some(error_json) 拒绝, None 放行.

§v1.4.104 阶段 4: pipeline 委托

caller-specific KeyRecord 解析 + Bearer 不存在的 fail-closed 仍在本地 (要保留 v1.4.103 codex F4 verbose error message). scope check + acc_id 白名单 + audit emit 委托给 [futu_auth_pipeline::authenticate_request] (跨 surface 共享: gRPC server.rs / WS ws_listener.rs / REST auth.rs 同源). LoC 减 ~80 行, 行为与 v1.4.103 byte-identical.

Source

pub(crate) fn require_trading( &self, tool: &'static str, env: &str, ctx: Option<CheckCtx>, override_key: Option<&str>, ) -> Option<String>

交易写守卫;ctx=Some 时同时做限额检查;override_key=Some 时优先用该 plaintext.

§v1.4.104 阶段 7-4: pipeline 委托

guard::require_trading 165 LoC 折叠为 ~70 LoC 调用 pipeline:

  • legacy 2 级开关 (enable_trading / allow_real_trading) 仍在本地 (MCP-specific, pipeline 不知 daemon 启动 flag).
  • per-call override_key 仍在本地 verify (保留 v1.4.103 codex F4 verbose error message: “per-call api_key invalid”).
  • scope check + expiry + rate gate + body-aware ctx + audit 全 委托 authenticate_request (与 4 surface unified).
Source

pub(crate) fn require_caller_key_strict( &self, tool: &'static str, override_key: Option<&str>, ) -> Result<Option<Arc<KeyRecord>>, String>

v1.4.105 D12 contract-hardening 补丁: 拿当前 caller 的 KeyRecord (per-call key 优先 > startup key). legacy mode (无 keys.json) 返 None. 用于 trade tool 调 resolve_acc_id_with_card_num 时获取 allowed_card_nums 做 string-level whitelist 校验. codex round 1 F2 (P2) v1.4.105 移除老的 current_key_rec — 改用下面 require_caller_key_strict (fail-closed). 移除原因: invalid override 时 silent fallback startup → 给 backend resolve_acc_id_with_card_num 探测 leak. legacy mode 仍由 strict helper Ok(None) 返回处理.

codex round 1 F2 (P2) v1.4.105: 在 trade write 路径里验证 caller key + fail-closed, resolve_acc_id_with_card_num. 防 invalid Bearer 仍触发 daemon GetAccList + 用 startup key 的 allowed_card_nums 做 resolution (探测 leakage).

current_key_rec 区别:

  • current_key_rec: invalid override → silent fallback startup key → resolve 已 side-effect.
  • require_caller_key_strict: invalid override → 立即 Err 返 reject JSON, 绝不 fallback. 也保护 legacy mode (返 Ok(None)) 不破.

Return:

  • Ok(Some(rec)): caller key 已验, 用其 allowed_card_nums 做 resolve
  • Ok(None): scope mode 关闭 (legacy), require_trading 后续会处理
  • Err(json_str): invalid override / no key / startup key revoked, 立即 abort
Source

pub(crate) fn require_trading_scope_only( &self, tool: &'static str, env: &str, caller_key_rec: Option<&Arc<KeyRecord>>, ) -> Option<String>

codex round 2 F1 (P2) v1.4.105: trade write 路径 早期 trade-scope 校验 — 在 client_or_err + resolve_acc_id_with_card_num 之前.

require_trading (full ctx body-aware) 区别:

  • require_trading: 完整 scope + acc_id whitelist + market/symbol/value
    • rate gate (最终 gate, 在 resolve 之后).
  • require_trading_scope_only: 只 verify caller key 含 trade:realtrade:simulate scope. 检查 acc_id / market / symbol / value (这些 final gate 仍由 require_trading 后做).

目标: 防 valid 但非-trade key (e.g. qot:read only) 触发 daemon GetAccList + card_num resolution → 探测 not-found / ambiguous / existence timing & messages, 之后才被 final require_trading 拒绝. 早期 scope check 让此类 key 在 resolve 之前 fail-closed.

不替代 require_trading — 只前置一个轻量 scope guard. 后续 final gate (含 ctx) 仍跑.

Source§

impl FutuServer

Source

pub fn futu_get_quote_tool_attr() -> Tool

Generated tool metadata function for futu_get_quote

Source

fn futu_get_quote( &self, Parameters: Parameters<SymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_snapshot_tool_attr() -> Tool

Generated tool metadata function for futu_get_snapshot

Source

fn futu_get_snapshot( &self, Parameters: Parameters<SymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_kline_tool_attr() -> Tool

Generated tool metadata function for futu_get_kline

Source

fn futu_get_kline( &self, Parameters: Parameters<KLineReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_orderbook_tool_attr() -> Tool

Generated tool metadata function for futu_get_orderbook

Source

fn futu_get_orderbook( &self, Parameters: Parameters<OrderBookReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_ticker_tool_attr() -> Tool

Generated tool metadata function for futu_get_ticker

Source

fn futu_get_ticker( &self, Parameters: Parameters<TickerReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_rt_tool_attr() -> Tool

Generated tool metadata function for futu_get_rt

Source

fn futu_get_rt( &self, Parameters: Parameters<SymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_static_tool_attr() -> Tool

Generated tool metadata function for futu_get_static

Source

fn futu_get_static( &self, Parameters: Parameters<SymbolListReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_broker_tool_attr() -> Tool

Generated tool metadata function for futu_get_broker

Source

fn futu_get_broker( &self, Parameters: Parameters<SymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_list_plates_tool_attr() -> Tool

Generated tool metadata function for futu_list_plates

Source

fn futu_list_plates( &self, Parameters: Parameters<PlateListReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_plate_stocks_tool_attr() -> Tool

Generated tool metadata function for futu_plate_stocks

Source

fn futu_plate_stocks( &self, Parameters: Parameters<PlateStocksReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub(crate) fn market_tool_router() -> ToolRouter<Self>

Source§

impl FutuServer

Source

pub fn futu_get_capital_flow_tool_attr() -> Tool

Generated tool metadata function for futu_get_capital_flow

Source

fn futu_get_capital_flow( &self, Parameters: Parameters<CapitalFlowReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_capital_distribution_tool_attr() -> Tool

Generated tool metadata function for futu_get_capital_distribution

Source

fn futu_get_capital_distribution( &self, Parameters: Parameters<SymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_market_state_tool_attr() -> Tool

Generated tool metadata function for futu_get_market_state

Source

fn futu_get_market_state( &self, Parameters: Parameters<MarketStateReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_history_kline_tool_attr() -> Tool

Generated tool metadata function for futu_get_history_kline

Source

fn futu_get_history_kline( &self, Parameters: Parameters<HistoryKLineReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_owner_plate_tool_attr() -> Tool

Generated tool metadata function for futu_get_owner_plate

Source

fn futu_get_owner_plate( &self, Parameters: Parameters<SymbolListReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_reference_tool_attr() -> Tool

Generated tool metadata function for futu_get_reference

Source

fn futu_get_reference( &self, Parameters: Parameters<ReferenceReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_option_chain_tool_attr() -> Tool

Generated tool metadata function for futu_get_option_chain

Source

fn futu_get_option_chain( &self, Parameters: Parameters<OptionChainReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_warrant_tool_attr() -> Tool

Generated tool metadata function for futu_get_warrant

Source

fn futu_get_warrant( &self, Parameters: Parameters<WarrantReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_ipo_list_tool_attr() -> Tool

Generated tool metadata function for futu_get_ipo_list

Source

fn futu_get_ipo_list( &self, Parameters: Parameters<IpoListReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_future_info_tool_attr() -> Tool

Generated tool metadata function for futu_get_future_info

Source

fn futu_get_future_info( &self, Parameters: Parameters<FutureInfoReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_user_security_group_tool_attr() -> Tool

Generated tool metadata function for futu_get_user_security_group

Source

fn futu_get_user_security_group( &self, Parameters: Parameters<UserSecurityGroupReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_stock_filter_tool_attr() -> Tool

Generated tool metadata function for futu_get_stock_filter

Source

fn futu_get_stock_filter( &self, Parameters: Parameters<StockFilterReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_trading_days_tool_attr() -> Tool

Generated tool metadata function for futu_get_trading_days

Source

fn futu_get_trading_days( &self, Parameters: Parameters<TradingDaysReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_rehab_tool_attr() -> Tool

Generated tool metadata function for futu_get_rehab

Source

fn futu_get_rehab( &self, Parameters: Parameters<SymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_suspend_tool_attr() -> Tool

Generated tool metadata function for futu_get_suspend

Source

fn futu_get_suspend( &self, Parameters: Parameters<SuspendReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_user_security_tool_attr() -> Tool

Generated tool metadata function for futu_get_user_security

Source

fn futu_get_user_security( &self, Parameters: Parameters<UserSecurityReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_global_state_tool_attr() -> Tool

Generated tool metadata function for futu_get_global_state

Source

fn futu_get_global_state( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_user_info_tool_attr() -> Tool

Generated tool metadata function for futu_get_user_info

Source

fn futu_get_user_info( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_quote_rights_tool_attr() -> Tool

Generated tool metadata function for futu_get_quote_rights

Source

fn futu_get_quote_rights( &self, Parameters: Parameters<QuoteRightsReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_delay_statistics_tool_attr() -> Tool

Generated tool metadata function for futu_get_delay_statistics

Source

fn futu_get_delay_statistics( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_token_state_tool_attr() -> Tool

Generated tool metadata function for futu_get_token_state

Source

fn futu_get_token_state( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_risk_free_rate_tool_attr() -> Tool

Generated tool metadata function for futu_get_risk_free_rate

Source

fn futu_get_risk_free_rate( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_spread_table_tool_attr() -> Tool

Generated tool metadata function for futu_get_spread_table

Source

fn futu_get_spread_table( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_ticker_statistic_tool_attr() -> Tool

Generated tool metadata function for futu_get_ticker_statistic

Source

fn futu_get_ticker_statistic( &self, Parameters: Parameters<TickerStatisticReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_ticker_statistic_detail_tool_attr() -> Tool

Generated tool metadata function for futu_get_ticker_statistic_detail

Source

fn futu_get_ticker_statistic_detail( &self, Parameters: Parameters<TickerStatisticDetailReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_history_kl_quota_tool_attr() -> Tool

Generated tool metadata function for futu_get_history_kl_quota

Source

fn futu_get_history_kl_quota( &self, Parameters: Parameters<HistoryKlQuotaReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_holding_change_tool_attr() -> Tool

Generated tool metadata function for futu_get_holding_change

Source

fn futu_get_holding_change( &self, Parameters: Parameters<HoldingChangeReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_modify_user_security_tool_attr() -> Tool

Generated tool metadata function for futu_modify_user_security

Source

fn futu_modify_user_security( &self, Parameters: Parameters<ModifyUserSecurityReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_code_change_tool_attr() -> Tool

Generated tool metadata function for futu_get_code_change

Source

fn futu_get_code_change( &self, Parameters: Parameters<CodeChangeReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_set_price_reminder_tool_attr() -> Tool

Generated tool metadata function for futu_set_price_reminder

Source

fn futu_set_price_reminder( &self, Parameters: Parameters<SetPriceReminderReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_price_reminder_tool_attr() -> Tool

Generated tool metadata function for futu_get_price_reminder

Source

fn futu_get_price_reminder( &self, Parameters: Parameters<GetPriceReminderReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_option_expiration_date_tool_attr() -> Tool

Generated tool metadata function for futu_get_option_expiration_date

Source

fn futu_get_option_expiration_date( &self, Parameters: Parameters<OptionExpirationDateReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub(crate) fn reference_tool_router() -> ToolRouter<Self>

Source§

impl FutuServer

Source

pub fn futu_query_subscription_tool_attr() -> Tool

Generated tool metadata function for futu_query_subscription

Source

fn futu_query_subscription( &self, Parameters: Parameters<QuerySubscriptionReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_used_quota_tool_attr() -> Tool

Generated tool metadata function for futu_get_used_quota

Source

fn futu_get_used_quota( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_subscribe_tool_attr() -> Tool

Generated tool metadata function for futu_subscribe

Source

fn futu_subscribe( &self, Parameters: Parameters<SubscribeReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

v1.4.74 A1 BUG-011 fix: 加 futu_subscribe 补齐 MCP 对称性。

MCP 之前有 futu_unsubscribe / futu_sub_acc_push / futu_unsub_acc_push / futu_query_subscription / futu_push_subscriber_info 但缺 futu_subscribe 本身 → API 对称性被打破(“能取消但不能订阅”)。

架构:本 tool 触发 gateway 层订阅(CMD 3001 QOT_SUB),不返 push stream 本身。Push 数据通过 SSE notification 走(v1.4.58 MCP SSE basics), 客户端用 futu_push_subscriber_info 查询订阅状态。

对齐 Python SDK OpenQuoteContext.subscribe

Source

pub fn futu_unsubscribe_tool_attr() -> Tool

Generated tool metadata function for futu_unsubscribe

Source

fn futu_unsubscribe( &self, Parameters: Parameters<UnsubscribeReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_sub_acc_push_tool_attr() -> Tool

Generated tool metadata function for futu_sub_acc_push

Source

fn futu_sub_acc_push( &self, Parameters: Parameters<SubAccPushReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_unsub_acc_push_tool_attr() -> Tool

Generated tool metadata function for futu_unsub_acc_push

Source

fn futu_unsub_acc_push( &self, Parameters: Parameters<UnsubAccPushReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_push_subscriber_info_tool_attr() -> Tool

Generated tool metadata function for futu_push_subscriber_info

Source

fn futu_push_subscriber_info( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub(crate) fn subscription_tool_router() -> ToolRouter<Self>

Source§

impl FutuServer

Source

pub fn futu_ping_tool_attr() -> Tool

Generated tool metadata function for futu_ping

Source

fn futu_ping( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub(crate) fn system_tool_router() -> ToolRouter<Self>

Source§

impl FutuServer

Source

pub fn futu_list_accounts_tool_attr() -> Tool

Generated tool metadata function for futu_list_accounts

Source

fn futu_list_accounts( &self, Parameters: Parameters<NoArgs>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_funds_tool_attr() -> Tool

Generated tool metadata function for futu_get_funds

Source

fn futu_get_funds( &self, Parameters: Parameters<TrdAccReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_positions_tool_attr() -> Tool

Generated tool metadata function for futu_get_positions

Source

fn futu_get_positions( &self, Parameters: Parameters<TrdAccReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_orders_tool_attr() -> Tool

Generated tool metadata function for futu_get_orders

Source

fn futu_get_orders( &self, Parameters: Parameters<TrdAccReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_deals_tool_attr() -> Tool

Generated tool metadata function for futu_get_deals

Source

fn futu_get_deals( &self, Parameters: Parameters<TrdAccReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_max_trd_qtys_tool_attr() -> Tool

Generated tool metadata function for futu_get_max_trd_qtys

Source

fn futu_get_max_trd_qtys( &self, Parameters: Parameters<MaxTrdQtysReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_order_fee_tool_attr() -> Tool

Generated tool metadata function for futu_get_order_fee

Source

fn futu_get_order_fee( &self, Parameters: Parameters<OrderFeeReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_margin_ratio_tool_attr() -> Tool

Generated tool metadata function for futu_get_margin_ratio

Source

fn futu_get_margin_ratio( &self, Parameters: Parameters<MarginRatioReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_history_orders_tool_attr() -> Tool

Generated tool metadata function for futu_get_history_orders

Source

fn futu_get_history_orders( &self, Parameters: Parameters<HistoryQueryReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_history_deals_tool_attr() -> Tool

Generated tool metadata function for futu_get_history_deals

Source

fn futu_get_history_deals( &self, Parameters: Parameters<HistoryQueryReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_acc_cash_flow_tool_attr() -> Tool

Generated tool metadata function for futu_get_acc_cash_flow

Source

fn futu_get_acc_cash_flow( &self, Parameters: Parameters<AccCashFlowReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_flow_summary_tool_attr() -> Tool

Generated tool metadata function for futu_get_flow_summary

Source

fn futu_get_flow_summary( &self, Parameters: Parameters<AccCashFlowReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

v1.4.73 BUG-002 fix: MCP alias futu_get_flow_summary 指向同 handler。

eli v1.4.71 验收报告的 AI tester 列此为 P0(“MCP 58 工具无对应 futu_get_flow_summary, 有 margin_ratio / order_fee 同类查询”)。审查后发现:REST 侧两个 endpoint 并存 /api/flow-summary (原) + /api/acc-cash-flow (v1.4.51 alias), MCP 只有 futu_get_acc_cash_flow (v1.4.30 P2 实装)。

用户期待 MCP 与 REST /api/flow-summary 同名的 tool,这是 UX 对称问题。 本 alias 保持与主 tool futu_get_acc_cash_flow 语义完全一致, 参数结构 + handler 调用 + scope 登记全部共享。

Source

pub fn futu_get_cash_log_tool_attr() -> Tool

Generated tool metadata function for futu_get_cash_log

Source

fn futu_get_cash_log( &self, Parameters: Parameters<CashLogReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_cash_detail_tool_attr() -> Tool

Generated tool metadata function for futu_get_cash_detail

Source

fn futu_get_cash_detail( &self, Parameters: Parameters<CashDetailReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_biz_group_tool_attr() -> Tool

Generated tool metadata function for futu_get_biz_group

Source

fn futu_get_biz_group( &self, Parameters: Parameters<BizGroupReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_margin_info_tool_attr() -> Tool

Generated tool metadata function for futu_get_margin_info

Source

fn futu_get_margin_info( &self, Parameters: Parameters<MarginInfoReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_account_flag_tool_attr() -> Tool

Generated tool metadata function for futu_get_account_flag

Source

fn futu_get_account_flag( &self, Parameters: Parameters<AccountFlagReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_bond_total_asset_tool_attr() -> Tool

Generated tool metadata function for futu_get_bond_total_asset

Source

fn futu_get_bond_total_asset( &self, Parameters: Parameters<BondAccountReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_bond_single_asset_tool_attr() -> Tool

Generated tool metadata function for futu_get_bond_single_asset

Source

fn futu_get_bond_single_asset( &self, Parameters: Parameters<BondSymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_bond_position_list_tool_attr() -> Tool

Generated tool metadata function for futu_get_bond_position_list

Source

fn futu_get_bond_position_list( &self, Parameters: Parameters<BondAccountReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_bond_answer_state_tool_attr() -> Tool

Generated tool metadata function for futu_get_bond_answer_state

Source

fn futu_get_bond_answer_state( &self, Parameters: Parameters<BondSymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_get_bond_trade_reminder_tool_attr() -> Tool

Generated tool metadata function for futu_get_bond_trade_reminder

Source

fn futu_get_bond_trade_reminder( &self, Parameters: Parameters<BondSymbolReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub(crate) fn trade_read_tool_router() -> ToolRouter<Self>

Source§

impl FutuServer

Source

pub fn futu_place_order_tool_attr() -> Tool

Generated tool metadata function for futu_place_order

Source

fn futu_place_order( &self, Parameters: Parameters<PlaceOrderReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_modify_order_tool_attr() -> Tool

Generated tool metadata function for futu_modify_order

Source

fn futu_modify_order( &self, Parameters: Parameters<ModifyOrderReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_cancel_order_tool_attr() -> Tool

Generated tool metadata function for futu_cancel_order

Source

fn futu_cancel_order( &self, Parameters: Parameters<CancelOrderReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_reconfirm_order_tool_attr() -> Tool

Generated tool metadata function for futu_reconfirm_order

Source

fn futu_reconfirm_order( &self, Parameters: Parameters<ReconfirmOrderReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_cancel_all_order_tool_attr() -> Tool

Generated tool metadata function for futu_cancel_all_order

Source

fn futu_cancel_all_order( &self, Parameters: Parameters<CancelAllOrderReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub fn futu_unlock_trade_tool_attr() -> Tool

Generated tool metadata function for futu_unlock_trade

Source

fn futu_unlock_trade( &self, Parameters: Parameters<UnlockTradeReq>, req_ctx: RequestContext<RoleServer>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + '_>>

Source

pub(crate) fn trade_write_tool_router() -> ToolRouter<Self>

Source§

impl FutuServer

Source

pub fn new(state: ServerState) -> Self

Source§

impl FutuServer

Source

pub(crate) fn tool_router() -> ToolRouter<Self>

Trait Implementations§

Source§

impl Clone for FutuServer

Source§

fn clone(&self) -> FutuServer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ServerHandler for FutuServer

Source§

async fn call_tool( &self, request: CallToolRequestParams, context: RequestContext<RoleServer>, ) -> Result<CallToolResult, ErrorData>

Source§

async fn list_tools( &self, _request: Option<PaginatedRequestParams>, _context: RequestContext<RoleServer>, ) -> Result<ListToolsResult, ErrorData>

Source§

fn get_tool(&self, name: &str) -> Option<Tool>

Get a tool definition by name. Read more
Source§

fn get_info(&self) -> ServerInfo

§

fn enqueue_task( &self, _request: CallToolRequestParams, _context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CreateTaskResult, ErrorData>> + MaybeSendFuture

§

fn ping( &self, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

§

fn initialize( &self, request: InitializeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<InitializeResult, ErrorData>> + MaybeSendFuture

§

fn complete( &self, request: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CompleteResult, ErrorData>> + MaybeSendFuture

§

fn set_level( &self, request: SetLevelRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

§

fn get_prompt( &self, request: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetPromptResult, ErrorData>> + MaybeSendFuture

§

fn list_prompts( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListPromptsResult, ErrorData>> + MaybeSendFuture

§

fn list_resources( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListResourcesResult, ErrorData>> + MaybeSendFuture

§

fn list_resource_templates( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListResourceTemplatesResult, ErrorData>> + MaybeSendFuture

§

fn read_resource( &self, request: ReadResourceRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ReadResourceResult, ErrorData>> + MaybeSendFuture

§

fn subscribe( &self, request: SubscribeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

§

fn unsubscribe( &self, request: UnsubscribeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

§

fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CustomResult, ErrorData>> + MaybeSendFuture

§

fn on_cancelled( &self, notification: CancelledNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_progress( &self, notification: ProgressNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_initialized( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_roots_list_changed( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn list_tasks( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListTasksResult, ErrorData>> + MaybeSendFuture

§

fn get_task_info( &self, request: GetTaskInfoParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskResult, ErrorData>> + MaybeSendFuture

§

fn get_task_result( &self, request: GetTaskResultParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskPayloadResult, ErrorData>> + MaybeSendFuture

§

fn cancel_task( &self, request: CancelTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CancelTaskResult, ErrorData>> + MaybeSendFuture

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

§

impl<R, S> DynService<R> for S
where R: ServiceRole, S: Service<R>,

§

fn handle_request( &self, request: <R as ServiceRole>::PeerReq, context: RequestContext<R>, ) -> Pin<Box<dyn Future<Output = Result<<R as ServiceRole>::Resp, ErrorData>> + Send + '_>>

§

fn handle_notification( &self, notification: <R as ServiceRole>::PeerNot, context: NotificationContext<R>, ) -> Pin<Box<dyn Future<Output = Result<(), ErrorData>> + Send + '_>>

§

fn get_info(&self) -> <R as ServiceRole>::Info

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<H> Service<RoleServer> for H
where H: ServerHandler,

§

async fn handle_request( &self, request: <RoleServer as ServiceRole>::PeerReq, context: RequestContext<RoleServer>, ) -> Result<<RoleServer as ServiceRole>::Resp, ErrorData>

§

async fn handle_notification( &self, notification: <RoleServer as ServiceRole>::PeerNot, context: NotificationContext<RoleServer>, ) -> Result<(), ErrorData>

§

fn get_info(&self) -> <RoleServer as ServiceRole>::Info

§

impl<S> ServiceExt<RoleServer> for S
where S: Service<RoleServer>,

§

fn serve_with_ct<T, E, A>( self, transport: T, ct: CancellationToken, ) -> impl Future<Output = Result<RunningService<RoleServer, S>, ServerInitializeError>> + MaybeSendFuture
where T: IntoTransport<RoleServer, E, A>, E: Error + Send + Sync + 'static,

§

fn into_dyn(self) -> Box<dyn DynService<R>>

Convert this service to a dynamic boxed service Read more
§

fn serve<T, E, A>( self, transport: T, ) -> impl Future<Output = Result<RunningService<R, Self>, <R as ServiceRole>::InitializeError>> + MaybeSendFuture
where T: IntoTransport<R, E, A>, E: Error + Send + Sync + 'static, Self: Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more