Class: SchwabMCP::Tools::GetAccountNamesTool

Inherits:
MCP::Tool
  • Object
show all
Extended by:
Loggable
Defined in:
lib/schwab_mcp/tools/get_account_names_tool.rb

Class Method Summary collapse

Methods included from Loggable

log_debug, log_error, log_fatal, log_info, log_warn, logger

Class Method Details

.call(topic: nil, server_context:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/schwab_mcp/tools/get_account_names_tool.rb', line 30

def self.call(topic: nil, server_context:)
   = SchwabRb::AccountHashManager.new.
  acct_names_content = if  && !.empty?
    formatted_names = .map { |name| "- #{name}" }.join("\n")
    "Configured Schwab Account Names:\n\n#{formatted_names}"
  else
    <<~NO_ACCOUNTS
      No Schwab Account Names Configured

      You need to configure your Schwab account names in the account_names.json file.

      This file should be located in your schwab_home directory (typically ~/.schwab_rb/).

      For detailed setup instructions, please refer to:
      https://github.com/jwplatta/schwab_rb/blob/main/doc/ACCOUNT_MANAGEMENT.md

      The account_names.json file should map friendly names to your Schwab account hashes.
    NO_ACCOUNTS
  end

  MCP::Tool::Response.new([{
    type: "text",
    text: acct_names_content
  }])
end