bray — Claude Code MCP server: what it does, how to install
Connects Claude Code to the Nostr protocol for publishing notes, reading feeds, and handling private messages. Useful whenever an AI agent needs decentralized identity.
claude mcp add bray -e NOSTR_SECRET_KEY=<NOSTR_SECRET_KEY> -e NOSTR_RELAYS=<NOSTR_RELAYS> -e NWC_URI=<NWC_URI> -- npx -y nostr-brayWhat bray does
The nostr-bray package connects your assistant to Nostr through 261 tools organized into 29 groups. Only 50 tools are exposed directly to the model, covering profile checks, feed fetching, direct messaging, and balance lookups. Remaining actions stay in a catalog: the agent locates them with search-actions and runs them through execute-action. This structure prevents context exhaustion.
Running the server requires Node.js 24 or newer. Storing raw keys in NOSTR_SECRET_KEY exposes them directly to the process environment. For ongoing operations, configure a NIP-46 signer bunker via BUNKER_URI or use encrypted keys with NOSTR_NCRYPTSEC instead.
What it helps with
- publish notes and read user feeds across Nostr relays
- exchange encrypted direct messages with contacts
- check zap balances and inspect wallet status
- generate a key pair and recovery mnemonic via
npx nostr-bray create
Example prompts for the agent
- Check our active Nostr identity with
whoami. - Post a short note to my Nostr feed saying "Testing Claude Code integration".
- Search the action catalog for relay health inspection tools.
How to install bray
Platform CLI
claude mcp add bray -e NOSTR_SECRET_KEY=<NOSTR_SECRET_KEY> -e NOSTR_RELAYS=<NOSTR_RELAYS> -e NWC_URI=<NWC_URI> -- npx -y nostr-brayReplace <…> with your own values
Platform CLI
codex mcp add bray --env NOSTR_SECRET_KEY=<NOSTR_SECRET_KEY> --env NOSTR_RELAYS=<NOSTR_RELAYS> --env NWC_URI=<NWC_URI> -- npx -y nostr-brayReplace <…> with your own values
Config file
{
"mcpServers": {
"bray": {
"command": "npx",
"args": [
"-y",
"nostr-bray"
],
"env": {
"NOSTR_SECRET_KEY": "<NOSTR_SECRET_KEY>",
"NOSTR_RELAYS": "<NOSTR_RELAYS>",
"NWC_URI": "<NWC_URI>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"bray": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"nostr-bray"
],
"env": {
"NOSTR_SECRET_KEY": "<NOSTR_SECRET_KEY>",
"NOSTR_RELAYS": "<NOSTR_RELAYS>",
"NWC_URI": "<NWC_URI>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e NOSTR_SECRET_KEY=<NOSTR_SECRET_KEY> -e NOSTR_RELAYS=<NOSTR_RELAYS> -e NWC_URI=<NWC_URI> bray npx -y nostr-brayReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about bray
How do I install bray in Claude Code?
Run claude mcp add bray -e NOSTR_SECRET_KEY=<NOSTR_SECRET_KEY> -e NOSTR_RELAYS=<NOSTR_RELAYS> -e NWC_URI=<NWC_URI> -- npx -y nostr-bray. If you lack a keypair, generate one first using npx nostr-bray create.
What does bray do?
It provides an MCP interface for Nostr, letting AI agents publish events, read direct messages, interact with communities, and query relays.
What are the runtime requirements for bray?
The package requires Node.js 24 or higher, along with relay endpoints set in NOSTR_RELAYS.