schwab_mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.copilotignore +3 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +8 -0
  5. data/CHANGELOG.md +5 -0
  6. data/CODE_OF_CONDUCT.md +132 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +157 -0
  9. data/Rakefile +12 -0
  10. data/exe/schwab_mcp +19 -0
  11. data/exe/schwab_token_refresh +38 -0
  12. data/exe/schwab_token_reset +49 -0
  13. data/lib/schwab_mcp/loggable.rb +31 -0
  14. data/lib/schwab_mcp/logger.rb +62 -0
  15. data/lib/schwab_mcp/option_chain_filter.rb +213 -0
  16. data/lib/schwab_mcp/orders/iron_condor_order.rb +87 -0
  17. data/lib/schwab_mcp/orders/order_factory.rb +40 -0
  18. data/lib/schwab_mcp/orders/vertical_order.rb +62 -0
  19. data/lib/schwab_mcp/redactor.rb +210 -0
  20. data/lib/schwab_mcp/resources/.keep +0 -0
  21. data/lib/schwab_mcp/tools/cancel_order_tool.rb +226 -0
  22. data/lib/schwab_mcp/tools/get_market_hours_tool.rb +104 -0
  23. data/lib/schwab_mcp/tools/get_order_tool.rb +263 -0
  24. data/lib/schwab_mcp/tools/get_price_history_tool.rb +203 -0
  25. data/lib/schwab_mcp/tools/help_tool.rb +406 -0
  26. data/lib/schwab_mcp/tools/list_account_orders_tool.rb +295 -0
  27. data/lib/schwab_mcp/tools/list_account_transactions_tool.rb +311 -0
  28. data/lib/schwab_mcp/tools/list_movers_tool.rb +125 -0
  29. data/lib/schwab_mcp/tools/list_schwab_accounts_tool.rb +162 -0
  30. data/lib/schwab_mcp/tools/option_chain_tool.rb +274 -0
  31. data/lib/schwab_mcp/tools/option_strategy_finder_tool.rb +378 -0
  32. data/lib/schwab_mcp/tools/place_order_tool.rb +305 -0
  33. data/lib/schwab_mcp/tools/preview_order_tool.rb +259 -0
  34. data/lib/schwab_mcp/tools/quote_tool.rb +77 -0
  35. data/lib/schwab_mcp/tools/quotes_tool.rb +110 -0
  36. data/lib/schwab_mcp/tools/replace_order_tool.rb +312 -0
  37. data/lib/schwab_mcp/tools/schwab_account_details_tool.rb +208 -0
  38. data/lib/schwab_mcp/version.rb +5 -0
  39. data/lib/schwab_mcp.rb +107 -0
  40. data/sig/schwab_mcp.rbs +4 -0
  41. data/start_mcp_server.sh +4 -0
  42. metadata +115 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c9da3afacad3bb1272bbff0e797dcaf882352d1263ab620446dd0c97d329debc
4
+ data.tar.gz: 6ea0e964b8ab66f7d92fc88b766b5c4d3569d18ed2b016ae35053e0d0a11b159
5
+ SHA512:
6
+ metadata.gz: 5000ea77ea70965802bf6b8bac785f01edb98b66568f3197678b5294aaa98a2f7e8e79912ca820307b06f40990ddfe6a24c2f51b24afbab947ee07c6ab909560
7
+ data.tar.gz: 5515f8088908d5a8a5a5f6e104ab4e29d6024acf275791b854eb00cbf7029868a5ce59d3b55e6b7aec66835baf1d3112a4ccf5aafb13bfdcc08482887690c74c
data/.copilotignore ADDED
@@ -0,0 +1,3 @@
1
+ .env
2
+ token.json
3
+ Gemlfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-07-10
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Joseph Platta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # SchwabMCP
2
+
3
+ A Model Context Protocol (MCP) server that provides AI assistants like Claude with secure access to Schwab's trading API. This gem enables natural language interactions with your Schwab brokerage account for retrieving market data, quotes, option chains, account information, and managing trades.
4
+
5
+ This gem is built on top of the [schwab_rb](https://github.com/jwplatta/schwab_rb) Ruby gem, which provides the underlying Schwab API client functionality.
6
+
7
+ ## Installation
8
+
9
+ Add this gem to your application's Gemfile:
10
+
11
+ ```bash
12
+ bundle add schwab_mcp
13
+ ```
14
+
15
+ Or install it directly:
16
+
17
+ ```bash
18
+ gem install schwab_mcp
19
+ ```
20
+
21
+ ### Prerequisites
22
+
23
+ Before using this gem, you'll need:
24
+
25
+ 1. A Schwab Developer account and API credentials
26
+ 2. Environment variables configured (see Usage section)
27
+ 3. Valid Schwab API tokens
28
+
29
+ **Dependencies:**
30
+ - This gem depends on [schwab_rb](https://github.com/jwplatta/schwab_rb) for Schwab API communication
31
+ - Ruby 3.1.0 or higher
32
+
33
+ ## Usage
34
+
35
+ ### Environment Setup
36
+
37
+ Create a `.env` file in your project root with the following required variables:
38
+
39
+ ```bash
40
+ SCHWAB_API_KEY=your_schwab_api_key
41
+ SCHWAB_APP_SECRET=your_schwab_app_secret
42
+ SCHWAB_CALLBACK_URI=your_callback_uri
43
+ TOKEN_PATH=path/to/your/token.json
44
+ ```
45
+
46
+ ### Running the MCP Server
47
+
48
+ Start the server using the provided executable:
49
+
50
+ ```bash
51
+ bundle exec exe/schwab_mcp
52
+ ```
53
+
54
+ Or use the convenience script:
55
+
56
+ ```bash
57
+ ./start_mcp_server.sh
58
+ ```
59
+
60
+ ### Token Management
61
+
62
+ The gem includes utility scripts for managing Schwab API authentication tokens:
63
+
64
+ #### Refresh Tokens
65
+
66
+ To refresh your existing authentication tokens:
67
+
68
+ ```bash
69
+ bundle exec exe/schwab_token_refresh
70
+ ```
71
+
72
+ This script will automatically refresh your tokens using the existing token file specified in your `TOKEN_PATH` environment variable.
73
+
74
+ #### Reset Tokens
75
+
76
+ To delete existing tokens and start the authentication process fresh:
77
+
78
+ ```bash
79
+ bundle exec exe/schwab_token_reset
80
+ ```
81
+
82
+ This script will:
83
+ 1. Delete your existing token file
84
+ 2. Guide you through the OAuth authentication flow to obtain new tokens
85
+
86
+ ### Available Tools
87
+
88
+ The MCP server provides the following tools for AI assistants:
89
+
90
+ - **Market Data**: Get quotes, option chains, price history, and market hours
91
+ - **Account Management**: View account details, balances, and positions
92
+ - **Order Management**: Preview, place, cancel, and replace orders
93
+ - **Transaction History**: Retrieve account transactions and order history
94
+ - **Market Analysis**: Find option strategies and view market movers
95
+
96
+ ### Integration with Claude Desktop
97
+
98
+ Configure Claude Desktop to use this MCP server by adding it to your `claude_desktop_config.json`.
99
+
100
+ ## Development
101
+
102
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
103
+
104
+ ### Setting up for Development
105
+
106
+ 1. Clone the repository
107
+ 2. Run `bundle install` to install dependencies
108
+ 3. Copy `.env.example` to `.env` and configure your Schwab API credentials
109
+ 4. Run tests with `bundle exec rspec`
110
+ 5. Start the development server with `bundle exec exe/schwab_mcp`
111
+
112
+ ### Testing
113
+
114
+ Run the test suite:
115
+
116
+ ```bash
117
+ bundle exec rspec
118
+ ```
119
+
120
+ ### Code Quality
121
+
122
+ The project uses RuboCop for code style enforcement:
123
+
124
+ ```bash
125
+ bundle exec rubocop
126
+ ```
127
+
128
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
129
+
130
+ ## Contributing
131
+
132
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jwplatta/schwab_mcp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/jwplatta/schwab_mcp/blob/master/CODE_OF_CONDUCT.md).
133
+
134
+ ### How to Contribute
135
+
136
+ 1. Fork the repository
137
+ 2. Create a feature branch (`git checkout -b my-new-feature`)
138
+ 3. Make your changes and add tests
139
+ 4. Ensure all tests pass (`bundle exec rspec`)
140
+ 5. Run RuboCop to check code style (`bundle exec rubocop`)
141
+ 6. Commit your changes (`git commit -am 'Add some feature'`)
142
+ 7. Push to the branch (`git push origin my-new-feature`)
143
+ 8. Create a new Pull Request
144
+
145
+ Please ensure your contributions:
146
+ - Include appropriate tests
147
+ - Follow the existing code style
148
+ - Update documentation as needed
149
+ - Respect the security considerations for financial API integration
150
+
151
+ ## License
152
+
153
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
154
+
155
+ ## Code of Conduct
156
+
157
+ Everyone interacting in the SchwabMcp project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/schwab_mcp/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/schwab_mcp ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "schwab_mcp"
4
+ require "dotenv/load"
5
+
6
+ required_vars = [
7
+ 'SCHWAB_API_KEY',
8
+ 'SCHWAB_APP_SECRET',
9
+ 'SCHWAB_CALLBACK_URI',
10
+ 'TOKEN_PATH'
11
+ ]
12
+ missing_vars = required_vars.select { |var| ENV[var].nil? || ENV[var].empty? }
13
+
14
+ unless missing_vars.empty?
15
+ exit 1
16
+ end
17
+
18
+
19
+ SchwabMCP::Server.new.start
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'pry'
6
+ require 'dotenv'
7
+ require 'schwab_rb'
8
+
9
+ Dotenv.load
10
+
11
+ required_vars = [
12
+ 'SCHWAB_API_KEY',
13
+ 'SCHWAB_APP_SECRET',
14
+ 'SCHWAB_CALLBACK_URI',
15
+ 'TOKEN_PATH'
16
+ ]
17
+ missing_vars = required_vars.select { |var| ENV[var].nil? || ENV[var].empty? }
18
+
19
+ unless missing_vars.empty?
20
+ puts "❌ Missing required environment variables: #{missing_vars.join(', ')}"
21
+ exit 1
22
+ end
23
+
24
+ token_path = ENV['TOKEN_PATH']
25
+ puts "Token path: #{token_path}"
26
+
27
+ begin
28
+ SchwabRb::Auth.init_client_easy(
29
+ ENV['SCHWAB_API_KEY'],
30
+ ENV['SCHWAB_APP_SECRET'],
31
+ ENV['SCHWAB_CALLBACK_URI'],
32
+ token_path
33
+ )
34
+ puts "✅ Token refresh completed successfully"
35
+ rescue => e
36
+ puts "❌ Token refresh failed: #{e.message}"
37
+ exit 1
38
+ end
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'pry'
6
+ require 'dotenv'
7
+ require 'schwab_rb'
8
+
9
+ Dotenv.load
10
+
11
+ required_vars = [
12
+ 'SCHWAB_API_KEY',
13
+ 'SCHWAB_APP_SECRET',
14
+ 'SCHWAB_CALLBACK_URI',
15
+ 'TOKEN_PATH'
16
+ ]
17
+ missing_vars = required_vars.select { |var| ENV[var].nil? || ENV[var].empty? }
18
+
19
+ unless missing_vars.empty?
20
+ puts "❌ Missing required environment variables: #{missing_vars.join(', ')}"
21
+ exit 1
22
+ end
23
+
24
+ token_path = ENV['TOKEN_PATH']
25
+ puts "Token path: #{token_path}"
26
+
27
+ if File.exist?(token_path)
28
+ puts "đŸ—‘ī¸ Deleting existing token file: #{token_path}"
29
+ File.delete(token_path)
30
+ puts "✅ Token file deleted successfully"
31
+ else
32
+ puts "â„šī¸ Token file doesn't exist at: #{token_path}"
33
+ end
34
+
35
+ refresh_script_path = File.join(File.dirname(__FILE__), 'schwab_token_refresh')
36
+ puts "🔄 Calling token refresh script: #{refresh_script_path}"
37
+
38
+ begin
39
+ result = system(refresh_script_path)
40
+ if result
41
+ puts "✅ Token reset and refresh completed successfully"
42
+ else
43
+ puts "❌ Token refresh script failed"
44
+ exit 1
45
+ end
46
+ rescue => e
47
+ puts "❌ Failed to execute token refresh script: #{e.message}"
48
+ exit 1
49
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "logger"
4
+
5
+ module SchwabMCP
6
+ module Loggable
7
+ def logger
8
+ SchwabMCP::Logger
9
+ end
10
+
11
+ def log_debug(message)
12
+ logger.debug(message)
13
+ end
14
+
15
+ def log_info(message)
16
+ logger.info(message)
17
+ end
18
+
19
+ def log_warn(message)
20
+ logger.warn(message)
21
+ end
22
+
23
+ def log_error(message)
24
+ logger.error(message)
25
+ end
26
+
27
+ def log_fatal(message)
28
+ logger.fatal(message)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require "tmpdir"
5
+ require_relative "redactor"
6
+
7
+ module SchwabMCP
8
+ class Logger
9
+ @instance = nil
10
+
11
+ class << self
12
+ def instance
13
+ @instance ||= create_logger
14
+ end
15
+
16
+ def debug(message)
17
+ instance.debug(Redactor.redact_formatted_text(message)) if debug_enabled?
18
+ end
19
+
20
+ def info(message)
21
+ instance.info(Redactor.redact_formatted_text(message))
22
+ end
23
+
24
+ def warn(message)
25
+ instance.warn(Redactor.redact_formatted_text(message))
26
+ end
27
+
28
+ def error(message)
29
+ instance.error(Redactor.redact_formatted_text(message))
30
+ end
31
+
32
+ def fatal(message)
33
+ instance.fatal(Redactor.redact_formatted_text(message))
34
+ end
35
+
36
+ private
37
+
38
+ def create_logger
39
+ if ENV['LOGFILE'] && !ENV['LOGFILE'].empty?
40
+ max_size = (ENV['LOG_MAX_SIZE'] || 10 * 1024 * 1024).to_i
41
+ max_files = (ENV['LOG_MAX_FILES'] || 5).to_i
42
+ logger = ::Logger.new(ENV['LOGFILE'], max_files, max_size)
43
+ else
44
+ # When running as MCP server, don't log to stderr as it interferes with the protocol
45
+ # Use a default log file instead
46
+ default_log_file = File.join(Dir.tmpdir, 'schwab_mcp.log')
47
+ logger = ::Logger.new(default_log_file)
48
+ end
49
+
50
+ logger.level = debug_enabled? ? ::Logger::DEBUG : ::Logger::INFO
51
+ logger.formatter = proc do |severity, datetime, progname, msg|
52
+ "[#{datetime.strftime('%H:%M:%S')}] SCHWAB_MCP #{severity}: #{msg}\n"
53
+ end
54
+ logger
55
+ end
56
+
57
+ def debug_enabled?
58
+ ENV['DEBUG'] == 'true' || ENV['LOG_LEVEL'] == 'DEBUG'
59
+ end
60
+ end
61
+ end
62
+ end