nectar-mcp
by Synxneuos
README.md
# Nectar π―
**Bitcoin wallets for Buzz agents.**
[Buzz](https://github.com/block/buzz) gives every agent its own Nostr keypair, so it can post, review code and run workflows under its own name. Nectar gives that same keypair a wallet. With it, an agent can:
- **get paid** over Lightning, or with nutzaps from people and other agents
- **pay** Lightning invoices
- **pay other agents** for work, for example "21 sats to @reviewer for the PR review"
- **stay inside limits its human sets**: a cap per payment and a cap per day
There is no account, no API key and no server to run. The wallet is a [NIP-60](https://github.com/nostr-protocol/nips/blob/master/60.md) Cashu wallet stored encrypted on Nostr relays under the agent's own key. Payments between agents are [NIP-61](https://github.com/nostr-protocol/nips/blob/master/61.md) nutzaps. Any NIP-60 wallet that holds the same key can open it.
```
Buzz channel Nostr relays (wallet state)
βββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ
β human: @builder ship itβ β 17375 wallet (encrypted) β
β builder: done β
β β 7375 ecash (encrypted) β
β human: tip it 50 sats ββββ β 7376 history (encrypted) β
βββββββββββββββββββββββββ β β 10019 "pay me here" β
βΌ β 9321 nutzaps β
buzz-acp ββΆ agent ββΆ nectar-mcp βββββΆβββββββββββββββββββββββββββββββββ
(BUZZ_PRIVATE_KEY) β
ββββββββββββΆ Cashu mint ββββΆ Lightning
```
## Tools the agent gets
| Tool | What it does |
| --- | --- |
| `wallet_info` | npub, balance, mint, limits, spent today |
| `wallet_receive_invoice` | make a Lightning invoice so someone can pay the agent |
| `wallet_check_incoming` | collect paid invoices and nutzaps |
| `wallet_pay_invoice` | pay a bolt11 invoice (inside the limits) |
| `wallet_zap` | send sats to an npub as a nutzap, optionally tied to the message being rewarded |
| `wallet_history` | recent payments in and out |
## Use it with Buzz
Requires Node 22 or newer.
```bash
git clone https://github.com/Synxneuos/nectar && cd nectar
npm install
npm link # puts nectar and nectar-mcp on your PATH
```
**Headless agents (`buzz-acp`).** `buzz-acp` starts the MCP server named in `BUZZ_ACP_MCP_COMMAND` and passes it the agent's `BUZZ_PRIVATE_KEY`. So the wallet always belongs to that agent:
```bash
export BUZZ_ACP_MCP_COMMAND="$(which nectar-mcp)"
export NECTAR_MAX_PAYMENT=500 # sats per payment
export NECTAR_DAILY_LIMIT=2000 # sats per UTC day
buzz-acp
```
`BUZZ_ACP_MCP_COMMAND` holds one server. If you already use another one there, run that one through your agent's own MCP config instead.
**Agents in the Buzz desktop app, or any MCP client.** Add Nectar to the agent's MCP servers and give it the agent's key:
```json
{
"mcpServers": {
"nectar": {
"command": "node",
"args": ["/path/to/nectar/bin/nectar-mcp.js"],
"env": {
"BUZZ_PRIVATE_KEY": "nsec1...the agent's key...",
"NECTAR_MAX_PAYMENT": "500",
"NECTAR_DAILY_LIMIT": "2000"
}
}
}
}
```
Then talk to it in a channel: *"@builder, make an invoice for 1000 sats so I can fund you"*, *"@builder, pay @reviewer 21 sats for that review"*.
## Fund and check an agent from the terminal
```bash
export BUZZ_PRIVATE_KEY=nsec1... # the agent's key
nectar info # balance, npub, limits
nectar invoice 1000 "top up" # pay this from any Lightning wallet
nectar collect # claim it
nectar zap npub1... 21 "thanks" # pay someone
nectar history
```
`nectar keygen` makes a throwaway key for trying it out.
## Settings
| Variable | Default | Meaning |
| --- | --- | --- |
| `BUZZ_PRIVATE_KEY` | required | The agent's key (`nsec1...` or hex). `NECTAR_PRIVATE_KEY` overrides it. |
| `NECTAR_MINT` | `https://mint.minibits.cash/Bitcoin` | Cashu mint. It must support NUT-11 (P2PK) and NUT-12 (DLEQ). |
| `NECTAR_RELAYS` | damus, nos.lol, primal | Relays that hold the wallet and receive nutzaps |
| `NECTAR_LOOKUP_RELAYS` | same three | Extra relays searched for a recipient's wallet info |
| `NECTAR_MAX_PAYMENT` | `1000` | Largest single payment in sats, fees included. `0` makes the agent receive-only. |
| `NECTAR_DAILY_LIMIT` | `5000` | Most it may spend per UTC day |
| `NECTAR_DATA_DIR` | `~/.nectar/<pubkey>` | Local state: unpaid invoices, today's spending, unsent events |
The wallet itself is not kept in a Buzz relay. A Buzz relay only stores Buzz's own event kinds, so NIP-60 and NIP-61 events go to ordinary Nostr relays under the same key.
## Safety
- **Limits are set by the human, not the agent.** They come from environment variables the agent cannot change. A refused payment returns a clear message so the agent asks its human instead of retrying.
- **Nothing is lost if a relay is down.** Every event is saved locally before it is published, and kept until a relay accepts it.
- **Nutzaps can't be stolen in transit.** They are locked (P2PK) to the recipient's wallet key and carry DLEQ proofs. The tests check that another key can't claim them.
- **Cashu is custodial.** Until sats are spent or withdrawn, the mint holds them. Keep agent balances small, and choose a mint you trust.
## How it works
| Kind | Purpose |
| --- | --- |
| 17375 | Wallet: the mint list and a separate P2PK key for nutzaps, encrypted to self (NIP-44) |
| 7375 | Unspent ecash, encrypted. Spending publishes a new event with the change and a `del` list, then a kind 5 deletion. |
| 7376 | History of payments in and out, encrypted. Redemptions carry a public `redeemed` tag. |
| 10019 | Tells senders which relays, mint and P2PK key to use |
| 9321 | A nutzap: proofs locked to the recipient's 10019 key |
Wallet operations run one at a time, so two tool calls can never spend the same proofs.
## Tests
```bash
npm test # offline unit tests
NECTAR_TEST_MINT=http://127.0.0.1:3338 npm test
```
The second command also runs the end-to-end tests. They use a local relay and a real Cashu mint (Nutshell with `MINT_BACKEND_BOLT11_SAT=FakeWallet`). They cover two agents funding, nutzapping and paying each other, double-redeem protection, limits, theft resistance, recovering the wallet from relays alone, and the MCP server started the same way `buzz-acp` starts it.
## License
Apache-2.0, the same as Buzz.
This server cannot be deployed
Maintenance
ActivityNo data
ResponsivenessOutdated data