
Nostr
STDIONostr MCP server enabling LLMs to interact with Nostr network profiles, notes, and zaps.
Nostr MCP server enabling LLMs to interact with Nostr network profiles, notes, and zaps.
A Model Context Protocol (MCP) server that provides Nostr capabilities to LLMs like Claude.
https://github.com/user-attachments/assets/1d2d47d0-c61b-44e2-85be-5985d2a81c64
This server implements 18 tools for interacting with the Nostr network:
getProfile
: Fetches a user's profile information by public keygetKind1Notes
: Fetches text notes (kind 1) authored by a usergetLongFormNotes
: Fetches long-form content (kind 30023) authored by a usergetReceivedZaps
: Fetches zaps received by a user, including detailed payment informationgetSentZaps
: Fetches zaps sent by a user, including detailed payment informationgetAllZaps
: Fetches both sent and received zaps for a user, clearly labeled with direction and totalssearchNips
: Search through Nostr Implementation Possibilities (NIPs) with relevance scoringcreateKeypair
: Generate new Nostr keypairs in hex and/or npub/nsec formatcreateProfile
: Create a new Nostr profile (kind 0 event) with metadataupdateProfile
: Update an existing Nostr profile with new metadatacreateNote
: Create unsigned kind 1 note events with specified content and tagssignNote
: Sign note events with a private key, generating cryptographically valid signaturespublishNote
: Publish signed notes to specified Nostr relayspostNote
: All-in-one authenticated note posting using an existing private key (nsec/hex)sendAnonymousZap
: Prepare an anonymous zap to a profile or event, generating a lightning invoice for paymentpostAnonymousNote
: Post an anonymous note using a randomly generated one-time keypairconvertNip19
: Convert between different NIP-19 entity formats (hex, npub, nsec, note, nprofile, nevent, naddr)analyzeNip19
: Analyze and decode any NIP-19 entity to understand its type and contentsAll tools fully support both hex public keys and npub format, with user-friendly display of Nostr identifiers.
npm install -g nostr-mcp-server
# Clone the repository git clone https://github.com/austinkelsay/nostr-mcp-server.git cd nostr-mcp-server # Install dependencies npm install # Build the project npm run build
Make sure you have Claude for Desktop installed and updated to the latest version.
Configure Claude for Desktop by editing or creating the configuration file:
For macOS:
vim ~/Library/Application\ Support/Claude/claude_desktop_config.json
For Windows:
notepad %AppData%\Claude\claude_desktop_config.json
Add the Nostr server to your configuration:
If installed via npm:
{ "mcpServers": { "nostr": { "command": "npx", "args": [ "nostr-mcp-server" ] } } }
If installed from source:
{ "mcpServers": { "nostr": { "command": "node", "args": [ "/ABSOLUTE/PATH/TO/nostr-mcp-server/build/index.js" ] } } }
For source installations, replace /ABSOLUTE/PATH/TO/
with the actual path to your project.
Restart Claude for Desktop.
Make sure you have Cursor installed and updated to the latest version.
Configure Cursor by creating or editing the configuration file:
For macOS:
vim ~/.cursor/config.json
For Windows:
notepad %USERPROFILE%\.cursor\config.json
Add the Nostr server to your configuration:
If installed via npm:
{ "mcpServers": { "nostr": { "command": "npx", "args": [ "nostr-mcp-server" ] } } }
If installed from source:
{ "mcpServers": { "nostr": { "command": "node", "args": [ "/ABSOLUTE/PATH/TO/nostr-mcp-server/build/index.js" ] } } }
For source installations, replace /ABSOLUTE/PATH/TO/
with the actual path to your project.
Restart Cursor.
Make sure you have Goose installed and properly configured.
Add the Nostr MCP server to your Goose configuration:
Open your Goose configuration file (typically ~/.config/goose/profiles.yaml
) and add the following to your profile's mcpServers
section:
If installed via npm:
profiles: default: provider: # your existing provider config model: # your existing model config mcpServers: - name: nostr command: npx args: - nostr-mcp-server
If installed from source:
profiles: default: provider: # your existing provider config model: # your existing model config mcpServers: - name: nostr command: node args: - /ABSOLUTE/PATH/TO/nostr-mcp-server/build/index.js
For source installations, replace /ABSOLUTE/PATH/TO/
with the actual path to your project.
Restart Goose or reload your configuration for the changes to take effect.
You can verify the MCP server is connected by asking Goose:
What MCP tools do you have available for Nostr?
Once configured, you can ask Claude to use the Nostr tools by making requests like:
The server automatically handles conversion between npub and hex formats, so you can use either format in your queries. Results are displayed with user-friendly npub identifiers.
The postAnonymousNote
tool allows users to post notes to the Nostr network without revealing their identity. Key points about anonymous notes:
Examples:
"Post an anonymous note saying 'Just trying out the anonymous posting feature!'"
"Create an anonymous note with the content 'Testing the Nostr anonymity features' and tags #test #anonymous"
"Post anonymously to Nostr: 'I can share thoughts without linking to my identity'"
For more control, you can specify custom relays:
"Post an anonymous note to relay wss://relay.damus.io saying 'Hello Nostr world!'"
This feature is useful for:
The server provides comprehensive tools for managing Nostr identities and profiles:
The createKeypair
tool generates cryptographically secure Nostr keypairs using the secp256k1 curve. You can choose to receive keys in hex format, npub/nsec format, or both:
"Generate a new Nostr keypair in both hex and npub format"
"Create a keypair with only hex keys"
"Generate keys in npub format only"
Create and manage Nostr profiles (kind 0 events) with full metadata support:
Examples:
"Create a profile with name 'Alice', about 'Bitcoin developer', and picture 'https://example.com/alice.jpg'"
"Update my profile to add website 'https://alice.dev' and Lightning address '[email protected]'"
For advanced users who need granular control over the note creation process:
createNote
: Creates unsigned note events with your content and tagssignNote
: Signs note events with your private key, generating cryptographically valid signaturespublishNote
: Publishes signed notes to your chosen relaysThis modular approach allows for:
The postNote
tool provides a convenient single-command approach for authenticated posting:
"Post a note saying 'GM Nostr! ☀️' using my private key nsec1xyz..."
"Create a post with content 'Just shipped a new feature!' and tags #development #nostr"
"Post 'Beautiful sunset today 🌅' with tags #photography #nature to relay wss://relay.damus.io"
Key features:
You can specify custom relays for any query:
You can also specify the number of notes or zaps to fetch:
For anonymous zaps, you can include optional comments and specify the target type:
For zap queries, you can enable extra validation and debugging:
For NIP searches, you can control the number of results and include full content:
The sendAnonymousZap
tool lets users send zaps without revealing their Nostr identity. Key points about anonymous zaps:
Examples:
"Send an anonymous zap of 100 sats to npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8"
"Send 1000 sats anonymously to note1abcdef... with the comment 'Great post!'"
The server fully validates LNURL services according to LNURL-pay (LUD-06) and Lightning Address (LUD-16) specifications, ensuring compatibility with various wallet implementations.
QUERY_TIMEOUT
value in the source code (currently 8 seconds)The server uses the following relays by default:
To modify or extend this server:
Edit the relevant file:
index.ts
: Main server and tool registrationprofile/profile-tools.ts
: Identity management, keypair generation, profile creation (Documentation)note/note-tools.ts
: Note creation, signing, publishing, and reading functionality (Documentation)zap/zap-tools.ts
: Zap-related functionality (Documentation)nips/nips-tools.ts
: Functions for searching NIPs (Documentation)utils/
: Shared utility functions
constants.ts
: Global constants and relay configurationsconversion.ts
: NIP-19 entity conversion utilities (hex/npub/nprofile/nevent/naddr)formatting.ts
: Output formatting helpersnip19-tools.ts
: NIP-19 entity conversion and analysis toolspool.ts
: Nostr connection pool managementephemeral-relay.ts
: In-memory Nostr relay for testingRun npm run build
to compile
Restart Claude for Desktop or Cursor to pick up your changes
We've implemented a comprehensive test suite using Jest to test both basic functionality and integration with the Nostr protocol:
# Run all tests npm test # Run a specific test file npm test -- __tests__/basic.test.ts # Run integration tests npm test -- __tests__/integration.test.ts
The test suite includes:
basic.test.ts
- Tests simple profile formatting and zap receipt processingprofile-notes-simple.test.ts
- Tests profile and note data structuresprofile-tools.test.ts
- Tests keypair generation, profile creation, and identity managementnote-creation.test.ts
- Tests note creation, signing, and publishing workflowsnote-tools-functions.test.ts
- Tests note formatting, creation, signing, and publishing functionsnote-tools-unit.test.ts
- Unit tests for note formatting functionsprofile-postnote.test.ts
- Tests authenticated note posting with existing private keyszap-tools-simple.test.ts
- Tests zap processing and anonymous zap preparationzap-tools-tests.test.ts
- Tests zap validation, parsing, and direction determinationsearch-nips-simple.test.ts
- Tests NIPs search functionality with relevance scoringnip19-conversion.test.ts
- Tests NIP-19 entity conversion and analysis (28 test cases)integration.test.ts
- Tests interaction with an ephemeral Nostr relay including:
websocket-integration.test.ts
- Tests WebSocket communication with a Nostr relay:
ephemeral-relay.ts
implementation—a fully functional in-memory Nostr relayFor more details about the test suite, see tests/README.md.
The codebase is organized into modules:
index.ts
utils/
directoryThis modular structure makes the codebase more maintainable, reduces duplication, and enables easier feature extensions. For detailed information about each module's features and implementation, see their respective documentation.