Navigation
Nostr MCP Server: Real-Time AI Context & Web3 Scalability - MCP Implementation

Nostr MCP Server: Real-Time AI Context & Web3 Scalability

Empower LLMs like Claude with Nostr’s decentralized real-time context via our MCP Server—scale AI potential, innovate at web3 speed.

Developer Tools
4.4(151 reviews)
226 saves
105 comments

Ranked in the top 2% of all AI tools in its category

About Nostr MCP Server

What is Nostr MCP Server: Real-Time AI Context & Web3 Scalability?

Nostr MCP Server acts as a bridge between Large Language Models (LLMs) like Claude and the Nostr protocol, enabling real-time access to blockchain-native social data. This server implements the Model Context Protocol (MCP) to fetch user profiles, text notes, and payment events (zaps), while maintaining compliance with Web3 standards for scalability and privacy.

How to Use Nostr MCP Server: Real-Time AI Context & Web3 Scalability?

Integration follows three core steps:

  1. Clone the repository and install dependencies via npm
  2. Configure Claude for Desktop by specifying the server's absolute path in claude_desktop_config.json
  3. Query Nostr data directly within Claude using natural language prompts specifying npub keys, relays, or filtering parameters

Advanced users can customize relay endpoints or adjust query parameters for granular control over data retrieval.

Nostr MCP Server Features

Key Features of Nostr MCP Server: Real-Time AI Context & Web3 Scalability?

  • Unified identifier support: Handles hex public keys and npub formats interchangeably
  • Direction-aware zap tracking: Distinguishes sent/received zaps with NIP-57 compliance
  • Smart caching: Optimizes performance for high-volume payment data queries
  • Parameterized requests: Specify note/zap limits, validation flags, and relay selection
  • Transparent logging: Provides debuggable payment invoice parsing with sats amount extraction

Use Cases of Nostr MCP Server: Real-Time AI Context & Web3 Scalability?

Developers and businesses leverage this server for:

  • Social analytics: Real-time sentiment analysis using note content and engagement metrics
  • Monetization tracking: Automated reporting of microtransactions via zap receipts
  • Identity verification: Cross-referencing NIP-5 email assertions with public activity
  • Bot automation: Trigger actions based on new posts or payment events detected
  • Multi-relay validation: Ensuring data consistency across distributed Nostr relays

Nostr MCP Server FAQ

FAQ from Nostr MCP Server: Real-Time AI Context & Web3 Scalability?

Why do some queries return empty?
Check relay availability - try specifying alternative endpoints like wss://nostr.commerce or increase the timeout value
Can I extend supported relays?
Edit the RELAYS constant in index.ts and rebuild the server
How is data freshness ensured?
New connections are established per query to avoid stale cache states
What prevents abuse?
Rate limiting is enforced through the 8-second timeout mechanism - adjust via QUERY_TIMEOUT for heavy workloads
Does it support nostr apps?
Currently optimized for LLM integration, but API endpoints can be repurposed for custom applications

Content

Nostr MCP Server

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

Features

This server implements five tools for interacting with the Nostr network:

  1. getProfile: Fetches a user's profile information by public key
  2. getKind1Notes: Fetches text notes (kind 1) authored by a user
  3. getReceivedZaps: Fetches zaps received by a user, including detailed payment information
  4. getSentZaps: Fetches zaps sent by a user, including detailed payment information
  5. getAllZaps: Fetches both sent and received zaps for a user, clearly labeled with direction and totals

All tools fully support both hex public keys and npub format, with user-friendly display of Nostr identifiers.

Installation

# Clone the repository
git clone https://github.com/yourusername/nostr-mcp-server.git
cd nostr-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

Connecting to Claude for Desktop

  1. Make sure you have Claude for Desktop installed and updated to the latest version.

  2. 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
  1. 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.

  1. Restart Claude for Desktop.

Usage in Claude

Once configured, you can ask Claude to use the Nostr tools by making requests like:

  • "Show me the profile information for npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8"
  • "What are the recent posts from npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8?"
  • "How many zaps has npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8 received?"
  • "Show me the zaps sent by npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8"
  • "Show me all zaps (both sent and received) for npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8"

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.

Advanced Usage

You can specify custom relays for any query:

  • "Show me the profile for npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8 using relay wss://relay.damus.io"

You can also specify the number of notes or zaps to fetch:

  • "Show me the latest 20 notes from npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8"

For zap queries, you can enable extra validation and debugging:

  • "Show me all zaps for npub1qny3tkh0acurzla8x3zy4nhrjz5zd8ne6dvrjehx9n9hr3lnj08qwuzwc8 with validation and debug enabled"

Limitations

  • The server has a default 8-second timeout for queries to prevent hanging
  • Only public keys in hex format or npub format are supported
  • Only a subset of relays is used by default

Implementation Details

  • Native support for npub format using NIP-19 encoding/decoding
  • NIP-57 compliant zap receipt detection with direction-awareness (sent/received/self)
  • Advanced bolt11 invoice parsing with payment amount extraction
  • Smart caching system for improved performance with large volumes of zaps
  • Total sats calculations for sent/received/self zaps with net balance
  • Optional NIP-57 validation for ensuring zap receipt integrity
  • Each tool call creates a fresh connection to the relays, ensuring reliable data retrieval

Troubleshooting

  • If queries time out, try increasing the QUERY_TIMEOUT value in the source code (currently 8 seconds)
  • If no data is found, try specifying different relays that might have the data
  • Check Claude's MCP logs for detailed error information

Default Relays

The server uses the following relays by default:

  • wss://relay.damus.io
  • wss://relay.nostr.band
  • wss://relay.primal.net
  • wss://nos.lol
  • wss://relay.current.fyi
  • wss://nostr.bitcoiner.social

Development

To modify or extend this server:

  1. Edit the index.ts file in the project root
  2. Run npm run build to compile
  3. Restart Claude for Desktop to pick up your changes

Related MCP Servers & Clients