Skip to main content

A local-first AI agent that runs a business on NOSTR: checks its Lightning wallet, publishes notes and listings, answers encrypted DMs, and pays for paywalled MCP tools over NWC — all under sats budget caps it can't exceed. Drives five MCP servers (nwc-mcp, nostr-ops-mcp, marketplace-mcp, albyhub-admin-mcp, paywall-mcp). Ollama-first, API-pluggable. Built on pydantic-ai — no LangChain. MIT.

Project description

nostr-merchant

The AI that runs your NOSTR business. A local-first Python agent that holds the whole merchant toolkit — it checks its Lightning wallet, publishes notes and listings, runs a Shopstr storefront, answers encrypted DMs, triages its NOSTR inbox to draft and post replies, and pays for paywalled MCP tools over NWC — all under sats budget caps it can't exceed. Built on five MCP servers (nwc-mcp, nostr-ops-mcp, marketplace-mcp, albyhub-admin-mcp, paywall-mcp) — 37 tools the agent picks from.

Ollama-first, API-pluggable. Built on pydantic-ai — no LangChain. MIT.

v0.3 — engagement inbox. Seven CLI commands. nostr-merchant inbox triages replies/mentions on your recent posts and drafts responses in your voice (read-only, language-matched); inbox --post walks each draft (approve / edit / skip), confirms, and publishes the approved ones as NIP-10 replies. The agent layer enforces a budget-and-audit safety pipeline on top of every MCP server's own safety stack; the self-paying-for-tools loop holds end to end given a working LLM backend (Ollama / Anthropic / OpenAI). (Renamed from llmops-agent in v0.2.)


Install

pipx install nostr-merchant          # recommended: isolated CLI
# or:  uvx --from nostr-merchant nostr-merchant --help
# or:  pip install nostr-merchant

The five MCP servers it drives are launched on demand via npx -y — no separate install. You need Python 3.11+, an NWC-compatible wallet (e.g. Alby Hub), and an LLM backend (see Usage).


Status

Layer State
Design doc ✅ Done — ../03-python-reference-agent-design.md
Package scaffold (uv init, pyproject.toml, ruff/mypy/pytest config) ✅ Done
config.py — env-driven Pydantic Settings ✅ Done
budget.py — persistent rolling-window tracker ✅ Done
audit.py — NDJSON writer ✅ Done
mcp_servers.pyMCPServerStdio launch + doctor probe ✅ Done
agent.py — Pydantic AI agent + process_tool_call middleware ✅ Done
workflows/research.py — self-paying research workflow ✅ Done
cli.py — typer entry-point with ask / doctor / budget / audit / config-print / version ✅ Done
Live LLM smoke test (Anthropic Haiku) ✅ Done — end-to-end ask returns a real nwc_get_balance receipt with all 37 substrate tools loaded

Usage

# from this directory, with uv-installed venv
uv run nostr-merchant --help
uv run nostr-merchant version
uv run nostr-merchant budget                # snapshot, no LLM needed
uv run nostr-merchant config-print          # effective config, secrets masked
uv run nostr-merchant doctor                # ping each configured MCP server
uv run nostr-merchant ask "What's my Lightning wallet balance?"   # the main demo loop
uv run nostr-merchant audit --tail 20       # recent audit entries

Or run the whole sequence with the bundled script: ./smoke.sh (full run — the ask is read-only, so it can never move sats) or ./smoke.sh --no-ask (skip the LLM call entirely).

ask requires a working LLM backend, set via NOSTR_MERCHANT_MODEL:

  • anthropic:claude-haiku-4-5-20251001 (or any Anthropic/OpenAI model) — fast, reliable tool-calling. Set ANTHROPIC_API_KEY (or OPENAI_API_KEY) in ~/.nostr-merchant/.env. Recommended for most setups.
  • ollama:<model> — fully local, no KYC, no phone-home (the sovereignty default). Needs Ollama at localhost:11434. Reality check: a 37-tool agent loop wants real hardware — a small model on a CPU-only box is too slow to be practical. Run Ollama on a GPU, or use a hosted model and keep your wallet + keys local (the trust boundary that actually matters).

Provider creds in ~/.nostr-merchant/.env are loaded automatically — no need to export them.


Dev loop

uv sync                 # install deps + dev deps into .venv
uv run ruff check       # lint
uv run mypy             # type check
uv run pytest           # tests

Build wheel for distribution:

uv build

License

MIT — see LICENSE.

Contact

Built by LLMOps.Pro.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nostr_merchant-0.3.3.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nostr_merchant-0.3.3-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file nostr_merchant-0.3.3.tar.gz.

File metadata

  • Download URL: nostr_merchant-0.3.3.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for nostr_merchant-0.3.3.tar.gz
Algorithm Hash digest
SHA256 ea6d5c0276a29bb44b307233dcc82dbe99c0ab056d671dbfe7b2b4d45bc0565f
MD5 1365aa1148f3727e44834b7dec680da8
BLAKE2b-256 67c9f938fb3b18f39fd0e3d84190f23847e2a0456d033c392b8aa0fd5682ca5a

See more details on using hashes here.

File details

Details for the file nostr_merchant-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: nostr_merchant-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for nostr_merchant-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e55b9f6b17fd078e9a4e8661c21b86a67d5c0843abba89dc325c93444e7e9515
MD5 2378e0eb675284f1156d907af758d2e3
BLAKE2b-256 3fd0ee358d62b7ab0e36225c77b1ff2bb8d2bae4e744adc45f38e991185ca39b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page