@guiie/buda-mcp 1.5.0 → 1.5.1

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 (59) hide show
  1. package/.cursor/rules/marketplace-docs-sync.mdc +32 -0
  2. package/CHANGELOG.md +40 -0
  3. package/PUBLISH_CHECKLIST.md +40 -88
  4. package/README.md +446 -78
  5. package/dist/client.d.ts +1 -0
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +2 -1
  8. package/dist/http.js +42 -6
  9. package/dist/index.js +12 -3
  10. package/dist/tools/batch_orders.d.ts +5 -0
  11. package/dist/tools/batch_orders.d.ts.map +1 -1
  12. package/dist/tools/batch_orders.js +35 -1
  13. package/dist/tools/cancel_order.js +1 -1
  14. package/dist/tools/dead_mans_switch.d.ts +1 -1
  15. package/dist/tools/dead_mans_switch.d.ts.map +1 -1
  16. package/dist/tools/dead_mans_switch.js +33 -3
  17. package/dist/tools/lightning.d.ts.map +1 -1
  18. package/dist/tools/lightning.js +15 -1
  19. package/dist/tools/place_order.d.ts.map +1 -1
  20. package/dist/tools/place_order.js +31 -0
  21. package/dist/tools/receive_addresses.d.ts +5 -0
  22. package/dist/tools/receive_addresses.d.ts.map +1 -1
  23. package/dist/tools/receive_addresses.js +26 -2
  24. package/dist/tools/remittances.d.ts +5 -0
  25. package/dist/tools/remittances.d.ts.map +1 -1
  26. package/dist/tools/remittances.js +27 -3
  27. package/dist/tools/technical_indicators.d.ts.map +1 -1
  28. package/dist/tools/technical_indicators.js +2 -1
  29. package/dist/tools/withdrawals.d.ts.map +1 -1
  30. package/dist/tools/withdrawals.js +11 -1
  31. package/dist/utils.d.ts.map +1 -1
  32. package/dist/utils.js +4 -1
  33. package/dist/validation.d.ts +6 -0
  34. package/dist/validation.d.ts.map +1 -1
  35. package/dist/validation.js +26 -0
  36. package/dist/version.d.ts.map +1 -1
  37. package/dist/version.js +8 -1
  38. package/marketplace/README.md +1 -1
  39. package/marketplace/claude-listing.md +75 -4
  40. package/marketplace/gemini-tools.json +325 -2
  41. package/marketplace/openapi.yaml +160 -1
  42. package/package.json +2 -1
  43. package/server.json +2 -2
  44. package/src/client.ts +3 -1
  45. package/src/http.ts +50 -6
  46. package/src/index.ts +10 -3
  47. package/src/tools/batch_orders.ts +40 -1
  48. package/src/tools/cancel_order.ts +1 -1
  49. package/src/tools/dead_mans_switch.ts +39 -3
  50. package/src/tools/lightning.ts +17 -1
  51. package/src/tools/place_order.ts +32 -0
  52. package/src/tools/receive_addresses.ts +29 -3
  53. package/src/tools/remittances.ts +30 -4
  54. package/src/tools/technical_indicators.ts +2 -1
  55. package/src/tools/withdrawals.ts +12 -1
  56. package/src/utils.ts +3 -1
  57. package/src/validation.ts +29 -0
  58. package/src/version.ts +11 -3
  59. package/test/unit.ts +261 -18
@@ -0,0 +1,32 @@
1
+ ---
2
+ description: Keep marketplace documentation in sync with tool changes
3
+ globs: src/tools/**/*.ts
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Marketplace Documentation Sync
8
+
9
+ Any change to `src/tools/` that adds, removes, or modifies a tool **must** be accompanied by matching updates to all three marketplace files.
10
+
11
+ ## Files to keep in sync
12
+
13
+ | File | What to update |
14
+ |------|----------------|
15
+ | `marketplace/claude-listing.md` | Add/remove/update `### \`tool_name\`` section in the correct group (Public or Authenticated) |
16
+ | `marketplace/gemini-tools.json` | Add/remove/update entry in `functionDeclarations[]` with Gemini types (`STRING`, `INTEGER`, `NUMBER`, `OBJECT`) |
17
+ | `marketplace/openapi.yaml` | Add/remove/update path + response schema — **public tools only** (auth tools are excluded intentionally) |
18
+
19
+ ## When each file needs updating
20
+
21
+ - **New tool added** → add to all applicable files above
22
+ - **Tool removed** → remove from all files
23
+ - **Parameter added/changed/removed** → update description and `required` array in all files
24
+ - **Tool description changed** → update all files
25
+ - **Auth status changed** (public ↔ auth) → move between sections in `claude-listing.md`, update `gemini-tools.json`, add/remove from `openapi.yaml`
26
+
27
+ ## Quick checklist before committing
28
+
29
+ - [ ] `claude-listing.md` reflects all 46+ tools (run `grep "^### \`" marketplace/claude-listing.md | wc -l` to count)
30
+ - [ ] `gemini-tools.json` `functionDeclarations` count matches
31
+ - [ ] `openapi.yaml` paths count matches public tool count
32
+ - [ ] `CHANGELOG.md` has an entry describing the change
package/CHANGELOG.md CHANGED
@@ -7,6 +7,46 @@ This project uses [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ---
9
9
 
10
+ ## [Unreleased]
11
+
12
+ ---
13
+
14
+ ## [1.5.1] – 2026-04-11
15
+
16
+ ### Security
17
+
18
+ - **HTTP startup guard for missing `MCP_AUTH_TOKEN`** — when `BUDA_API_KEY`/`BUDA_API_SECRET` are present but `MCP_AUTH_TOKEN` is not set, the HTTP server now exits with a `FATAL` error at startup instead of silently leaving the `/mcp` endpoint publicly accessible. This closes the opt-in footgun where operators could deploy credentials without a protecting token.
19
+
20
+ - **Rate limiting on `/mcp`** — `express-rate-limit` middleware (120 req/min per IP by default) is applied to `POST /mcp` and `GET /mcp` before auth, preventing looping agents from saturating the Buda API. Configurable via the `MCP_RATE_LIMIT` environment variable.
21
+
22
+ - **Crypto address format validation in `create_withdrawal`** — the `address` field is now validated against per-currency regex rules for BTC, ETH, USDC, USDT, LTC, BCH, and XRP before any API call. Unknown currencies pass through to the exchange. Returns `INVALID_ADDRESS` on failure. Tool description now explicitly warns that crypto withdrawals are irreversible.
23
+
24
+ - **BOLT-11 invoice format validation in `lightning_withdrawal`** — the `invoice` field is now checked against a prefix regex (`/^ln(bc|tb|bcrt)\d/i`) before the API call, rejecting non-invoice strings (e.g. a Bitcoin address pasted by mistake). Zod minimum length tightened from 1 to 50 characters.
25
+
26
+ - **Dead man's switch blocked on HTTP transport** — `schedule_cancel_all` now returns `TRANSPORT_NOT_SUPPORTED` when called via the HTTP server, where a process restart (deploy, crash, autoscale) silently drops all in-memory timers. `renew_cancel_timer` and `disarm_cancel_timer` remain callable. The `register()` function accepts a new `transport: "stdio" | "http"` parameter (default `"stdio"`).
27
+
28
+ ### Added
29
+
30
+ - **Batch orders optional notional cap** — `place_batch_orders` now accepts an optional `max_notional` parameter. If the sum of `amount × limit_price` across all limit orders exceeds the cap, the entire batch is rejected before any API call with `NOTIONAL_CAP_EXCEEDED`. Market orders contribute 0 (execution price unknown).
31
+
32
+ ### Fixed
33
+
34
+ - **Security: path traversal in MCP resource handlers** — `buda://ticker/{market}` and `buda://summary/{market}` resource handlers now call `validateMarketId` before interpolating the parameter into the API URL, preventing path traversal to unintended Buda API endpoints.
35
+ - **Security: bearer token auth for HTTP server** — `src/http.ts` now supports an optional `MCP_AUTH_TOKEN` environment variable. When set, all requests to `/mcp` must include `Authorization: Bearer <token>`. Health check and server-card endpoints remain public.
36
+ - **Bug: NaN propagation in `flattenAmount`** — now throws an explicit error on invalid amount strings instead of silently returning `NaN`.
37
+ - **Bug: nonce collision on concurrent HTTP requests** — `BudaClient` now uses a per-instance counter to guarantee unique nonces even when multiple requests land within the same millisecond.
38
+ - **Bug: `version.ts` crash on missing `package.json`** — `readFileSync` is now wrapped in `try/catch` with fallback `"unknown"` to prevent process crash in deployments without `package.json`.
39
+ - **Bug: incorrect PUT payload in `cancel_order` and `dead_mans_switch`** — body is now `{ order: { state: "canceling" } }` per Buda API Rails convention, matching `cancel_order_by_client_id` and `remittances`.
40
+ - **Bug: `ttl_seconds` bounds not enforced in `handleScheduleCancelAll`** — added explicit validation (10–300, integer) in the handler itself, independent of Zod schema; a negative TTL would previously have fired the timer immediately.
41
+ - **Bug: `gtd_timestamp` not validated in `place_order`** — now checks that the value is a valid ISO 8601 datetime and is in the future before sending it to the API.
42
+ - **Bug: `sma_50` returned incorrect partial average** — `get_technical_indicators` now returns `null` for `sma_50` (with an `sma_50_warning` field) when fewer than 50 candles are available, instead of silently computing an average over fewer points.
43
+ - **Security: `quote_remittance` now requires `confirmation_token="CONFIRM"`** — this tool is non-idempotent (each call creates a new remittance record); the confirmation guard prevents accidental or repeated invocations.
44
+ - **Security: `create_receive_address` now requires `confirmation_token="CONFIRM"`** — this tool is non-idempotent (each call generates a new blockchain address); the confirmation guard prevents accidental repeated calls.
45
+ - **Marketplace docs updated** — `gemini-tools.json`, `claude-listing.md`, `openapi.yaml`, and `README.md` updated to reflect all changes.
46
+ - **Marketplace documentation gap** — `claude-listing.md`, `gemini-tools.json`, and `openapi.yaml` were missing 18 tools that were already implemented and registered in the server. All three files now reflect the full set of 46 tools.
47
+
48
+ ---
49
+
10
50
  ## [1.5.0] – 2026-04-11
11
51
 
12
52
  ### Added
@@ -1,8 +1,6 @@
1
- # Publish Checklist — buda-mcp v1.4.0
1
+ # Publish Checklist — buda-mcp v1.5.1
2
2
 
3
- Steps to publish `v1.4.0` to npm, the MCP registry, and notify community directories.
4
-
5
- > **Important for v1.4.0:** The new `schedule_cancel_all` tool uses in-memory timer state that is lost on server restart. This is prominently documented in the tool description, README auth section, and CHANGELOG. Do NOT encourage users to rely on this tool in hosted/Railway deployments.
3
+ Steps to publish `v1.5.1` to npm, the MCP registry, and notify community directories.
6
4
 
7
5
  ---
8
6
 
@@ -10,13 +8,13 @@ Steps to publish `v1.4.0` to npm, the MCP registry, and notify community directo
10
8
 
11
9
  ```bash
12
10
  # Confirm version
13
- node -e "console.log(require('./package.json').version)" # should print 1.4.0
11
+ node -e "console.log(require('./package.json').version)" # should print 1.5.1
14
12
 
15
13
  # Build and test
16
14
  npm run build
17
15
  npm test
18
16
 
19
- # Sync server.json version (already done, but run again to confirm)
17
+ # Sync server.json version (already done, but confirm)
20
18
  npm run sync-version
21
19
 
22
20
  # Verify no credentials are logged (audit)
@@ -39,58 +37,9 @@ Verify: https://www.npmjs.com/package/@guiie/buda-mcp
39
37
 
40
38
  ## 3. GitHub release
41
39
 
42
- ```bash
43
- git add -A
44
- git commit -m "chore: release v1.4.0
45
-
46
- - simulate_order: live order cost simulation (no order placed, simulation: true)
47
- - calculate_position_size: Kelly-style sizing from capital/risk/entry/stop (client-side)
48
- - get_market_sentiment: composite score -100..+100 from price/volume/spread
49
- - get_technical_indicators: RSI/MACD/BB/SMA20/SMA50 from trade history (no libs)
50
- - schedule_cancel_all + renew_cancel_timer + disarm_cancel_timer: in-memory dead man's switch (auth-gated)
51
- - aggregateTradesToCandles() extracted to utils.ts (shared by price_history + technical_indicators)
52
- - OhlcvCandle interface moved to types.ts
53
- - 59 unit tests (24 new)"
54
-
55
- git tag v1.4.0
56
- git push origin main --tags
57
- ```
58
-
59
- Then create a GitHub Release from the tag:
60
-
61
- ---
62
-
63
- **Release notes template (GitHub):**
64
-
65
- ```
66
- ## buda-mcp v1.4.0 — Trading Tools
67
-
68
- ### 5 new tools
40
+ Tag and release already created via `gh release create v1.5.1`. Verify at:
69
41
 
70
- **`simulate_order`** (public)
71
- Simulates a buy or sell order using live ticker data — no order placed. Returns estimated fill price, fee (actual taker rate from market data: 0.8% crypto / 0.5% stablecoin), total cost, and slippage vs mid. All outputs include simulation: true.
72
-
73
- **`calculate_position_size`** (public)
74
- Kelly-style position sizing from capital, risk %, entry, and stop-loss. Fully client-side. Returns units, capital_at_risk, position_value, fee_impact, and a plain-text risk note.
75
-
76
- **`get_market_sentiment`** (public)
77
- Composite sentiment score (−100 to +100) from price variation 24h (40%), volume vs 7d average (35%), and spread vs market-type baseline (25%). Returns score, label, component breakdown, and disclaimer.
78
-
79
- **`get_technical_indicators`** (public)
80
- RSI (14), MACD (12/26/9), Bollinger Bands (20, 2σ), SMA 20, SMA 50 — computed server-side from Buda trade history with no external libraries. Returns signal interpretations and structured warning if insufficient candles.
81
-
82
- **`schedule_cancel_all` + `renew_cancel_timer` + `disarm_cancel_timer`** (auth-gated)
83
- In-memory dead man's switch: arms a timer that cancels all open orders if not renewed. WARNING: timer state is lost on server restart. Use only on locally-run instances.
84
-
85
- ### Infrastructure
86
- - `aggregateTradesToCandles()` extracted to `utils.ts` — shared by `get_price_history` and `get_technical_indicators`
87
- - `OhlcvCandle` interface exported from `types.ts`
88
- - 59 unit tests (was 35)
89
-
90
- ```bash
91
- npx @guiie/buda-mcp
92
- ```
93
- ```
42
+ https://github.com/gtorreal/buda-mcp/releases/tag/v1.5.1
94
43
 
95
44
  ---
96
45
 
@@ -115,19 +64,20 @@ Verify: https://smithery.ai/server/@guiie/buda-mcp
115
64
  **Email/message template:**
116
65
 
117
66
  ```
118
- Subject: [Update] buda-mcp v1.4.0simulate_order, technical indicators, sentiment, position sizing, dead man's switch
67
+ Subject: [Update] buda-mcp v1.5.1Security hardening release
119
68
 
120
69
  Hi mcp.so team,
121
70
 
122
- I've released v1.4.0 of buda-mcp (@guiie/buda-mcp on npm).
71
+ I've released v1.5.1 of buda-mcp (@guiie/buda-mcp on npm).
123
72
 
124
- Key changes (5 new tools + 3 sub-tools):
125
- - simulate_order: live order cost simulation with actual fee rates (no order placed)
126
- - calculate_position_size: Kelly-style position sizing (fully client-side)
127
- - get_market_sentiment: composite score -100..+100 from price/volume/spread microstructure
128
- - get_technical_indicators: RSI/MACD/Bollinger Bands/SMA (no external libs, from trade history)
129
- - schedule_cancel_all / renew_cancel_timer / disarm_cancel_timer: in-memory dead man's switch (auth-gated)
130
- - 59 unit tests (was 35)
73
+ Key changes (security hardening, no new tools):
74
+ - HTTP startup guard: server exits if credentials are set without MCP_AUTH_TOKEN
75
+ - Rate limiting: 120 req/min per IP on /mcp (configurable via MCP_RATE_LIMIT)
76
+ - Crypto address validation in create_withdrawal (BTC, ETH, USDC, USDT, LTC, BCH, XRP)
77
+ - BOLT-11 invoice format validation in lightning_withdrawal
78
+ - Dead man's switch blocked on HTTP transport (process restarts drop timers)
79
+ - place_batch_orders: optional max_notional spending cap
80
+ - 156 unit tests (was 136)
131
81
 
132
82
  Links:
133
83
  - npm: https://www.npmjs.com/package/@guiie/buda-mcp
@@ -146,23 +96,24 @@ Thank you!
146
96
  **Message template:**
147
97
 
148
98
  ```
149
- Subject: [Update] buda-mcp v1.4.0
99
+ Subject: [Update] buda-mcp v1.5.1
150
100
 
151
101
  Hi Glama team,
152
102
 
153
- buda-mcp has been updated to v1.4.0.
103
+ buda-mcp has been updated to v1.5.1.
154
104
 
155
105
  Package: @guiie/buda-mcp (npm)
156
106
  Registry: io.github.gtorreal/buda-mcp (MCP Registry)
157
- Version: 1.4.0
107
+ Version: 1.5.1
158
108
 
159
- Changes (5 new tools + 3 sub-tools):
160
- - simulate_order: order simulation with live data, simulation: true always set
161
- - calculate_position_size: client-side position sizing
162
- - get_market_sentiment: composite sentiment score with disclaimers
163
- - get_technical_indicators: RSI/MACD/BB/SMA from trade history
164
- - schedule_cancel_all + renew/disarm: in-memory dead man's switch (auth-gated, local use only)
165
- - 59 unit tests
109
+ Changes (security hardening):
110
+ - HTTP startup guard for missing MCP_AUTH_TOKEN
111
+ - Rate limiting on /mcp (120 req/min per IP)
112
+ - Crypto address format validation in create_withdrawal
113
+ - BOLT-11 invoice validation in lightning_withdrawal
114
+ - Dead man's switch blocked on HTTP transport
115
+ - place_batch_orders: optional max_notional cap
116
+ - 156 unit tests
166
117
 
167
118
  Quick start:
168
119
  npx @guiie/buda-mcp
@@ -177,21 +128,22 @@ Thank you!
177
128
 
178
129
  ## 8. Post-publish verification
179
130
 
180
- - [ ] `npx @guiie/buda-mcp@1.4.0` starts successfully
181
- - [ ] `npm info @guiie/buda-mcp version` returns `1.4.0`
182
- - [ ] GitHub release tag `v1.4.0` is visible
183
- - [ ] MCP Registry entry reflects v1.4.0
184
- - [ ] Smithery server card lists 14 public tools (including 4 new: simulate_order, calculate_position_size, get_market_sentiment, get_technical_indicators)
185
- - [ ] Smithery server card lists 7 auth tools (including schedule_cancel_all, renew_cancel_timer, disarm_cancel_timer)
186
- - [ ] `GET /health` returns `"version":"1.4.0"` on Railway deployment
187
- - [ ] simulate_order response includes `simulation: true`
188
- - [ ] get_technical_indicators returns `warning: "insufficient_data"` for markets with few trades
189
- - [ ] schedule_cancel_all requires `confirmation_token="CONFIRM"` (test with wrong token)
131
+ - [ ] `npx @guiie/buda-mcp@1.5.1` starts successfully
132
+ - [ ] `npm info @guiie/buda-mcp version` returns `1.5.1`
133
+ - [ ] GitHub release tag `v1.5.1` is visible
134
+ - [ ] MCP Registry entry reflects v1.5.1
135
+ - [ ] Smithery server card lists all tools
136
+ - [ ] `GET /health` returns `"version":"1.5.1"` on Railway deployment
137
+ - [ ] HTTP server exits if `BUDA_API_KEY` set but `MCP_AUTH_TOKEN` is absent
138
+ - [ ] `create_withdrawal` rejects a truncated BTC address with `INVALID_ADDRESS`
139
+ - [ ] `lightning_withdrawal` rejects a non-BOLT11 string with `INVALID_INVOICE`
140
+ - [ ] `place_batch_orders` with `max_notional` rejects over-cap batch before API call
141
+ - [ ] `schedule_cancel_all` via HTTP returns `TRANSPORT_NOT_SUPPORTED`
190
142
  - [ ] mcp.so listing updated
191
143
  - [ ] Glama.ai listing updated
192
144
 
193
145
  ---
194
146
 
195
- ## ARCHIVED: v1.3.0 checklist
147
+ ## ARCHIVED: previous checklists
196
148
 
197
- See git tag `v1.3.0` for the v1.3.0 release notes and verification steps.
149
+ See git tags `v1.5.0`, `v1.4.0`, `v1.4.1`, `v1.4.2` for previous release notes and verification steps.