btctx-mcp 1.2.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.
- btctx_mcp-1.2.0/PKG-INFO +265 -0
- btctx_mcp-1.2.0/README.md +245 -0
- btctx_mcp-1.2.0/btctx_mcp/__init__.py +3 -0
- btctx_mcp-1.2.0/btctx_mcp/__main__.py +3 -0
- btctx_mcp-1.2.0/btctx_mcp/client.py +237 -0
- btctx_mcp-1.2.0/btctx_mcp/guide.py +128 -0
- btctx_mcp-1.2.0/btctx_mcp/server.py +439 -0
- btctx_mcp-1.2.0/btctx_mcp.egg-info/PKG-INFO +265 -0
- btctx_mcp-1.2.0/btctx_mcp.egg-info/SOURCES.txt +18 -0
- btctx_mcp-1.2.0/btctx_mcp.egg-info/dependency_links.txt +1 -0
- btctx_mcp-1.2.0/btctx_mcp.egg-info/entry_points.txt +2 -0
- btctx_mcp-1.2.0/btctx_mcp.egg-info/requires.txt +3 -0
- btctx_mcp-1.2.0/btctx_mcp.egg-info/top_level.txt +1 -0
- btctx_mcp-1.2.0/pyproject.toml +35 -0
- btctx_mcp-1.2.0/setup.cfg +4 -0
- btctx_mcp-1.2.0/tests/test_ai_key_client.py +136 -0
- btctx_mcp-1.2.0/tests/test_client_url.py +25 -0
- btctx_mcp-1.2.0/tests/test_key_file.py +206 -0
- btctx_mcp-1.2.0/tests/test_server.py +291 -0
- btctx_mcp-1.2.0/tests/test_version_notice.py +71 -0
btctx_mcp-1.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: btctx-mcp
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: MCP server that lets an AI assistant add transactions to a BitcoinTX ledger
|
|
5
|
+
Author: BitcoinTX contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://digimonk73.github.io/btctx-site/
|
|
8
|
+
Project-URL: Source, https://github.com/DigiMonk73/BTCTX-MCP
|
|
9
|
+
Project-URL: Documentation, https://github.com/DigiMonk73/BTCTX-MCP/blob/main/mcp_server/README.md
|
|
10
|
+
Project-URL: Changelog, https://github.com/DigiMonk73/BTCTX-MCP/blob/main/docs/CHANGELOG.md
|
|
11
|
+
Keywords: bitcoin,tax,mcp,self-hosted,form-8949
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: mcp<3,>=2.2
|
|
18
|
+
Requires-Dist: httpx>=0.27
|
|
19
|
+
Requires-Dist: pydantic>=2.7
|
|
20
|
+
|
|
21
|
+
# BitcoinTX MCP server
|
|
22
|
+
|
|
23
|
+
Connect an AI assistant (Claude Desktop, Claude Code, or any MCP client) to
|
|
24
|
+
your BitcoinTX ledger. Paste anything, like an exchange confirmation email, a
|
|
25
|
+
wallet's transaction history, a block-explorer page or a CSV snippet, or just
|
|
26
|
+
describe it ("moved 0.05 BTC from River to my Coldcard yesterday, fee was 2k
|
|
27
|
+
sats"). The assistant turns it into transactions, shows you a dry-run preview
|
|
28
|
+
with dedup and the resulting gain/loss, and saves them once you confirm.
|
|
29
|
+
|
|
30
|
+
The server runs **on your computer** and talks to your BitcoinTX instance
|
|
31
|
+
over its normal API with an **AI key**, never your password. The Mac app
|
|
32
|
+
keeps the key in a private file the server reads; with Docker or StartOS you
|
|
33
|
+
create the key in BitcoinTX Settings and paste it into your AI app's
|
|
34
|
+
settings.
|
|
35
|
+
|
|
36
|
+
**What the AI's model sees:** everything the tools return (transactions,
|
|
37
|
+
balances, gains, the review list) and everything you paste into the chat.
|
|
38
|
+
The MCP server itself sends nothing anywhere else. When a preview fills in a
|
|
39
|
+
value, BitcoinTX asks only the price source you chose in Settings → Privacy &
|
|
40
|
+
Network (your own mempool server, public price sites, or nothing), and no
|
|
41
|
+
request names a transaction date. Your AI app sends the conversation to its
|
|
42
|
+
model. With a cloud AI that is the provider's servers;
|
|
43
|
+
see [Privacy: cloud or local model](https://github.com/DigiMonk73/BTCTX-MCP/blob/main/mcp_server/README.md#privacy-cloud-or-local-model).
|
|
44
|
+
|
|
45
|
+
## Tools
|
|
46
|
+
|
|
47
|
+
| Tool | What it does |
|
|
48
|
+
|------|--------------|
|
|
49
|
+
| `get_ledger_guide` | How to map real-world events onto BitcoinTX accounts, types and tax fields |
|
|
50
|
+
| `preview_transactions` | Dry run: validate, auto-fill FMV, flag duplicates, simulate FIFO gains and balances. Saves nothing |
|
|
51
|
+
| `add_transactions` | Save rows, all-or-nothing; exact duplicates are skipped |
|
|
52
|
+
| `list_transactions` | Search by date range, type and account |
|
|
53
|
+
| `update_transaction` / `delete_transaction` | Correct one transaction (the ledger is recalculated). An update can also set `broker_reporting` (which Form 8949 box a sale goes in) and `fee_usd` |
|
|
54
|
+
| `get_portfolio` | Account balances, average cost basis, live BTC price (from the price source chosen in Settings → Privacy & Network), tax timezone |
|
|
55
|
+
| `get_btc_price` | Historical daily or current BTC price |
|
|
56
|
+
| `recalculate_ledger` | Rebuild lots and gains from your transactions (same as Settings → Recalculate Ledger) |
|
|
57
|
+
| `review_ledger` | Read-only list of saved transactions worth a second look (same as Settings → Ledger Review). Changes nothing; fee-value fixes are made in Settings |
|
|
58
|
+
| `backup_ledger` | A copy of the database in BitcoinTX's `backups` folder on your server, as a safety net before a large change (the newest 3 are kept, one a minute). Restoring one is up to you |
|
|
59
|
+
|
|
60
|
+
There is deliberately no bulk delete.
|
|
61
|
+
|
|
62
|
+
## Requirements
|
|
63
|
+
|
|
64
|
+
- BitcoinTX **v1.0.3 or later** on Docker and StartOS (the AI key); the Mac
|
|
65
|
+
app **v0.9.2 or later** (its key file). `backup_ledger` needs v1.0.3.
|
|
66
|
+
Install the server pinned to your BitcoinTX release (`btctx-mcp==X.Y.Z`
|
|
67
|
+
from PyPI; the setup prompt in Settings fills in your version), so your AI
|
|
68
|
+
app runs exactly that version. Versions before 1.2.0 aren't on PyPI: use
|
|
69
|
+
`uvx --from "git+https://github.com/DigiMonk73/BTCTX-MCP.git@vX.Y.Z#subdirectory=mcp_server" btctx-mcp`.
|
|
70
|
+
When the server and your BitcoinTX are different versions, every tool
|
|
71
|
+
reply starts with a line saying so and what to change.
|
|
72
|
+
- Python 3.10+ on the machine running your AI client
|
|
73
|
+
|
|
74
|
+
## Quick setup: let your AI do it
|
|
75
|
+
|
|
76
|
+
In BitcoinTX, open **Settings → Connect an AI Assistant** and copy the setup
|
|
77
|
+
prompt into your AI app. It carries your address and points the AI to
|
|
78
|
+
[AI_SETUP.md](https://github.com/DigiMonk73/BTCTX-MCP/blob/main/mcp_server/AI_SETUP.md), which tells it how to install the server in
|
|
79
|
+
Claude Code, Claude Desktop, Grok Build or another MCP client. On Docker and
|
|
80
|
+
StartOS, create the AI key in the same section first; it stays out of the
|
|
81
|
+
chat: the AI writes `YOUR_BITCOINTX_AI_KEY` and you paste the key into the
|
|
82
|
+
configuration file. The section also has the Claude Desktop config and
|
|
83
|
+
`claude mcp add` command (and, for the Mac app, a Grok Build command) ready
|
|
84
|
+
to paste if you'd rather do it yourself.
|
|
85
|
+
|
|
86
|
+
The AI app has to run on your computer (or on your network, for Docker and
|
|
87
|
+
StartOS): cloud-hosted assistants such as Grok Bot can't reach BitcoinTX.
|
|
88
|
+
Running on your computer doesn't make the AI's model local, though: read the
|
|
89
|
+
next section before you connect a cloud AI.
|
|
90
|
+
|
|
91
|
+
## Privacy: cloud or local model
|
|
92
|
+
|
|
93
|
+
An MCP server gives the AI your data to read. Here that means your
|
|
94
|
+
transaction history, balances, cost basis and gains, plus whatever you paste
|
|
95
|
+
(exchange emails, wallet histories, addresses, txids). Where it goes depends
|
|
96
|
+
on the model behind your AI app, not on this server:
|
|
97
|
+
|
|
98
|
+
- **Cloud AI** (Claude Desktop, Claude Code, Grok Build and most others): the
|
|
99
|
+
conversation, tool results included, is sent to the provider's servers and
|
|
100
|
+
handled under its privacy terms. Your AI key is not sent: it stays in the
|
|
101
|
+
configuration on your computer.
|
|
102
|
+
- **Local model:** what the AI reads stays on your machine. BitcoinTX itself
|
|
103
|
+
asks only the price source you chose (your own mempool server or public
|
|
104
|
+
price sites; Settings → Privacy & Network). Use an app that runs MCP
|
|
105
|
+
servers with a model on your own machine, for example
|
|
106
|
+
[LM Studio](https://lmstudio.ai/docs/app/mcp) (0.3.17 or later) or
|
|
107
|
+
[Goose](https://goose-docs.ai/) with [Ollama](https://ollama.com/).
|
|
108
|
+
|
|
109
|
+
Access: **Settings → Connect an AI Assistant → Let AI assistants use
|
|
110
|
+
BitcoinTX** is off by default on every edition: nothing can use the key until
|
|
111
|
+
you turn it on. Turn it off, or revoke the key (Docker, StartOS), to stop the
|
|
112
|
+
AI.
|
|
113
|
+
|
|
114
|
+
If you want BitcoinTX's data to stay private, use a local model, or use a
|
|
115
|
+
cloud AI only with a test ledger. Keeping a cloud AI away from real data
|
|
116
|
+
isn't something BitcoinTX can enforce once it's connected.
|
|
117
|
+
|
|
118
|
+
### Using a local model
|
|
119
|
+
|
|
120
|
+
Pick a model that handles tool calls well (for example a recent Qwen model
|
|
121
|
+
of 8B parameters or more) and give it a context window of at least 16K tokens:
|
|
122
|
+
the ledger guide and tool results don't fit in Ollama's small default.
|
|
123
|
+
Smaller models make more mistakes, so read every preview before you confirm.
|
|
124
|
+
|
|
125
|
+
**LM Studio:** Program tab → Install → Edit `mcp.json`, and add the same block
|
|
126
|
+
as for Claude Desktop (below). For the Mac app:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"mcpServers": {
|
|
131
|
+
"bitcointx": {
|
|
132
|
+
"command": "uvx",
|
|
133
|
+
"args": ["btctx-mcp==X.Y.Z"]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Use the full path from `which uvx` if LM Studio can't find it. For Docker or
|
|
140
|
+
StartOS add the `env` block with `BTCTX_URL` and `BTCTX_AI_KEY` (see
|
|
141
|
+
Configure).
|
|
142
|
+
|
|
143
|
+
**Goose:** `goose configure` → choose Ollama as the provider; then
|
|
144
|
+
`goose configure` → Add Extension → Command-line Extension, with the command
|
|
145
|
+
`uvx btctx-mcp==X.Y.Z`
|
|
146
|
+
(and `BTCTX_URL` and `BTCTX_AI_KEY` for Docker or StartOS).
|
|
147
|
+
|
|
148
|
+
## Install
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
uvx btctx-mcp==X.Y.Z # your BitcoinTX version; nothing to install
|
|
152
|
+
pip install btctx-mcp==X.Y.Z # or a btctx-mcp command of your own
|
|
153
|
+
pip install ./mcp_server # or from a clone of the repo
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Configure
|
|
157
|
+
|
|
158
|
+
**The BitcoinTX Mac app (0.9.2+): nothing to configure.** With no
|
|
159
|
+
`BTCTX_AI_KEY` set, the server reads
|
|
160
|
+
`~/Library/Application Support/BitcoinTX/mcp.json`, which the app writes when
|
|
161
|
+
it starts (owner-only): its address and the AI key, never your password.
|
|
162
|
+
Turn on **Settings → Connect an AI Assistant → Let AI assistants use
|
|
163
|
+
BitcoinTX** first (off by default), and keep BitcoinTX open while you use
|
|
164
|
+
the AI. The same section turns access off again or resets the key (the
|
|
165
|
+
server picks up a new key by itself). `BTCTX_MCP_FILE` points at another
|
|
166
|
+
file.
|
|
167
|
+
|
|
168
|
+
**Docker, StartOS, or from source:** in BitcoinTX, **Settings → Connect an
|
|
169
|
+
AI Assistant**, turn on **Let AI assistants use BitcoinTX** and click
|
|
170
|
+
**Create AI key** (it's shown once; **New key** replaces it, **Revoke**
|
|
171
|
+
deletes it).
|
|
172
|
+
|
|
173
|
+
| Variable | Meaning |
|
|
174
|
+
|----------|---------|
|
|
175
|
+
| `BTCTX_URL` | Where BitcoinTX is reachable: Docker the host and port you published, e.g. `http://localhost:8080` or `http://192.168.1.50:8080`; StartOS the **MCP API** address from the service's Interfaces (`https://….local/api`; the **Connect an AI Assistant** action shows it with a ready-made config); from source `http://localhost:8000` |
|
|
176
|
+
| `BTCTX_AI_KEY` | The AI key. Put it in the configuration file, not in a chat or a shell command (which stays in the history) |
|
|
177
|
+
| `BTCTX_VERIFY_TLS` | `false` to accept a self-signed certificate (StartOS `.local` addresses) |
|
|
178
|
+
| `BTCTX_CA_BUNDLE` | Or: path to the CA certificate that signed it (StartOS lets you download its root CA). Safer than disabling verification |
|
|
179
|
+
|
|
180
|
+
`BTCTX_USERNAME` and `BTCTX_PASSWORD` are no longer used. While
|
|
181
|
+
`BTCTX_PASSWORD` is set, every tool answers with how to switch to a key and
|
|
182
|
+
sends nothing; after switching, change your BitcoinTX password, since the old
|
|
183
|
+
one sat in that file.
|
|
184
|
+
|
|
185
|
+
### Claude Desktop
|
|
186
|
+
|
|
187
|
+
Settings → Developer → Edit Config (`claude_desktop_config.json`):
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"mcpServers": {
|
|
192
|
+
"bitcointx": {
|
|
193
|
+
"command": "btctx-mcp",
|
|
194
|
+
"env": {
|
|
195
|
+
"BTCTX_URL": "http://192.168.1.50:8080",
|
|
196
|
+
"BTCTX_AI_KEY": "YOUR_BITCOINTX_AI_KEY"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
If Claude Desktop can't find `btctx-mcp`, use the full path from `which btctx-mcp`.
|
|
204
|
+
|
|
205
|
+
**macOS desktop app:** leave out `env` entirely:
|
|
206
|
+
`{"mcpServers": {"bitcointx": {"command": "btctx-mcp"}}}`. The server finds the
|
|
207
|
+
running app and its key by itself.
|
|
208
|
+
|
|
209
|
+
### Claude Code
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
claude mcp add --scope user bitcointx \
|
|
213
|
+
-e BTCTX_URL=http://192.168.1.50:8080 -e BTCTX_AI_KEY=YOUR_BITCOINTX_AI_KEY \
|
|
214
|
+
-- btctx-mcp
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Then paste your key over the placeholder in `~/.claude.json`
|
|
218
|
+
(`mcpServers.bitcointx.env`), so it never goes into your shell history.
|
|
219
|
+
|
|
220
|
+
## Using it
|
|
221
|
+
|
|
222
|
+
> Here's my River email: "You bought 0.00231 BTC for $150.00 (fee $1.49) on Mar 3"
|
|
223
|
+
|
|
224
|
+
> I withdrew everything from River to my Trezor on March 10, network fee 1,800 sats
|
|
225
|
+
|
|
226
|
+
> Got paid 250k sats for a logo design on 2024-05-02, went straight to cold storage
|
|
227
|
+
|
|
228
|
+
The assistant asks when something tax-relevant is ambiguous (is that address
|
|
229
|
+
your own wallet or someone else's? bank-funded or from your River cash
|
|
230
|
+
balance?), previews, then saves once you confirm. Your AI client will also ask
|
|
231
|
+
you to approve each tool call unless you tell it not to.
|
|
232
|
+
|
|
233
|
+
## Security notes
|
|
234
|
+
|
|
235
|
+
- **What the AI key can do:** read the ledger, add, change or delete single
|
|
236
|
+
transactions, recalculate, and make a backup copy on the server
|
|
237
|
+
(`backup_ledger`). Only while AI access is on.
|
|
238
|
+
- **What it can't do** (BitcoinTX answers 403): log in, change your username
|
|
239
|
+
or password, create or revoke keys, turn AI access on or off, restore or
|
|
240
|
+
download a backup, export or import files, delete everything, apply Ledger
|
|
241
|
+
Review fixes, change settings, or open reports.
|
|
242
|
+
- Mac app: the key sits in `mcp.json`, readable only by you, and works only
|
|
243
|
+
from this computer. Settings → Connect an AI Assistant turns access off or
|
|
244
|
+
resets the key.
|
|
245
|
+
- Docker/StartOS: the key sits in your AI app's configuration on your
|
|
246
|
+
computer; anyone who can read that file can do what the key allows. Revoke
|
|
247
|
+
it or make a new one in Settings → Connect an AI Assistant. BitcoinTX stores
|
|
248
|
+
only a hash of it, and restoring a backup never brings back an old key.
|
|
249
|
+
- With a cloud AI, what the tools return goes to the provider (see
|
|
250
|
+
[Privacy](https://github.com/DigiMonk73/BTCTX-MCP/blob/main/mcp_server/README.md#privacy-cloud-or-local-model)).
|
|
251
|
+
- There is no bulk delete, and every write is visible in BitcoinTX. Before a
|
|
252
|
+
large import, have the AI run `backup_ledger` or take a backup yourself
|
|
253
|
+
(Settings → Backup & Restore, or `scripts/backup-db.sh` on a server).
|
|
254
|
+
|
|
255
|
+
## Development
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# from the repo root
|
|
259
|
+
pip install -r backend/requirements.txt -r requirements-dev.txt ./mcp_server
|
|
260
|
+
mkdir -p frontend/dist
|
|
261
|
+
pytest mcp_server/tests backend/tests/test_entry_import.py
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The tests run an MCP client against this server, which calls the real FastAPI
|
|
265
|
+
app in-process on a temporary database. Price lookups are stubbed.
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# BitcoinTX MCP server
|
|
2
|
+
|
|
3
|
+
Connect an AI assistant (Claude Desktop, Claude Code, or any MCP client) to
|
|
4
|
+
your BitcoinTX ledger. Paste anything, like an exchange confirmation email, a
|
|
5
|
+
wallet's transaction history, a block-explorer page or a CSV snippet, or just
|
|
6
|
+
describe it ("moved 0.05 BTC from River to my Coldcard yesterday, fee was 2k
|
|
7
|
+
sats"). The assistant turns it into transactions, shows you a dry-run preview
|
|
8
|
+
with dedup and the resulting gain/loss, and saves them once you confirm.
|
|
9
|
+
|
|
10
|
+
The server runs **on your computer** and talks to your BitcoinTX instance
|
|
11
|
+
over its normal API with an **AI key**, never your password. The Mac app
|
|
12
|
+
keeps the key in a private file the server reads; with Docker or StartOS you
|
|
13
|
+
create the key in BitcoinTX Settings and paste it into your AI app's
|
|
14
|
+
settings.
|
|
15
|
+
|
|
16
|
+
**What the AI's model sees:** everything the tools return (transactions,
|
|
17
|
+
balances, gains, the review list) and everything you paste into the chat.
|
|
18
|
+
The MCP server itself sends nothing anywhere else. When a preview fills in a
|
|
19
|
+
value, BitcoinTX asks only the price source you chose in Settings → Privacy &
|
|
20
|
+
Network (your own mempool server, public price sites, or nothing), and no
|
|
21
|
+
request names a transaction date. Your AI app sends the conversation to its
|
|
22
|
+
model. With a cloud AI that is the provider's servers;
|
|
23
|
+
see [Privacy: cloud or local model](https://github.com/DigiMonk73/BTCTX-MCP/blob/main/mcp_server/README.md#privacy-cloud-or-local-model).
|
|
24
|
+
|
|
25
|
+
## Tools
|
|
26
|
+
|
|
27
|
+
| Tool | What it does |
|
|
28
|
+
|------|--------------|
|
|
29
|
+
| `get_ledger_guide` | How to map real-world events onto BitcoinTX accounts, types and tax fields |
|
|
30
|
+
| `preview_transactions` | Dry run: validate, auto-fill FMV, flag duplicates, simulate FIFO gains and balances. Saves nothing |
|
|
31
|
+
| `add_transactions` | Save rows, all-or-nothing; exact duplicates are skipped |
|
|
32
|
+
| `list_transactions` | Search by date range, type and account |
|
|
33
|
+
| `update_transaction` / `delete_transaction` | Correct one transaction (the ledger is recalculated). An update can also set `broker_reporting` (which Form 8949 box a sale goes in) and `fee_usd` |
|
|
34
|
+
| `get_portfolio` | Account balances, average cost basis, live BTC price (from the price source chosen in Settings → Privacy & Network), tax timezone |
|
|
35
|
+
| `get_btc_price` | Historical daily or current BTC price |
|
|
36
|
+
| `recalculate_ledger` | Rebuild lots and gains from your transactions (same as Settings → Recalculate Ledger) |
|
|
37
|
+
| `review_ledger` | Read-only list of saved transactions worth a second look (same as Settings → Ledger Review). Changes nothing; fee-value fixes are made in Settings |
|
|
38
|
+
| `backup_ledger` | A copy of the database in BitcoinTX's `backups` folder on your server, as a safety net before a large change (the newest 3 are kept, one a minute). Restoring one is up to you |
|
|
39
|
+
|
|
40
|
+
There is deliberately no bulk delete.
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
- BitcoinTX **v1.0.3 or later** on Docker and StartOS (the AI key); the Mac
|
|
45
|
+
app **v0.9.2 or later** (its key file). `backup_ledger` needs v1.0.3.
|
|
46
|
+
Install the server pinned to your BitcoinTX release (`btctx-mcp==X.Y.Z`
|
|
47
|
+
from PyPI; the setup prompt in Settings fills in your version), so your AI
|
|
48
|
+
app runs exactly that version. Versions before 1.2.0 aren't on PyPI: use
|
|
49
|
+
`uvx --from "git+https://github.com/DigiMonk73/BTCTX-MCP.git@vX.Y.Z#subdirectory=mcp_server" btctx-mcp`.
|
|
50
|
+
When the server and your BitcoinTX are different versions, every tool
|
|
51
|
+
reply starts with a line saying so and what to change.
|
|
52
|
+
- Python 3.10+ on the machine running your AI client
|
|
53
|
+
|
|
54
|
+
## Quick setup: let your AI do it
|
|
55
|
+
|
|
56
|
+
In BitcoinTX, open **Settings → Connect an AI Assistant** and copy the setup
|
|
57
|
+
prompt into your AI app. It carries your address and points the AI to
|
|
58
|
+
[AI_SETUP.md](https://github.com/DigiMonk73/BTCTX-MCP/blob/main/mcp_server/AI_SETUP.md), which tells it how to install the server in
|
|
59
|
+
Claude Code, Claude Desktop, Grok Build or another MCP client. On Docker and
|
|
60
|
+
StartOS, create the AI key in the same section first; it stays out of the
|
|
61
|
+
chat: the AI writes `YOUR_BITCOINTX_AI_KEY` and you paste the key into the
|
|
62
|
+
configuration file. The section also has the Claude Desktop config and
|
|
63
|
+
`claude mcp add` command (and, for the Mac app, a Grok Build command) ready
|
|
64
|
+
to paste if you'd rather do it yourself.
|
|
65
|
+
|
|
66
|
+
The AI app has to run on your computer (or on your network, for Docker and
|
|
67
|
+
StartOS): cloud-hosted assistants such as Grok Bot can't reach BitcoinTX.
|
|
68
|
+
Running on your computer doesn't make the AI's model local, though: read the
|
|
69
|
+
next section before you connect a cloud AI.
|
|
70
|
+
|
|
71
|
+
## Privacy: cloud or local model
|
|
72
|
+
|
|
73
|
+
An MCP server gives the AI your data to read. Here that means your
|
|
74
|
+
transaction history, balances, cost basis and gains, plus whatever you paste
|
|
75
|
+
(exchange emails, wallet histories, addresses, txids). Where it goes depends
|
|
76
|
+
on the model behind your AI app, not on this server:
|
|
77
|
+
|
|
78
|
+
- **Cloud AI** (Claude Desktop, Claude Code, Grok Build and most others): the
|
|
79
|
+
conversation, tool results included, is sent to the provider's servers and
|
|
80
|
+
handled under its privacy terms. Your AI key is not sent: it stays in the
|
|
81
|
+
configuration on your computer.
|
|
82
|
+
- **Local model:** what the AI reads stays on your machine. BitcoinTX itself
|
|
83
|
+
asks only the price source you chose (your own mempool server or public
|
|
84
|
+
price sites; Settings → Privacy & Network). Use an app that runs MCP
|
|
85
|
+
servers with a model on your own machine, for example
|
|
86
|
+
[LM Studio](https://lmstudio.ai/docs/app/mcp) (0.3.17 or later) or
|
|
87
|
+
[Goose](https://goose-docs.ai/) with [Ollama](https://ollama.com/).
|
|
88
|
+
|
|
89
|
+
Access: **Settings → Connect an AI Assistant → Let AI assistants use
|
|
90
|
+
BitcoinTX** is off by default on every edition: nothing can use the key until
|
|
91
|
+
you turn it on. Turn it off, or revoke the key (Docker, StartOS), to stop the
|
|
92
|
+
AI.
|
|
93
|
+
|
|
94
|
+
If you want BitcoinTX's data to stay private, use a local model, or use a
|
|
95
|
+
cloud AI only with a test ledger. Keeping a cloud AI away from real data
|
|
96
|
+
isn't something BitcoinTX can enforce once it's connected.
|
|
97
|
+
|
|
98
|
+
### Using a local model
|
|
99
|
+
|
|
100
|
+
Pick a model that handles tool calls well (for example a recent Qwen model
|
|
101
|
+
of 8B parameters or more) and give it a context window of at least 16K tokens:
|
|
102
|
+
the ledger guide and tool results don't fit in Ollama's small default.
|
|
103
|
+
Smaller models make more mistakes, so read every preview before you confirm.
|
|
104
|
+
|
|
105
|
+
**LM Studio:** Program tab → Install → Edit `mcp.json`, and add the same block
|
|
106
|
+
as for Claude Desktop (below). For the Mac app:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"mcpServers": {
|
|
111
|
+
"bitcointx": {
|
|
112
|
+
"command": "uvx",
|
|
113
|
+
"args": ["btctx-mcp==X.Y.Z"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Use the full path from `which uvx` if LM Studio can't find it. For Docker or
|
|
120
|
+
StartOS add the `env` block with `BTCTX_URL` and `BTCTX_AI_KEY` (see
|
|
121
|
+
Configure).
|
|
122
|
+
|
|
123
|
+
**Goose:** `goose configure` → choose Ollama as the provider; then
|
|
124
|
+
`goose configure` → Add Extension → Command-line Extension, with the command
|
|
125
|
+
`uvx btctx-mcp==X.Y.Z`
|
|
126
|
+
(and `BTCTX_URL` and `BTCTX_AI_KEY` for Docker or StartOS).
|
|
127
|
+
|
|
128
|
+
## Install
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
uvx btctx-mcp==X.Y.Z # your BitcoinTX version; nothing to install
|
|
132
|
+
pip install btctx-mcp==X.Y.Z # or a btctx-mcp command of your own
|
|
133
|
+
pip install ./mcp_server # or from a clone of the repo
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Configure
|
|
137
|
+
|
|
138
|
+
**The BitcoinTX Mac app (0.9.2+): nothing to configure.** With no
|
|
139
|
+
`BTCTX_AI_KEY` set, the server reads
|
|
140
|
+
`~/Library/Application Support/BitcoinTX/mcp.json`, which the app writes when
|
|
141
|
+
it starts (owner-only): its address and the AI key, never your password.
|
|
142
|
+
Turn on **Settings → Connect an AI Assistant → Let AI assistants use
|
|
143
|
+
BitcoinTX** first (off by default), and keep BitcoinTX open while you use
|
|
144
|
+
the AI. The same section turns access off again or resets the key (the
|
|
145
|
+
server picks up a new key by itself). `BTCTX_MCP_FILE` points at another
|
|
146
|
+
file.
|
|
147
|
+
|
|
148
|
+
**Docker, StartOS, or from source:** in BitcoinTX, **Settings → Connect an
|
|
149
|
+
AI Assistant**, turn on **Let AI assistants use BitcoinTX** and click
|
|
150
|
+
**Create AI key** (it's shown once; **New key** replaces it, **Revoke**
|
|
151
|
+
deletes it).
|
|
152
|
+
|
|
153
|
+
| Variable | Meaning |
|
|
154
|
+
|----------|---------|
|
|
155
|
+
| `BTCTX_URL` | Where BitcoinTX is reachable: Docker the host and port you published, e.g. `http://localhost:8080` or `http://192.168.1.50:8080`; StartOS the **MCP API** address from the service's Interfaces (`https://….local/api`; the **Connect an AI Assistant** action shows it with a ready-made config); from source `http://localhost:8000` |
|
|
156
|
+
| `BTCTX_AI_KEY` | The AI key. Put it in the configuration file, not in a chat or a shell command (which stays in the history) |
|
|
157
|
+
| `BTCTX_VERIFY_TLS` | `false` to accept a self-signed certificate (StartOS `.local` addresses) |
|
|
158
|
+
| `BTCTX_CA_BUNDLE` | Or: path to the CA certificate that signed it (StartOS lets you download its root CA). Safer than disabling verification |
|
|
159
|
+
|
|
160
|
+
`BTCTX_USERNAME` and `BTCTX_PASSWORD` are no longer used. While
|
|
161
|
+
`BTCTX_PASSWORD` is set, every tool answers with how to switch to a key and
|
|
162
|
+
sends nothing; after switching, change your BitcoinTX password, since the old
|
|
163
|
+
one sat in that file.
|
|
164
|
+
|
|
165
|
+
### Claude Desktop
|
|
166
|
+
|
|
167
|
+
Settings → Developer → Edit Config (`claude_desktop_config.json`):
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"mcpServers": {
|
|
172
|
+
"bitcointx": {
|
|
173
|
+
"command": "btctx-mcp",
|
|
174
|
+
"env": {
|
|
175
|
+
"BTCTX_URL": "http://192.168.1.50:8080",
|
|
176
|
+
"BTCTX_AI_KEY": "YOUR_BITCOINTX_AI_KEY"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
If Claude Desktop can't find `btctx-mcp`, use the full path from `which btctx-mcp`.
|
|
184
|
+
|
|
185
|
+
**macOS desktop app:** leave out `env` entirely:
|
|
186
|
+
`{"mcpServers": {"bitcointx": {"command": "btctx-mcp"}}}`. The server finds the
|
|
187
|
+
running app and its key by itself.
|
|
188
|
+
|
|
189
|
+
### Claude Code
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
claude mcp add --scope user bitcointx \
|
|
193
|
+
-e BTCTX_URL=http://192.168.1.50:8080 -e BTCTX_AI_KEY=YOUR_BITCOINTX_AI_KEY \
|
|
194
|
+
-- btctx-mcp
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Then paste your key over the placeholder in `~/.claude.json`
|
|
198
|
+
(`mcpServers.bitcointx.env`), so it never goes into your shell history.
|
|
199
|
+
|
|
200
|
+
## Using it
|
|
201
|
+
|
|
202
|
+
> Here's my River email: "You bought 0.00231 BTC for $150.00 (fee $1.49) on Mar 3"
|
|
203
|
+
|
|
204
|
+
> I withdrew everything from River to my Trezor on March 10, network fee 1,800 sats
|
|
205
|
+
|
|
206
|
+
> Got paid 250k sats for a logo design on 2024-05-02, went straight to cold storage
|
|
207
|
+
|
|
208
|
+
The assistant asks when something tax-relevant is ambiguous (is that address
|
|
209
|
+
your own wallet or someone else's? bank-funded or from your River cash
|
|
210
|
+
balance?), previews, then saves once you confirm. Your AI client will also ask
|
|
211
|
+
you to approve each tool call unless you tell it not to.
|
|
212
|
+
|
|
213
|
+
## Security notes
|
|
214
|
+
|
|
215
|
+
- **What the AI key can do:** read the ledger, add, change or delete single
|
|
216
|
+
transactions, recalculate, and make a backup copy on the server
|
|
217
|
+
(`backup_ledger`). Only while AI access is on.
|
|
218
|
+
- **What it can't do** (BitcoinTX answers 403): log in, change your username
|
|
219
|
+
or password, create or revoke keys, turn AI access on or off, restore or
|
|
220
|
+
download a backup, export or import files, delete everything, apply Ledger
|
|
221
|
+
Review fixes, change settings, or open reports.
|
|
222
|
+
- Mac app: the key sits in `mcp.json`, readable only by you, and works only
|
|
223
|
+
from this computer. Settings → Connect an AI Assistant turns access off or
|
|
224
|
+
resets the key.
|
|
225
|
+
- Docker/StartOS: the key sits in your AI app's configuration on your
|
|
226
|
+
computer; anyone who can read that file can do what the key allows. Revoke
|
|
227
|
+
it or make a new one in Settings → Connect an AI Assistant. BitcoinTX stores
|
|
228
|
+
only a hash of it, and restoring a backup never brings back an old key.
|
|
229
|
+
- With a cloud AI, what the tools return goes to the provider (see
|
|
230
|
+
[Privacy](https://github.com/DigiMonk73/BTCTX-MCP/blob/main/mcp_server/README.md#privacy-cloud-or-local-model)).
|
|
231
|
+
- There is no bulk delete, and every write is visible in BitcoinTX. Before a
|
|
232
|
+
large import, have the AI run `backup_ledger` or take a backup yourself
|
|
233
|
+
(Settings → Backup & Restore, or `scripts/backup-db.sh` on a server).
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# from the repo root
|
|
239
|
+
pip install -r backend/requirements.txt -r requirements-dev.txt ./mcp_server
|
|
240
|
+
mkdir -p frontend/dist
|
|
241
|
+
pytest mcp_server/tests backend/tests/test_entry_import.py
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
The tests run an MCP client against this server, which calls the real FastAPI
|
|
245
|
+
app in-process on a temporary database. Price lookups are stubbed.
|