Nostr Network Integration
STDIOMCP server providing Nostr network capabilities to LLMs like Claude.
MCP server providing Nostr network capabilities to LLMs like Claude.
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 several 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 scoringsendAnonymousZap
: Prepare an anonymous zap to a profile or event, generating a lightning invoice for paymentAll tools fully support both hex public keys and npub format, with user-friendly display of Nostr identifiers.
# 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:
{ "mcpServers": { "nostr": { "command": "node", "args": [ "/ABSOLUTE/PATH/TO/nostr-mcp-server/build/index.js" ] } } }
Be sure to 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:
{ "mcpServers": { "nostr": { "command": "node", "args": [ "/ABSOLUTE/PATH/TO/nostr-mcp-server/build/index.js" ] } } }
Be sure to replace /ABSOLUTE/PATH/TO/
with the actual path to your project.
Restart Cursor.
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.
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 registrationnote/note-tools.ts
: Profile and notes 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
: Pubkey format conversion utilitiesformatting.ts
: Output formatting helperspool.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 structureszap-tools-simple.test.ts
- Tests zap processing and anonymous zap preparationintegration.test.ts
- Tests interaction with an ephemeral Nostr relay including:
websocket-integration.test.ts
- Tests WebSocket communication with a Nostr relay:
All integration tests use our ephemeral-relay.ts
implementation—a fully functional in-memory Nostr relay that supports the Nostr protocol, allowing for real cryptographic event signing and verification without requiring external network connections. This provides a robust way to test the full Nostr workflow in an isolated environment.
For 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.