etrade-mcp 0.1.0__tar.gz

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 (126) hide show
  1. etrade_mcp-0.1.0/.gitignore +18 -0
  2. etrade_mcp-0.1.0/CHANGELOG.md +30 -0
  3. etrade_mcp-0.1.0/CONTRIBUTING.md +211 -0
  4. etrade_mcp-0.1.0/LICENSE +202 -0
  5. etrade_mcp-0.1.0/Makefile +40 -0
  6. etrade_mcp-0.1.0/PKG-INFO +163 -0
  7. etrade_mcp-0.1.0/README.md +120 -0
  8. etrade_mcp-0.1.0/SECURITY.md +84 -0
  9. etrade_mcp-0.1.0/docs/configuration.md +51 -0
  10. etrade_mcp-0.1.0/docs/connections.md +234 -0
  11. etrade_mcp-0.1.0/docs/diagnostics.md +22 -0
  12. etrade_mcp-0.1.0/docs/execution.md +78 -0
  13. etrade_mcp-0.1.0/docs/getting-started.md +37 -0
  14. etrade_mcp-0.1.0/docs/index.md +69 -0
  15. etrade_mcp-0.1.0/docs/previews.md +146 -0
  16. etrade_mcp-0.1.0/docs/reference/reads.md +45 -0
  17. etrade_mcp-0.1.0/docs/reference/responses.md +127 -0
  18. etrade_mcp-0.1.0/docs/reference/tool-coverage.md +76 -0
  19. etrade_mcp-0.1.0/docs/service.md +52 -0
  20. etrade_mcp-0.1.0/docs/stylesheets/extra.css +121 -0
  21. etrade_mcp-0.1.0/docs/workflows.md +43 -0
  22. etrade_mcp-0.1.0/mkdocs.yml +62 -0
  23. etrade_mcp-0.1.0/pyproject.toml +91 -0
  24. etrade_mcp-0.1.0/scripts/check_artifacts.py +205 -0
  25. etrade_mcp-0.1.0/scripts/check_release.py +77 -0
  26. etrade_mcp-0.1.0/scripts/protocol_smoke.py +260 -0
  27. etrade_mcp-0.1.0/src/etrade_mcp/__init__.py +5 -0
  28. etrade_mcp-0.1.0/src/etrade_mcp/__main__.py +5 -0
  29. etrade_mcp-0.1.0/src/etrade_mcp/_version.py +3 -0
  30. etrade_mcp-0.1.0/src/etrade_mcp/cli.py +92 -0
  31. etrade_mcp-0.1.0/src/etrade_mcp/config.py +88 -0
  32. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/accounts_get_balance.md +12 -0
  33. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/accounts_list.md +7 -0
  34. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/alerts_delete.md +17 -0
  35. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/alerts_get.md +12 -0
  36. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/alerts_list.md +12 -0
  37. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/fields.toml +445 -0
  38. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/market_get_option_chain.md +18 -0
  39. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/market_get_option_expirations.md +12 -0
  40. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/market_get_quote.md +12 -0
  41. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/market_get_quotes.md +15 -0
  42. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/market_lookup_product.md +9 -0
  43. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_cancel.md +16 -0
  44. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_list.md +13 -0
  45. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_place.md +33 -0
  46. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_place_change.md +34 -0
  47. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview.md +87 -0
  48. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_butterfly.md +35 -0
  49. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_buy_write.md +29 -0
  50. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_call_spread_short_put.md +33 -0
  51. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change.md +43 -0
  52. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_butterfly.md +36 -0
  53. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_buy_write.md +30 -0
  54. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_call_spread_short_put.md +34 -0
  55. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_condor.md +37 -0
  56. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_equity.md +28 -0
  57. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_iron_butterfly.md +35 -0
  58. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_iron_condor.md +36 -0
  59. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_single_option.md +31 -0
  60. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_change_vertical.md +34 -0
  61. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_condor.md +36 -0
  62. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_equity.md +27 -0
  63. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_iron_butterfly.md +34 -0
  64. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_iron_condor.md +35 -0
  65. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_single_option.md +30 -0
  66. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/orders_preview_vertical.md +33 -0
  67. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/portfolio_get_positions.md +15 -0
  68. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/server_status.md +9 -0
  69. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/transactions_get.md +10 -0
  70. etrade_mcp-0.1.0/src/etrade_mcp/descriptions/transactions_list.md +13 -0
  71. etrade_mcp-0.1.0/src/etrade_mcp/guidance.py +70 -0
  72. etrade_mcp-0.1.0/src/etrade_mcp/http.py +143 -0
  73. etrade_mcp-0.1.0/src/etrade_mcp/input_schema.py +138 -0
  74. etrade_mcp-0.1.0/src/etrade_mcp/inputs.py +224 -0
  75. etrade_mcp-0.1.0/src/etrade_mcp/order_families.py +417 -0
  76. etrade_mcp-0.1.0/src/etrade_mcp/policy.py +33 -0
  77. etrade_mcp-0.1.0/src/etrade_mcp/py.typed +0 -0
  78. etrade_mcp-0.1.0/src/etrade_mcp/responses.py +300 -0
  79. etrade_mcp-0.1.0/src/etrade_mcp/server.py +262 -0
  80. etrade_mcp-0.1.0/src/etrade_mcp/tool_logging.py +415 -0
  81. etrade_mcp-0.1.0/src/etrade_mcp/tools/__init__.py +94 -0
  82. etrade_mcp-0.1.0/src/etrade_mcp/tools/accounts.py +41 -0
  83. etrade_mcp-0.1.0/src/etrade_mcp/tools/alerts.py +75 -0
  84. etrade_mcp-0.1.0/src/etrade_mcp/tools/market.py +100 -0
  85. etrade_mcp-0.1.0/src/etrade_mcp/tools/orders.py +177 -0
  86. etrade_mcp-0.1.0/src/etrade_mcp/tools/portfolio.py +31 -0
  87. etrade_mcp-0.1.0/src/etrade_mcp/tools/specialized.py +374 -0
  88. etrade_mcp-0.1.0/src/etrade_mcp/tools/transactions.py +48 -0
  89. etrade_mcp-0.1.0/src/etrade_mcp/validation.py +347 -0
  90. etrade_mcp-0.1.0/tests/__init__.py +0 -0
  91. etrade_mcp-0.1.0/tests/audit_cases.py +75 -0
  92. etrade_mcp-0.1.0/tests/audit_worker.py +81 -0
  93. etrade_mcp-0.1.0/tests/broker_error_cases.py +105 -0
  94. etrade_mcp-0.1.0/tests/broker_error_worker.py +51 -0
  95. etrade_mcp-0.1.0/tests/conftest.py +49 -0
  96. etrade_mcp-0.1.0/tests/helpers.py +108 -0
  97. etrade_mcp-0.1.0/tests/large_response_data.py +18 -0
  98. etrade_mcp-0.1.0/tests/large_response_worker.py +44 -0
  99. etrade_mcp-0.1.0/tests/mutation_cases.py +105 -0
  100. etrade_mcp-0.1.0/tests/mutation_worker.py +49 -0
  101. etrade_mcp-0.1.0/tests/preview_cases.py +172 -0
  102. etrade_mcp-0.1.0/tests/read_cases.py +326 -0
  103. etrade_mcp-0.1.0/tests/response_contract_worker.py +115 -0
  104. etrade_mcp-0.1.0/tests/specialized_cases.py +2560 -0
  105. etrade_mcp-0.1.0/tests/test_broker_messages.py +225 -0
  106. etrade_mcp-0.1.0/tests/test_cli.py +195 -0
  107. etrade_mcp-0.1.0/tests/test_config.py +62 -0
  108. etrade_mcp-0.1.0/tests/test_guidance.py +224 -0
  109. etrade_mcp-0.1.0/tests/test_http.py +426 -0
  110. etrade_mcp-0.1.0/tests/test_input_schema.py +229 -0
  111. etrade_mcp-0.1.0/tests/test_large_responses.py +67 -0
  112. etrade_mcp-0.1.0/tests/test_mutations.py +607 -0
  113. etrade_mcp-0.1.0/tests/test_previews.py +413 -0
  114. etrade_mcp-0.1.0/tests/test_protocol_audit.py +421 -0
  115. etrade_mcp-0.1.0/tests/test_reads.py +358 -0
  116. etrade_mcp-0.1.0/tests/test_release.py +120 -0
  117. etrade_mcp-0.1.0/tests/test_response_contract.py +110 -0
  118. etrade_mcp-0.1.0/tests/test_responses.py +99 -0
  119. etrade_mcp-0.1.0/tests/test_server.py +293 -0
  120. etrade_mcp-0.1.0/tests/test_specialized_previews.py +375 -0
  121. etrade_mcp-0.1.0/tests/test_tool_logging.py +478 -0
  122. etrade_mcp-0.1.0/tests/test_validation.py +299 -0
  123. etrade_mcp-0.1.0/tests/tool_logging_worker.py +37 -0
  124. etrade_mcp-0.1.0/tests/validation_cases.py +196 -0
  125. etrade_mcp-0.1.0/tests/validation_worker.py +33 -0
  126. etrade_mcp-0.1.0/uv.lock +2124 -0
@@ -0,0 +1,18 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .env
5
+ .env.*
6
+ !.env.example
7
+ *credentials*.json
8
+ *.pem
9
+ .pytest_cache/
10
+ .ruff_cache/
11
+ .coverage*
12
+ coverage.xml
13
+ htmlcov/
14
+ dist/
15
+ build/
16
+ *.egg-info/
17
+ .idea/
18
+ site/
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ Interfaces may change before 1.0; review release notes before upgrading a
4
+ consuming harness.
5
+
6
+ ## 0.1.0
7
+
8
+ ### Added
9
+
10
+ - Python 3.11–3.14 MCP adapter over the public async `etrade-python>=1.1,<2` APIs,
11
+ with loopback Streamable HTTP and local stdio transports.
12
+ - Thirteen brokerage read tools, twenty general/specialized order previews, and
13
+ local server status; shared placement, change placement, cancellation, and alert
14
+ deletion tools available under independent, disabled-by-default permissions.
15
+ - Nine specialized order structures with complete replacement previews, full
16
+ general-request fallbacks, exact decimal strings, and reusable placement inputs.
17
+ - Strict inputs, inlined discovery schemas, packaged field/tool guidance, native
18
+ MCP error signaling, broker diagnostics, and bounded local validation details.
19
+ - Explicit environment/profile configuration, coordinated client credential
20
+ storage, HTTP bearer/Host/Origin restrictions, tool allowlists, and opt-in
21
+ redacted tool-call diagnostics on stderr.
22
+ - Direct, single-dispatch mutation wrappers with no implicit preview, execution
23
+ state, automatic mutation retries, or server deduplication. Hosts own human
24
+ approval, request binding, attempt history, and recovery after uncertain results.
25
+ - Offline real-client/mock-HTTP and actual MCP protocol tests; precision, multi-leg
26
+ mapping, pagination, transport loss, process restart, and secret-handling checks.
27
+ - Four-worker test commands, Python-version CI, isolated wheel/sdist verification,
28
+ and a release workflow for PyPI Trusted Publishing.
29
+ - Public Markdown documentation with MkDocs navigation/search, a concise README,
30
+ and a GitHub Pages workflow separate from package publishing.
@@ -0,0 +1,211 @@
1
+ # Contributing
2
+
3
+ Contributions to etrade-mcp are welcome. For a bug report, include steps to
4
+ reproduce it, expected and actual behavior, and the Python and package versions.
5
+ Discuss substantial features or architecture changes in an issue before starting
6
+ implementation so the proposed change can be agreed on with maintainers.
7
+
8
+ ## Set up a development environment
9
+
10
+ Fork the repository on GitHub, clone your fork, and create a branch for your
11
+ change. Install Python 3.11+ and uv, then run these commands from the repository
12
+ root:
13
+
14
+ ```sh
15
+ uv sync --extra dev --frozen
16
+ uv run --frozen etrade-mcp --version
17
+ ```
18
+
19
+ No E*TRADE credentials or authenticated broker access are needed to run the test
20
+ suite. See the [user guide](https://kevinrider.github.io/etrade-mcp/) for server
21
+ configuration and manual usage.
22
+
23
+ uv selects an available compatible Python interpreter. To select one explicitly,
24
+ set `UV_PYTHON`, for example `export UV_PYTHON=3.11`, before running setup and
25
+ checks. CI validates Python 3.11–3.14.
26
+
27
+ The committed `uv.lock` records development dependency versions. `--frozen` uses
28
+ that lockfile without updating it. When changing dependencies, update
29
+ `pyproject.toml`, run `uv lock`, and include the updated lockfile in your pull
30
+ request.
31
+
32
+ ## Make changes
33
+
34
+ Keep changes focused on the problem being addressed and add relevant tests for
35
+ new behavior or bug fixes. Update user-facing documentation when configuration,
36
+ tools, or behavior change.
37
+
38
+ etrade-mcp is a thin adapter over etrade-python. Keep runtime network code async
39
+ and typed, use only public client APIs, and reuse the client's models, OAuth
40
+ lifecycle, credential stores, and brokerage logic. Production code uses the real
41
+ client; mock broker responses belong only in tests. Preserve supported request
42
+ fields and monetary precision when adding tools.
43
+
44
+ The consuming host owns human approval, request/preview binding, execution
45
+ history, duplicate prevention, and recovery. Preserve the separation between
46
+ preview and placement. Do not add automatic mutation retries, resubmit a mutation
47
+ to reconstruct a lost response, or introduce an adapter execution database,
48
+ preparation records, or background monitoring.
49
+
50
+ Keep stdout reserved for MCP protocol traffic during stdio serving; send
51
+ diagnostics to stderr. Keep credentials and customer data out of results, errors,
52
+ logs, examples, and submitted files. Do not commit `.env` files or live brokerage
53
+ recordings.
54
+
55
+ Tool-call diagnostics are explicitly opt-in and use the dedicated
56
+ `etrade_mcp.tool_calls` logger. Preserve schema-based redaction, size limits,
57
+ stderr output, and argument types without modifying submitted arguments. Do not
58
+ log response bodies, arbitrary exceptions, unknown fields, or enable protocol/
59
+ HTTP wire logging. Test that diagnostic formatting and sink failures cannot
60
+ change tool results, and that both transports retain the same behavior.
61
+
62
+ Maintain the [tool coverage table](docs/reference/tool-coverage.md) manually when
63
+ client operations or MCP tools change. Link implemented tools to relevant tests,
64
+ distinguish planned tools, explain intentional omissions, and document coverage
65
+ of request fields when adding brokerage wrappers.
66
+
67
+ ## Maintain tool guidance
68
+
69
+ Tool descriptions live in packaged Markdown files under
70
+ `src/etrade_mcp/descriptions/`, named after each tool. Field descriptions live in
71
+ `fields.toml` in that directory, keyed by input model and Python field name.
72
+ Keep prose there and short implementation docstrings beside handlers. Validation,
73
+ types, defaults, aliases, and behavioral annotations belong in Python.
74
+
75
+ Every fenced `json` block in a tool description must be a complete synthetic
76
+ argument object for that tool. The server also advertises those blocks as input
77
+ schema examples and validates them with the actual input model. Use fake account
78
+ keys and symbols, decimal strings for modeled prices/quantities, and no credentials
79
+ or customer data. Examples establish request structure, not broker acceptance.
80
+
81
+ Describe when to use the tool, prerequisites, identifiers, conditional fields,
82
+ pagination, returned information, and approval/execution boundaries as applicable.
83
+ Put essential guidance first and keep descriptions within 4,096 characters for
84
+ hosts with shorter description budgets. Explain advanced settings through field
85
+ descriptions rather than filling examples with unused optional objects.
86
+
87
+ When adding or renaming a production tool, update the TOML tool catalog, its
88
+ Markdown file, and all referenced input models, including nested definitions.
89
+ Guidance tests detect missing/stale fields and check actual HTTP/stdio discovery.
90
+ Do not change schema constraints through the description layer or mutate client
91
+ models. Built-artifact checks must verify these assets outside the checkout.
92
+
93
+ Specialized previews share deterministic construction over public client models.
94
+ Keep their new/change inputs aligned, test explicit opening/closing sides and leg
95
+ ratios, and compare actual client HTTP bodies with independently specified
96
+ synthetic fixtures. Reusable placement arguments must preserve the normalized
97
+ submitted request and every preview ID; never reconstruct an order from the
98
+ broker preview's descriptive legs. Keep general previews available for complete
99
+ client request coverage.
100
+
101
+ ## Run checks
102
+
103
+ Before submitting a pull request, run:
104
+
105
+ ```sh
106
+ uv lock --check
107
+ uv run --frozen ruff check .
108
+ uv run --frozen ruff format --check .
109
+ uv run --frozen pyright --pythonpath .venv/bin/python
110
+ uv run --frozen pytest -n 4
111
+ ```
112
+
113
+ To apply formatting, use `uv run --frozen ruff format .`. If Make is available,
114
+ `make install`, `make check`, and `make format` wrap the setup, code checks, and
115
+ formatting commands. Run `uv lock --check` separately.
116
+
117
+ The full-suite command, `make test`, and CI use four pytest-xdist worker processes.
118
+ Coverage is combined across workers and retains the same 90% requirement. Direct
119
+ `uv run --frozen pytest` remains serial by default. To troubleshoot serially or
120
+ compare timings, run:
121
+
122
+ ```sh
123
+ uv run --frozen pytest -n 0 --durations=25
124
+ ```
125
+
126
+ For a machine with limited CPU or memory, use `-n 2` and compare elapsed time.
127
+ Avoid unbounded worker counts: protocol tests also start server processes.
128
+ Tests must keep temporary files, credential environments, and loopback ports
129
+ isolated across workers; do not share running servers between tests.
130
+
131
+ During development, run the affected tests without full-suite coverage collection:
132
+
133
+ ```sh
134
+ uv run --frozen pytest tests/test_mutations.py --no-cov
135
+ ```
136
+
137
+ Run the complete suite with coverage before submitting a pull request.
138
+
139
+ The suite enforces at least 90% combined statement/branch coverage. Brokerage
140
+ integration tests must exercise the real client with fake credentials and mocked
141
+ broker HTTP responses. Existing fixtures isolate credential storage and block
142
+ external broker networking. Protocol tests exercise actual stdio and loopback
143
+ HTTP connections. Keep offline tests independent of broker authorization, and
144
+ never place live orders as part of development or automated testing.
145
+
146
+ ## Maintain the public documentation
147
+
148
+ Public Markdown lives in `docs/`; `mkdocs.yml` defines navigation and strict
149
+ link checks. Keep the README short and link to the relevant guide page for detail.
150
+ The tool coverage table is maintained manually; do not generate it from tests.
151
+ CONTRIBUTING, SECURITY, and CHANGELOG remain canonical root documents linked from
152
+ the site. Packaged MCP tool descriptions remain in the Python package and are
153
+ separate from the website.
154
+
155
+ Install the optional documentation tools and build or preview locally:
156
+
157
+ ```sh
158
+ uv sync --extra dev --extra docs --frozen
159
+ uv run --extra docs --frozen mkdocs build --strict
160
+ uv run --extra docs --frozen mkdocs serve
161
+ ```
162
+
163
+ Equivalent Make targets are `make docs-build` and `make docs-serve`. The preview
164
+ uses port 8001 (separate from the MCP server's port 8000) and the project path
165
+ `http://127.0.0.1:8001/etrade-mcp/`. Generated `site/` output is ignored and must
166
+ not be committed. Inspect navigation, search, examples, and internal links before
167
+ submitting documentation changes; there are no README text/coverage snapshot tests.
168
+
169
+ The Documentation workflow builds pull requests and main-branch documentation
170
+ changes. Only main-branch pushes or a manual run on main deploy a successful build
171
+ to the `github-pages` environment. Pull requests have no deployment permissions.
172
+ The release build also validates the site once, outside its Python test matrix.
173
+
174
+ For the first deployment, the repository owner must select **Settings → Pages →
175
+ Build and deployment → Source: GitHub Actions**, then push the workflow/docs commit
176
+ or manually run Documentation on main. Review the resulting Pages URL before
177
+ publishing a package. Pages deployment is independent of the `pypi` environment
178
+ and does not publish a package or start an MCP server.
179
+
180
+ ## Verify distributions
181
+
182
+ For packaging changes, also run:
183
+
184
+ ```sh
185
+ uv build --clear
186
+ uv run --frozen python -m twine check --strict dist/*
187
+ uv run --frozen python scripts/check_artifacts.py
188
+ ```
189
+
190
+ Alternatively, run `make package-check`. The artifact checker validates archive
191
+ contents, installs the wheel and source distribution into separate temporary
192
+ virtual environments, and checks imports, package metadata, the CLI, and MCP
193
+ discovery/invocation over stdio and authenticated loopback HTTP outside the
194
+ checkout. It uses dummy credentials and does not contact E*TRADE or publish
195
+ artifacts. Package-index access is needed to install build and runtime
196
+ dependencies; temporary environments are removed afterward.
197
+
198
+ ## Submit a pull request
199
+
200
+ Push your branch to your fork and open a pull request against the repository's
201
+ default branch. Describe the problem, the resulting behavior, and any relevant
202
+ compatibility considerations. Link the related issue when there is one, identify
203
+ documentation updates, and state which checks you ran and their results.
204
+
205
+ Distinguish offline protocol tests and mocked brokerage integration tests from
206
+ any separately arranged authenticated broker validation. Note checks you could
207
+ not run and why. Address review feedback and keep the pull request focused;
208
+ release publishing is handled separately by maintainers. Report security issues
209
+ through [SECURITY.md](SECURITY.md), not public bug reports containing private details.
210
+
211
+ Contributions are provided under the project's [Apache-2.0 license](LICENSE).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,40 @@
1
+ .PHONY: install lint format format-check type test check build twine-check artifact-check package-check docs-build docs-serve
2
+
3
+ install:
4
+ uv sync --extra dev --frozen
5
+
6
+ lint:
7
+ uv run --frozen ruff check .
8
+
9
+ format:
10
+ uv run --frozen ruff format .
11
+
12
+ format-check:
13
+ uv run --frozen ruff format --check .
14
+
15
+ type:
16
+ uv run --frozen pyright --pythonpath .venv/bin/python
17
+
18
+ test:
19
+ uv run --frozen pytest -n 4
20
+
21
+ check: lint format-check type test
22
+
23
+ build:
24
+ uv build --clear
25
+
26
+ twine-check:
27
+ uv run --frozen python -m twine check --strict dist/*
28
+
29
+ artifact-check:
30
+ uv run --frozen python scripts/check_artifacts.py
31
+
32
+ package-check: build
33
+ uv run --frozen python -m twine check --strict dist/*
34
+ uv run --frozen python scripts/check_artifacts.py
35
+
36
+ docs-build:
37
+ uv run --extra docs --frozen mkdocs build --strict
38
+
39
+ docs-serve:
40
+ uv run --extra docs --frozen mkdocs serve
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: etrade-mcp
3
+ Version: 0.1.0
4
+ Summary: An unofficial Python MCP adapter for the etrade-python E*TRADE client
5
+ Project-URL: Homepage, https://github.com/kevinrider/etrade-mcp
6
+ Project-URL: Documentation, https://kevinrider.github.io/etrade-mcp/
7
+ Project-URL: Repository, https://github.com/kevinrider/etrade-mcp
8
+ Project-URL: Issues, https://github.com/kevinrider/etrade-mcp/issues
9
+ Project-URL: Changelog, https://github.com/kevinrider/etrade-mcp/blob/main/CHANGELOG.md
10
+ Author: etrade-mcp contributors
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: etrade-python<2,>=1.1
23
+ Requires-Dist: mcp<3,>=2.3
24
+ Requires-Dist: pydantic-settings<3,>=2.7
25
+ Requires-Dist: pydantic<3,>=2.12
26
+ Requires-Dist: starlette<2,>=1.10
27
+ Requires-Dist: typer<1,>=0.20
28
+ Requires-Dist: uvicorn<1,>=0.31.1
29
+ Provides-Extra: dev
30
+ Requires-Dist: build<2,>=1.2; extra == 'dev'
31
+ Requires-Dist: httpx2<3,>=2.10; extra == 'dev'
32
+ Requires-Dist: httpx<1,>=0.28; extra == 'dev'
33
+ Requires-Dist: pyright<2,>=1.1.400; extra == 'dev'
34
+ Requires-Dist: pytest-asyncio<2,>=1; extra == 'dev'
35
+ Requires-Dist: pytest-cov<8,>=6; extra == 'dev'
36
+ Requires-Dist: pytest-xdist<4,>=3.8; extra == 'dev'
37
+ Requires-Dist: pytest<10,>=8.3; extra == 'dev'
38
+ Requires-Dist: ruff<1,>=0.11; extra == 'dev'
39
+ Requires-Dist: twine<7,>=6; extra == 'dev'
40
+ Provides-Extra: docs
41
+ Requires-Dist: mkdocs<2,>=1.6; extra == 'docs'
42
+ Description-Content-Type: text/markdown
43
+
44
+ <div align="center">
45
+ <img src="https://repository-images.githubusercontent.com/1423904536/9aac8c54-260f-4d70-812b-0fb110af0394" alt="etrade-mcp project banner" width="640">
46
+ </div>
47
+
48
+ <h1 align="center">etrade-mcp: E*TRADE, one tool call away.</h1>
49
+
50
+ <div align="center">
51
+ <a href="https://github.com/kevinrider/etrade-mcp/releases"><img src="https://img.shields.io/github/release/kevinrider/etrade-mcp.svg?style=flat-square" alt="Latest Version"></a>
52
+ <a href="https://github.com/kevinrider/etrade-mcp/actions/workflows/ci.yml"><img src="https://github.com/kevinrider/etrade-mcp/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
53
+ <a href="https://github.com/kevinrider/etrade-mcp/issues"><img src="https://img.shields.io/github/issues/kevinrider/etrade-mcp" alt="GitHub issues"></a>
54
+ <a href="https://github.com/kevinrider/etrade-mcp/blob/main/LICENSE"><img src="https://img.shields.io/github/license/kevinrider/etrade-mcp" alt="License"></a>
55
+ </div>
56
+
57
+ <p align="center">
58
+ Give your agent a brokerage toolkit: accounts, quotes, positions, option chains, and order
59
+ management, through a typed Python MCP server backed by
60
+ <a href="https://pypi.org/project/etrade-python/">etrade-python</a>.
61
+ </p>
62
+
63
+ <p align="center">
64
+ <a href="https://kevinrider.github.io/etrade-mcp/">Documentation</a> ·
65
+ <a href="https://kevinrider.github.io/etrade-mcp/reference/tool-coverage/">Tool coverage</a> ·
66
+ <a href="https://kevinrider.github.io/etrade-mcp/connections/">Client setup</a> ·
67
+ <a href="https://github.com/kevinrider/etrade-mcp/blob/main/CHANGELOG.md">Changelog</a>
68
+ </p>
69
+
70
+ ## A toolkit that fits your harness
71
+
72
+ - **Read the account.** Balances, positions, transactions, orders, and alerts.
73
+ - **Explore the market.** Quotes, product lookup, option expirations, and chains.
74
+ - **Preview precisely.** Equity, single options, buy-writes, spreads, butterflies,
75
+ condors, and general multi-leg requests—with monetary values kept as decimal strings.
76
+ - **Choose your tools.** Expose a focused allowlist or the complete catalog.
77
+ - **Connect your way.** Local stdio or authenticated loopback Streamable HTTP.
78
+
79
+ There are **34 tools by default**: 13 brokerage reads, 20 new/change previews,
80
+ and `server_status`. Explicitly enabling order execution and alert deletion
81
+ brings the complete catalog to **38 tools**. Strategy, scheduling, and portfolio
82
+ decisions stay in your application.
83
+
84
+ ## Get started
85
+
86
+ Requires **Python 3.11–3.14** and [uv](https://docs.astral.sh/uv/).
87
+
88
+ ```sh
89
+ uv tool install --with-executables-from etrade-python etrade-mcp
90
+ etrade-mcp --version
91
+ etrade --version
92
+ ```
93
+
94
+ This exposes both the server and the client's OAuth CLI. Already have a
95
+ compatible `etrade` executable? See the
96
+ [installation guide](https://kevinrider.github.io/etrade-mcp/getting-started/)
97
+ for that setup.
98
+
99
+ Provide `ETRADE_CONSUMER_KEY` and `ETRADE_CONSUMER_SECRET` through your protected
100
+ process environment, using keys issued for the selected broker environment.
101
+ Then log in interactively:
102
+
103
+ ```sh
104
+ export ETRADE_ENVIRONMENT=sandbox
105
+ etrade auth login --profile default
106
+ ```
107
+
108
+ Start local HTTP with a generated bearer credential in your private shell:
109
+
110
+ ```sh
111
+ export ETRADE_MCP_HTTP_BEARER_TOKEN="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
112
+ etrade-mcp serve --environment sandbox --profile default \
113
+ --no-enable-order-execution --no-enable-alert-deletion
114
+ ```
115
+
116
+ Connect your host to `http://127.0.0.1:8000/mcp`, using that same bearer token.
117
+ For Codex, Claude Code, generic Python, or stdio, follow the
118
+ [connection examples](https://kevinrider.github.io/etrade-mcp/connections/).
119
+ Broker OAuth and the MCP bearer credential serve different purposes; keep both
120
+ out of prompts and committed configuration.
121
+
122
+ ## Ask your agent
123
+
124
+ Once connected and authenticated, try:
125
+
126
+ > Get the AAPL quote. Report the last trade price, bid, ask, quote status, and
127
+ > broker timestamp exactly as returned.
128
+
129
+ Then explore [workflow recipes](https://kevinrider.github.io/etrade-mcp/workflows/)
130
+ and [order previews](https://kevinrider.github.io/etrade-mcp/previews/).
131
+ Each tool advertises its input schema, field descriptions, and synthetic examples.
132
+ You can also inspect these directly in [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
133
+
134
+ ## Preview first. Execute deliberately.
135
+
136
+ **Execution is disabled by default.** Previews do not place orders.
137
+ The consuming host must obtain human approval bound to the exact account,
138
+ request, and preview before invoking an execution tool. A model's approval flag
139
+ or a server capability switch does not establish that approval.
140
+
141
+ The host also owns submission history and reconciliation after uncertain
142
+ outcomes. See the [execution guide](https://kevinrider.github.io/etrade-mcp/execution/)
143
+ for permissions, client-order-ID lifecycle, cancellations, and recovery.
144
+
145
+ ## Under the hood
146
+
147
+ Thin adapters call the public async client APIs. Both transports expose the same
148
+ validated tools and structured responses, with native MCP error signaling.
149
+ Brokerage behavior, OAuth, and coordinated credential storage stay in
150
+ `etrade-python>=1.1,<2`.
151
+
152
+ Offline tests cover actual MCP messages and real client serialization with mocked
153
+ broker HTTP. Built wheel/sdist checks run outside the checkout. These checks do
154
+ not establish broker acceptance of every order or reliability of every model.
155
+
156
+ ## Join in
157
+
158
+ [Contributing](https://github.com/kevinrider/etrade-mcp/blob/main/CONTRIBUTING.md) ·
159
+ [Issues](https://github.com/kevinrider/etrade-mcp/issues) ·
160
+ [Security](https://github.com/kevinrider/etrade-mcp/blob/main/SECURITY.md)
161
+
162
+ Apache-2.0. This project is not affiliated with or endorsed by E*TRADE or Morgan
163
+ Stanley.