MCP Hub
Back to servers

nostr-bray

MCP server giving AI agents sovereign Nostr identities — key derivation, personas, attestations, duress detection, zaps

npm907/wk
Updated
Mar 25, 2026

Quick Install

npx -y nostr-bray

nostr-bray

Sovereign Nostr identities for AI agents

CI npm coverage licence TypeScript

An MCP server that gives AI agents a full Nostr identity — not just a key pair, but a hierarchical identity tree with personas, attestations, ring signatures, encrypted DMs, and duress detection. 77 tools across 10 groups.

The Problem

AI agents interacting with Nostr today are handed a single key pair with no separation of concerns. One compromised session leaks everything. There is no way to rotate keys, prove identity links, or maintain separate personas for different contexts.

nostr-bray solves this with nsec-tree hierarchical derivation. A single master secret generates unlimited child identities, each with its own key pair, purpose, and relay set. Private keys are zeroed from memory on eviction. Agents can switch personas mid-conversation, prove they control the master without revealing the derivation path, and activate a duress identity if compromised.

How It Works

Every tool operates as the "active identity." Derive a persona, switch to it, and everything you do is signed by that persona's key — cryptographically unlinkable to the master unless you publish a proof.

identity-derive-persona("work")    → npub1abc...
identity-switch("work")            → now operating as work persona
social-post("Hello from work!")    → signed by npub1abc...
identity-switch("master")          → back to master
social-post("Back to main")       → signed by master npub

This is not just key management — it is context isolation. Each persona has its own relay set, its own contact list, and its own attestation chain. Compromise one and the others remain intact.

Comparison

Featurenostr-braynaknostr-mcpnostr-tools
MCP server77 toolsvia nak mcp5–23 tools
CLI77 commands✓ (mature)
Hierarchical identity (nsec-tree)
Persona switching
Ring signatures (anonymous proofs)
Shamir backup (BIP-39 words)
Duress detection
NIP-VA attestations (kind 31000)
Linkage proofs (blind/full)
NIP-46 bunker (server + client)✓ (client)partial
NIP-17 encrypted DMs
NWC Lightning payments
Blossom media
NIP-29 groups
Tor routing (SOCKS5h)
329 tests, 96% coverage

Quick Start — CLI

# Post a note to Nostr from your terminal
export NOSTR_SECRET_KEY="nsec1..."
export NOSTR_RELAYS="wss://relay.damus.io,wss://nos.lol"

npx nostr-bray whoami                    # show your npub
npx nostr-bray post "hello from bray!"   # publish a note
npx nostr-bray persona work              # derive a work persona
npx nostr-bray prove blind               # create a linkage proof
npx nostr-bray --help                    # see all commands

Quick Start — MCP Server

Add to your Claude/Cursor/Windsurf MCP config:

{
  "mcpServers": {
    "nostr": {
      "command": "npx",
      "args": ["nostr-bray"],
      "env": {
        "NOSTR_SECRET_KEY": "nsec1...",
        "NOSTR_RELAYS": "wss://relay.damus.io,wss://nos.lol"
      }
    }
  }
}

Or with a secret file (recommended):

{
  "mcpServers": {
    "nostr": {
      "command": "npx",
      "args": ["nostr-bray"],
      "env": {
        "NOSTR_SECRET_KEY_FILE": "/path/to/secret.key",
        "NOSTR_RELAYS": "wss://relay.damus.io,wss://nos.lol"
      }
    }
  }
}

Tool Groups

Identity (12 tools) — create, derive, switch, prove, backup, and migrate Nostr identities

ToolDescription
whoamiReturns the active identity's npub
identity-createGenerate a fresh identity with BIP-39 mnemonic
identity-deriveDerive a child identity by purpose and index
identity-derive-personaDerive a named persona (work, personal, anonymous)
identity-switchSwitch active identity — all tools operate as the new identity
identity-listList all known identities (public info only)
identity-proveCreate blind/full linkage proof
identity-backup-shamirSplit master secret into Shamir shard files
identity-restore-shamirReconstruct secret from shard files
identity-backupFetch profile, contacts, relay list as portable bundle
identity-restoreRe-sign migratable events under the active identity
identity-migrateFull migration with preview, confirmation, and linkage proof

Social (14 tools) — post, reply, react, DM, follow, and read feeds

ToolDescription
social-postPost a text note (kind 1)
social-replyReply with correct e-tag and p-tag threading
social-reactReact to an event (kind 7)
social-deleteRequest deletion of your event (kind 5)
social-repostRepost/boost an event (kind 6)
social-profile-getFetch and parse a kind 0 profile
social-profile-setSet profile with overwrite safety guard
dm-sendSend encrypted DM (NIP-17 default, NIP-04 opt-in)
dm-readRead and decrypt received DMs
contacts-getFetch contact list (kind 3 follows)
contacts-followFollow a pubkey (publishes updated kind 3)
contacts-unfollowUnfollow a pubkey
social-notificationsFetch mentions, replies, reactions, zap receipts
social-feedFetch kind 1 text note feed

Trust (11 tools) — attestations, ring signatures, linkage proofs, spoken verification

ToolDescription
trust-attestCreate kind 31000 verifiable attestation
trust-readRead attestations by subject/type/attestor
trust-verifyValidate attestation structure
trust-revokeRevoke an attestation (identity check)
trust-requestSend attestation request via NIP-17
trust-request-listScan DMs for attestation requests
trust-proof-publishPublish linkage proof (kind 30078) with confirmation
trust-ring-proveAnonymous group membership proof (ring signature)
trust-ring-verifyVerify ring signature proof
trust-spoken-challengeGenerate spoken verification token
trust-spoken-verifyVerify spoken token response

Relay (5 tools) — per-identity relay lists, NIP-65 management, direct queries

ToolDescription
relay-listList relays with shared-relay warnings
relay-setPublish kind 10002 relay list
relay-addAdd relay to active identity (in-memory)
relay-queryQuery events from relays by kind, author, tags, or time range
relay-infoFetch NIP-11 relay information document

Zap (7 tools) — Lightning payments and invoices via Nostr Wallet Connect

ToolDescription
zap-sendPay a Lightning invoice via NWC
zap-balanceRequest wallet balance via NWC
zap-make-invoiceGenerate a Lightning invoice via NWC
zap-lookup-invoiceCheck invoice payment status via NWC
zap-list-transactionsList recent Lightning transactions
zap-receiptsParse zap receipts (amount, sender, message)
zap-decodeDecode bolt11 invoice fields

Safety (2 tools) — duress personas for coercion resistance

ToolDescription
safety-configureConfigure an alternative identity persona
safety-activateSwitch to alternative identity

Blossom (3 tools) — media uploads and management

ToolDescription
blossom-uploadUpload file to a blossom media server
blossom-listList blobs for a pubkey
blossom-deleteDelete a blob by SHA-256 hash

Groups — NIP-29 (4 tools) — group chat, metadata, and membership

ToolDescription
group-infoFetch group metadata
group-chatRead group chat messages
group-sendSend message to a group
group-membersList group members

Community NIPs (2 tools) — publish and read community-proposed NIPs

ToolDescription
nip-publishPublish a community NIP (kind 30817)
nip-readFetch community NIPs

Utility (18 tools) — encode, decode, encrypt, verify, filter, fetch, browse NIPs

ToolDescription
decodeDecode npub/nsec/note/nevent/nprofile/naddr
encode-npubEncode hex pubkey as npub
encode-noteEncode hex event ID as note
encode-nprofileEncode pubkey + relays as nprofile
encode-neventEncode event ID + relays as nevent
encode-naddrEncode addressable event as naddr
encode-nsecEncode hex private key as nsec
key-publicDerive pubkey from secret key
key-encryptEncrypt a secret key with a password (NIP-49 ncryptsec)
key-decryptDecrypt an ncryptsec (NIP-49) with a password
verify-eventVerify event hash and signature
filterTest if an event matches a filter
nip44-encryptNIP-44 encrypt for a recipient
nip44-decryptNIP-44 decrypt from a sender
countCount events matching a filter
fetchFetch events by nip19 code
nip-listList all official NIPs
nip-showShow a specific NIP's content

Configuration

VariableDescription
NOSTR_SECRET_KEYnsec bech32, 64-char hex, or BIP-39 mnemonic
NOSTR_SECRET_KEY_FILEPath to secret key file (takes precedence)
NOSTR_RELAYSComma-separated relay URLs
TOR_PROXYSOCKS5h proxy for Tor (blocks clearnet relays by default)
NIP04_ENABLEDSet 1 to enable legacy NIP-04 DMs
TRANSPORTstdio (default) or http
PORTHTTP port (default 3000)

Documentation

  • Usage Guide — walkthroughs for identity management, DMs, attestations, NWC payments, Tor, and duress
  • Examples — MCP config files (basic, NWC, Tor) and a CLI workflow script
  • Contributing — setup, architecture, testing, and conventions

For AI Assistants

See llms.txt for a concise summary optimised for AI context windows, or llms-full.txt for complete tool documentation with parameter details.

Licence

MIT

Reviews

No reviews yet

Sign in to write a review