# lightning-memory

Adds persistent memory and payment safety gates for AI agents spending satoshis over the Lightning network via L402.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 9
- Author: singularityjason
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/singularityjason/lightning-memory
- Updated: 2026-03-25
- HTML: https://affpapa.org/en/nevibecode/mcp/lightning-memory

## What it does

Standard coding agents lose payment history once a process terminates. Every session starts clean. As a consequence, agents accept price spikes blindly. This server solves that issue by logging transactions, vendors, and decisions into a local SQLite database powered by FTS5 search.

The server provides 22 callable tools. They evaluate prospective invoices via `ln_preflight` and enforce monthly spend thresholds. Agent identity maps directly to Nostr keypairs under BIP-340, skipping external platform registrations. State sync across nodes runs over Nostr relays using NIP-78 events.

Python 3.10 or higher is required. Running the optional remote HTTP gateway on port 8402 requires the extra `lightning-memory[gateway]` package. Without configured spending limits, the preflight check will not flag suspicious payment requests.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add lightning-memory -- uvx lightning-memory
```
uvx runs the command named after the package; if the README names another one, use uvx --from lightning-memory <command>

### Codex

**Platform CLI**
```bash
codex mcp add lightning-memory -- uvx lightning-memory
```
uvx runs the command named after the package; if the README names another one, use uvx --from lightning-memory <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "lightning-memory": {
            "command": "uvx",
            "args": [
                "lightning-memory"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from lightning-memory <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "lightning-memory": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "lightning-memory"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from lightning-memory <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add lightning-memory uvx lightning-memory
```
uvx runs the command named after the package; if the README names another one, use uvx --from lightning-memory <command>

## When to use it
- halt suspicious Lightning invoices before spending sats
- store agent transaction logs in a local SQLite database
- track vendor history and calculate pricing reputation under L402
- sync agent memory across Nostr relays via NIP-78
- enforce per-vendor daily and monthly payment limits

## Example prompts
- Run `ln_preflight` on a 500 sat payment to bitrefill.com to check my daily budget.
- Check the reputation and average order value for vendor bitrefill.com with `ln_vendor_reputation`.
- Record a new transaction of 500 sats for a gift card using `memory_store`.

## Similar
- [Lightning Wallet](https://affpapa.org/en/nevibecode/mcp/lightning-wallet.md) — MCP server · ★ 10
- [SaturnZap](https://affpapa.org/en/nevibecode/mcp/saturnzap.md) — MCP server · ★ 7
- [invinoveritas](https://affpapa.org/en/nevibecode/mcp/invinoveritas.md) — MCP server
- [emblem-portfolio-tracker](https://affpapa.org/en/nevibecode/skills/emblem-portfolio-tracker.md) — skill · 8900 installs
- [crypto-com-app](https://affpapa.org/en/nevibecode/skills/crypto-com-app.md) — skill · 1400 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
