bsv-mcp 0.2.15 → 0.3.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 (84) hide show
  1. package/CHANGELOG.md +94 -10
  2. package/README.md +95 -13
  3. package/dist/app.html +483 -106
  4. package/dist/index.js +227724 -117380
  5. package/index.ts +523 -63
  6. package/package.json +24 -15
  7. package/prompts/bsvSdk/auth.ts +1 -1
  8. package/prompts/bsvSdk/cryptography.ts +1 -1
  9. package/prompts/bsvSdk/overview.ts +1 -1
  10. package/prompts/bsvSdk/primitives.ts +1 -1
  11. package/prompts/bsvSdk/script.ts +1 -1
  12. package/prompts/bsvSdk/transaction.ts +1 -1
  13. package/prompts/bsvSdk/wallet.ts +1 -1
  14. package/prompts/ordinals.ts +1 -1
  15. package/tools/a2b/discover.ts +2 -2
  16. package/tools/bap/friend.ts +17 -24
  17. package/tools/bap/generate.test.ts +34 -32
  18. package/tools/bap/generate.ts +48 -43
  19. package/tools/bap/getCurrentAddress.ts +1 -3
  20. package/tools/bap/getId.test.ts +18 -10
  21. package/tools/bap/getId.ts +8 -6
  22. package/tools/bap/utils.ts +1 -1
  23. package/tools/bsocial/bmapReadPosts.ts +16 -2
  24. package/tools/bsocial/createPost.ts +21 -10
  25. package/tools/bsocial/readPosts.ts +10 -4
  26. package/tools/bsv/decodeTransaction.ts +1 -1
  27. package/tools/bsv/explore.ts +0 -4
  28. package/tools/bsv/getPrice.ts +1 -1
  29. package/tools/bsv/token.ts +14 -6
  30. package/tools/constants.ts +6 -2
  31. package/tools/index.ts +22 -13
  32. package/tools/mnee/getBalance.ts +1 -1
  33. package/tools/mnee/parseTx.ts +1 -1
  34. package/tools/mnee/sendMnee.ts +30 -8
  35. package/tools/ordinals/getInscription.ts +1 -3
  36. package/tools/ordinals/getTokenByIdOrTicker.ts +1 -3
  37. package/tools/ordinals/index.ts +4 -1
  38. package/tools/ordinals/marketListings.ts +1 -1
  39. package/tools/ordinals/marketSales.ts +1 -1
  40. package/tools/ordinals/searchInscriptions.ts +1 -1
  41. package/tools/utils/aip.ts +31 -22
  42. package/tools/utils/installAgentMaster.ts +8 -9
  43. package/tools/utils/toolRegistration.ts +21 -22
  44. package/tools/utils/transactionBuilder.ts +21 -14
  45. package/tools/wallet/a2bPublishMcp.ts +15 -5
  46. package/tools/wallet/brc100.ts +567 -312
  47. package/tools/wallet/cancelListing.ts +29 -37
  48. package/tools/wallet/createOrdinals.ts +43 -27
  49. package/tools/wallet/droplit.ts +124 -0
  50. package/tools/wallet/fetchPaymentUtxos.ts +7 -5
  51. package/tools/wallet/gatherCollectionInfo.ts +3 -5
  52. package/tools/wallet/getAddress.ts +1 -4
  53. package/tools/wallet/getBalance.ts +15 -15
  54. package/tools/wallet/{getBalanceDroplet.ts → getBalanceDroplit.ts} +6 -6
  55. package/tools/wallet/getBsv21Balances.ts +20 -14
  56. package/tools/wallet/getLockData.ts +11 -11
  57. package/tools/wallet/getOrdinals.ts +26 -20
  58. package/tools/wallet/integratedWallet.ts +53 -53
  59. package/tools/wallet/listOrdinal.ts +40 -39
  60. package/tools/wallet/listTokens.ts +18 -17
  61. package/tools/wallet/lockBsv.ts +36 -22
  62. package/tools/wallet/mintCollection.ts +15 -10
  63. package/tools/wallet/opnsDeregister.ts +29 -39
  64. package/tools/wallet/opnsRegister.ts +29 -39
  65. package/tools/wallet/purchaseListing.test.ts +27 -0
  66. package/tools/wallet/purchaseListing.ts +59 -40
  67. package/tools/wallet/refreshUtxos.ts +1 -1
  68. package/tools/wallet/schemas.ts +0 -13
  69. package/tools/wallet/sendAllBsv.ts +26 -20
  70. package/tools/wallet/sendBsv.ts +107 -0
  71. package/tools/wallet/setupDroplit.ts +151 -0
  72. package/tools/wallet/signBsm.ts +18 -18
  73. package/tools/wallet/sweepBsv.ts +48 -27
  74. package/tools/wallet/sweepBsv21.ts +42 -28
  75. package/tools/wallet/sweepOrdinals.ts +38 -26
  76. package/tools/wallet/tools.ts +17 -17
  77. package/tools/wallet/transactionHelper.ts +13 -5
  78. package/tools/wallet/transferOrdToken.ts +72 -84
  79. package/tools/wallet/unlockBsv.ts +23 -17
  80. package/tools/wallet/utxo.ts +1 -0
  81. package/tools/wallet/wallet.ts +1 -13
  82. package/test-mcp-server.ts +0 -157
  83. package/tools/wallet/sendToAddress.ts +0 -74
  84. package/tools/wallet/setupDroplet.ts +0 -161
package/CHANGELOG.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # BSV MCP Server Changelog
2
2
 
3
+ ## [0.3.1] - 2026-09-05
4
+
5
+ ### Added
6
+ - Connect an existing BRC-100 HTTP signer without loading local private keys or provisioning wallet storage.
7
+ - Inspect sponsor access and submit sponsored push/fund operations with the connected signer.
8
+
9
+ ### Fixed
10
+ - Preserve wallet permission arguments through MCP schemas.
11
+ - Block automatic HTTP payment during sponsor authentication and avoid ambiguous write retries.
12
+ - Preserve explicitly requested satoshi amounts in legacy Droplit taps.
13
+
14
+ ## [0.3.0] - 2026-07-30
15
+
16
+ ### Breaking Changes
17
+
18
+ - **Spending now requires approval.** `WalletPermissionsManager` was constructed
19
+ with `seekSpendingPermissions: false`, so no spend was ever gated. It is armed,
20
+ and a handler is bound to `onSpendingAuthorizationRequested`. Clients that
21
+ support elicitation prompt the user with the exact satoshi amount and itemised
22
+ line items; approval grants that amount ephemerally. **On a client without
23
+ elicitation support, spends are denied.** The refusal names the amount and the
24
+ reason. This is deliberate — a confirmation gate that silently passes when the
25
+ client cannot be asked is not a gate.
26
+ - `wallet_setupDroplit` is replaced by three tools —
27
+ `wallet_registerDroplitKey`, `wallet_createDroplitFaucet`, and
28
+ `wallet_checkDroplitFaucetStatus`. It had put three unrelated operations behind
29
+ an `action` enum, which made every argument conditional.
30
+ - `wallet_purchaseListing` no longer accepts `description`. The underlying
31
+ purchase actions have no parameter for it, so it was advertised and discarded.
32
+
33
+ ### Security
34
+
35
+ - **`DISABLE_BROADCASTING` did nothing for the tools that move money.** The
36
+ startup banner printed `Broadcasting: Disabled` while the flag reached only the
37
+ BAP tools; `wallet_sendBsv`, `sendAllBsv`, the three sweeps, `purchaseListing`
38
+ and `sendMnee` never received it. Setting the variable, reading "Disabled", and
39
+ calling `wallet_sendBsv` moved real money. Sixteen transaction-submitting tools
40
+ now assert through one guard that reads the same environment variable the
41
+ banner reads.
42
+ - **WIF redaction covered one of three exit paths.** The sweep tools each defined
43
+ a sanitizer commented "sanitize WIF from any error output" and applied it only
44
+ in the `catch`. The `result.error` branch and the serialised success payload
45
+ both returned raw, on tools that take a raw WIF as an argument. One shared
46
+ redactor now covers all three exits in all three tools, and additionally
47
+ catches testnet WIFs and xprvs.
48
+ - The admin originator was the package name, `bsv-mcp` — the exact string a
49
+ caller reaches for when a parameter named `originator` wants a value. Passing
50
+ it would have bypassed the spending gate while the configuration reported it
51
+ armed.
52
+ - Two identity-key paths caught an invalid WIF, logged a warning, and continued
53
+ unsigned. Both now fail.
54
+
55
+ ### Added
56
+
57
+ - Audit log at `~/.bsv-mcp/audit.log` (JSON Lines, directory `0700`, file
58
+ `0600`), routed through the key redactor. A failed write reports to stderr and
59
+ does not break a payment the user already approved.
60
+ - Amount validation on the money-moving tools. `sendBsv`, `sendMnee`, `lockBsv`
61
+ and `listOrdinal` took a bare `z.number()`, so negative, zero and NaN amounts
62
+ reached the SDK; a negative USD amount converted to a negative satoshi count.
63
+
64
+ ### Fixed
65
+
66
+ - `wallet_createOrdinals` accepted `destinationAddress` and never forwarded it,
67
+ so an ordinal minted to a named address silently locked to a wallet-derived
68
+ self key.
69
+ - Droplit authentication was hand-rolled and could never have succeeded. It is
70
+ now BRC-103/104 via `AuthFetch`, verified against the live service.
71
+ - Five packages the code imports were never declared, `zod` among them, so a
72
+ clean install of the published package could not resolve them.
73
+ - The stdio guard was dead code. Its replacement is a first-position side-effect
74
+ import, since ES imports evaluate before any top-level statement.
75
+ - `purchaseListing`'s marketplace-rate arithmetic is a pure function, so a fee
76
+ bug can be told apart from an execution bug.
77
+
78
+ ### Changed
79
+
80
+ - Core SDKs to current: `@modelcontextprotocol/sdk` 1.27.1 → 1.29.0,
81
+ `@modelcontextprotocol/ext-apps` 1.2.0 → 1.7.5, `@1sat/actions` 0.0.41 →
82
+ 0.0.192, `@bsv/sdk` 2.0.6 → 2.2.0, `bsv-bap` 0.1.23 → 0.3.4.
83
+ - `Droplet` is spelled `Droplit` throughout, matching droplit.dev. Environment
84
+ variables are now `DROPLIT_API_URL` and `DROPLIT_FAUCET_NAME`.
85
+ - Test coverage 15 → 45.
86
+
3
87
  ## [0.2.15] - 2026-03-10
4
88
 
5
89
  ### Fixed
@@ -129,29 +213,29 @@
129
213
  - Improved error handling with standardized error types
130
214
  - Better code organization with new utility modules
131
215
 
132
- ## v0.1.0 - Droplet API Integration & Claude Code CLI Support
216
+ ## v0.1.0 - Droplit API Integration & Claude Code CLI Support
133
217
 
134
218
  ### Major Features
135
- - **Droplet API Integration**: Added support for running without local keys using Droplet faucet API
219
+ - **Droplit API Integration**: Added support for running without local keys using Droplit faucet API
136
220
  - New `IntegratedWallet` class supports both local and remote wallet modes
137
- - BSM (Bitcoin Signed Message) authentication for Droplet API communication
138
- - Environment variable configuration: `USE_DROPLET_API`, `DROPLET_API_URL`, `DROPLET_FAUCET_NAME`
139
- - Automatic faucet funding and transaction broadcasting through Droplet service
221
+ - BSM (Bitcoin Signed Message) authentication for Droplit API communication
222
+ - Environment variable configuration: `USE_DROPLIT_API`, `DROPLIT_API_URL`, `DROPLIT_FAUCET_NAME`
223
+ - Automatic faucet funding and transaction broadcasting through Droplit service
140
224
  - **Claude Code CLI Compatibility**: Fixed stdio transport configuration for seamless Claude Code integration
141
225
  - Updated smithery.yaml configuration for proper MCP CLI operation
142
226
  - Enhanced testing and debugging workflows with Claude CLI
143
227
 
144
228
  ### Technical Improvements
145
- - Created `DropletClient` class for robust API communication with go-faucet-api
146
- - Added comprehensive error handling and validation for Droplet operations
229
+ - Created `DroplitClient` class for robust API communication with go-faucet-api
230
+ - Added comprehensive error handling and validation for Droplit operations
147
231
  - Enhanced documentation with testing instructions and troubleshooting guides
148
232
  - Improved dual-mode wallet architecture maintaining backward compatibility
149
233
  - Updated development documentation with detailed testing workflows
150
234
 
151
235
  ### Environment Variables
152
- - `USE_DROPLET_API`: Enable Droplet API mode (default: false)
153
- - `DROPLET_API_URL`: Droplet service endpoint (default: http://localhost:4000)
154
- - `DROPLET_FAUCET_NAME`: Faucet name for API operations (required in Droplet mode)
236
+ - `USE_DROPLIT_API`: Enable Droplit API mode (default: false)
237
+ - `DROPLIT_API_URL`: Droplit service endpoint (default: http://localhost:4000)
238
+ - `DROPLIT_FAUCET_NAME`: Faucet name for API operations (required in Droplit mode)
155
239
  - `TRANSPORT`: MCP transport mode (stdio/http) for Claude Code compatibility
156
240
 
157
241
  ## v0.0.37 - Resource Updates
package/README.md CHANGED
@@ -8,6 +8,51 @@
8
8
 
9
9
  A collection of Bitcoin SV (BSV) tools for the Model Context Protocol (MCP) framework. This library provides wallet, ordinals, and utility functions for BSV blockchain interaction.
10
10
 
11
+ ## Connect an existing BRC-100 signer
12
+
13
+ Set `BRC100_WALLET_URL` to explicitly use an existing wallet through the SDK's
14
+ `HTTPWalletJSON` signer RPC transport. For example, **if your wallet already
15
+ exposes this signer RPC**:
16
+
17
+ ```bash
18
+ BRC100_WALLET_URL=http://127.0.0.1:3321 BRC100_WALLET_ORIGINATOR=bsv-mcp.local bun run index.ts --stdio
19
+ ```
20
+
21
+ `BRC100_WALLET_ORIGINATOR` is optional and defaults to `bsv-mcp.local`; use a
22
+ domain or HTTP(S) origin without credentials, paths, queries or fragments.
23
+ Empty, malformed and `admin.bsv-mcp.internal` origins are rejected. The SDK
24
+ sends the origin as both `Origin` and `Originator` headers in Node/Bun.
25
+ Signer URLs must use HTTPS, or HTTP on loopback (`localhost`, `127.0.0.0/8`,
26
+ `[::1]`), without credentials, queries or fragments. Redirects are rejected.
27
+
28
+ Remove `PRIVATE_KEY_WIF`, `IDENTITY_KEY_WIF`, `DROPLIT_API_URL` and
29
+ `DROPLIT_FAUCET_NAME`, and disable `USE_DROPLIT_API` before enabling this mode:
30
+ explicit conflicting configuration is rejected. Existing local key files are
31
+ left unread. This mode generates no keys, creates no local wallet or storage,
32
+ and provisions no remote storage. Startup performs one identity-public-key
33
+ request with a 10-second timeout. Failure stops startup with a nonzero exit;
34
+ there is no endpoint probing or identity fallback. All signer calls have a
35
+ 10-second timeout and no automatic retries; a timed-out write may have reached
36
+ the signer, so inspect its state before resubmitting.
37
+
38
+ The external wallet remains the permission authority, including spending and
39
+ identity disclosure. Tool arguments (including `seekPermission`) reach it
40
+ without a permission-bypass wrapper or automatic approval. Approve requests
41
+ in your wallet. MCP shutdown does not shut down the signer.
42
+
43
+ Context wallet/BRC-100 tools are available without a legacy wallet. Legacy
44
+ collection minting/gathering, A2B publication, BAP/raw-key, BSocial and MNEE
45
+ tools are unavailable in this mode. `BSV_CHAIN` selects `main` (default) or
46
+ `test`. Existing `ONESAT_API_URL` configures the auxiliary OneSat API clients
47
+ used by context actions; it is separate from the signer URL. Those actions
48
+ still require the corresponding OneSat service capabilities and the signer's
49
+ support for the requested protocol/baskets. Existing tool disable flags apply.
50
+
51
+ **Transport distinction:** `1sat serve wallet` exposes **storage RPC**, not
52
+ the SDK signer RPC. Do not set `BRC100_WALLET_URL` to that storage endpoint.
53
+ This server does not start or supply a signer daemon. Without
54
+ `BRC100_WALLET_URL`, the existing local wallet configuration remains in effect.
55
+
11
56
  ## Installation Options
12
57
 
13
58
  ### Option 1: Claude Code Plugin (Simplest)
@@ -576,34 +621,34 @@ The BSV MCP server can be customized using environment variables to enable or di
576
621
  | `IDENTITY_KEY_WIF` | `not set` | Optional WIF for identity key; if set, ordinals inscriptions will be signed with sigma-protocol for authentication, curation, and web-of-trust. |
577
622
  | `DISABLE_BROADCASTING` | `false` | Set to `true` to disable transaction broadcasting; returns raw transaction hex instead - useful for testing and transaction review before broadcasting |
578
623
 
579
- ### Droplet API Configuration
624
+ ### Droplit API Configuration
580
625
 
581
- The BSV MCP server supports running in Droplet API mode, which allows operation without local private keys by using a remote faucet service:
626
+ The BSV MCP server supports running in Droplit API mode, which allows operation without local private keys by using a remote faucet service:
582
627
 
583
628
  | Environment Variable | Default | Description |
584
629
  | -------------------- | ------- | ----------- |
585
- | `USE_DROPLET_API` | `false` | Set to `true` to enable Droplet API mode for remote wallet operations |
586
- | `DROPLET_API_URL` | `http://localhost:4000` | Base URL for the Droplet faucet API service |
587
- | `DROPLET_FAUCET_NAME` | `not set` | Name of the faucet to use (required when `USE_DROPLET_API` is true) |
630
+ | `USE_DROPLIT_API` | `false` | Set to `true` to enable Droplit API mode for remote wallet operations |
631
+ | `DROPLIT_API_URL` | `http://localhost:4000` | Base URL for the Droplit faucet API service |
632
+ | `DROPLIT_FAUCET_NAME` | `not set` | Name of the faucet to use (required when `USE_DROPLIT_API` is true) |
588
633
  | `TRANSPORT` | `stdio` | MCP transport mode (stdio/http) - automatically set to stdio for Claude Code compatibility |
589
634
 
590
- #### Droplet API Mode
635
+ #### Droplit API Mode
591
636
 
592
- When `USE_DROPLET_API=true` is set, the server operates in remote mode:
637
+ When `USE_DROPLIT_API=true` is set, the server operates in remote mode:
593
638
 
594
639
  - **No Local Keys Required**: The server doesn't need `PRIVATE_KEY_WIF` or local key files
595
- - **Remote Wallet Operations**: Transactions are funded and broadcast through the Droplet API
640
+ - **Remote Wallet Operations**: Transactions are funded and broadcast through the Droplit API
596
641
  - **BSM Authentication**: Uses Bitcoin Signed Message (BSM) authentication for secure API communication
597
642
  - **Automatic Funding**: The faucet automatically provides UTXOs for transactions
598
643
  - **Seamless Integration**: All existing wallet tools work transparently with the remote service
599
644
 
600
- #### Example Droplet Configuration
645
+ #### Example Droplit Configuration
601
646
 
602
647
  ```bash
603
- # Enable Droplet API mode
604
- USE_DROPLET_API=true
605
- DROPLET_API_URL=https://your-droplet-service.com
606
- DROPLET_FAUCET_NAME=your-faucet-name
648
+ # Enable Droplit API mode
649
+ USE_DROPLIT_API=true
650
+ DROPLIT_API_URL=https://your-droplit-service.com
651
+ DROPLIT_FAUCET_NAME=your-faucet-name
607
652
  TRANSPORT=stdio
608
653
  ```
609
654
 
@@ -830,3 +875,40 @@ npm test
830
875
  ## License
831
876
 
832
877
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
878
+
879
+
880
+ ### Use a sponsor with your connected wallet
881
+
882
+ ```sh
883
+ BRC100_WALLET_URL=http://127.0.0.1:3321
884
+ BRC100_WALLET_ORIGINATOR=bsv-mcp.local
885
+ DROPLIT_API_URL=https://api.droplit.dev/droplit
886
+ DROPLIT_FAUCET_NAME=your-sponsor-slug
887
+ ```
888
+
889
+ Set both sponsor values explicitly. The URL includes the server's configured
890
+ base path. Leave `USE_DROPLIT_API` unset: these sponsor tools appear alongside
891
+ normal wallet tools and use the same connected signer identity. Existing local
892
+ BRC-100 wallet contexts also support this sponsor pair. `1sat serve` exposes a
893
+ wallet stack service; it is not itself a BRC-100 signer RPC endpoint.
894
+
895
+ Call `droplit_getAccess` to inspect your own authorization and quotas. An
896
+ `approval_required` response includes a `https://droplit.dev` link for manual
897
+ owner review. Do not automatically open, approve, or register to obtain access.
898
+ Public status and public-key registration do not prove sponsor approval, and
899
+ creating your own faucet requires funding rather than providing free credit.
900
+ Missing quota kinds are unrestricted for authorized users; a configured zero
901
+ count remains denied. Count and transfer quotas exclude a guaranteed miner-fee
902
+ budget.
903
+
904
+ `droplit_push` accepts `data: string[]` and `encoding: "hex" | "utf8"`.
905
+ `droplit_fund` accepts `rawtx` transaction hex and requests sponsor funding and
906
+ broadcast. Both obey broadcasting disable settings and make one client
907
+ submission, with no automatic 402 payment or ambiguous-write retry. Wallet
908
+ signing permissions remain controlled by the configured signer. The API authentication
909
+ facade forwards signer methods but rejects payment creation/signing, so SDK
910
+ BRC-105 payment handling cannot spend funds; a 402 requires human review. Structured
911
+ 401/403/429 errors identify authentication, approval, or quota problems;
912
+ available quota reset information is retained. `unknown_outcome` means reconcile
913
+ transaction/history before retrying; no idempotency-key support is claimed.
914
+ The legacy `USE_DROPLIT_API=true` wallet mode remains available separately.