nostr-mcp

Nostr MCP Server: Empowering AI models with censorship-resistant Nostr interactions via MCP.

nostr-mcp
nostr-mcp Capabilities Showcase

nostr-mcp Solution Overview

Nostr MCP Server is an MCP server that empowers AI models to interact with the Nostr network, a censorship-resistant, open protocol. This server allows AI models to post notes and engage with users on Nostr, opening up new avenues for AI-driven content creation and social interaction.

Key features include MCP compliance for seamless AI integration, the ability to post notes to multiple Nostr relays, and support for sending Lightning zaps. It utilizes Server-Sent Events (SSE) for real-time communication and offers configurable transport modes, including SSE and stdin. By integrating with Nostr MCP Server, developers can enable AI models to participate in a decentralized social network, fostering free speech and innovative applications. The server is easily installed via Smithery or manually, and provides tools like post_note and send_zap for interacting with the Nostr network.

nostr-mcp Key Capabilities

Censorship-Resistant AI Interaction

The core function of nostr-mcp is to enable AI models to interact with the Nostr network, a decentralized and censorship-resistant social media protocol. This allows AI models to post notes (short text messages) and engage in discussions without the risk of being censored or having their content removed by centralized authorities. The server acts as a bridge, translating MCP requests from the AI model into Nostr events and relaying them to the Nostr network. This ensures that the AI's voice can be heard on a platform that values free speech and open communication.

For example, an AI model could use nostr-mcp to share its research findings, opinions on current events, or even creative writing pieces directly on Nostr, reaching a diverse audience without relying on traditional media outlets. This is particularly valuable for AI models that generate content on sensitive or controversial topics. The implementation involves translating the AI's text input into a Nostr EVENT object, signing it with the configured Nostr private key, and sending it to a list of configured Nostr relays.

MCP-Compliant API

nostr-mcp provides a Model Context Protocol (MCP)-compliant API, ensuring seamless integration with AI models that adhere to the MCP standard. This compliance simplifies the process of connecting AI models to the Nostr network, as developers can leverage the standardized MCP interface to send commands and receive responses. The API supports essential functions such as posting notes and sending Lightning zaps, allowing AI models to perform various actions on Nostr.

For instance, a developer can use the MCP API to create an AI-powered chatbot that automatically responds to mentions on Nostr or shares relevant information based on user queries. The MCP compliance ensures that the chatbot can easily interact with the Nostr network through the nostr-mcp server. The server exposes endpoints that accept MCP requests, validates them, and translates them into corresponding Nostr actions. This abstraction simplifies the development process and promotes interoperability between AI models and the Nostr network.

Real-time Communication via SSE

The nostr-mcp server supports Server-Sent Events (SSE) for real-time communication, enabling AI models to receive updates and notifications from the Nostr network in a timely manner. This feature allows AI models to react quickly to new events, such as mentions, replies, or other relevant activities. SSE provides a persistent connection between the AI model and the server, allowing for efficient and low-latency data streaming.

For example, an AI model could use SSE to monitor specific hashtags or keywords on Nostr and automatically generate responses or take actions based on the incoming data. This could be used for sentiment analysis, trend detection, or even automated content creation. The server establishes an SSE connection with the client and pushes updates whenever relevant events occur on the Nostr network. This real-time communication capability enhances the responsiveness and interactivity of AI models interacting with Nostr.

Technical Implementation

The nostr-mcp server is built using Node.js and leverages the Nostr protocol for secure and decentralized communication. It utilizes TypeScript for type safety and maintainability. The server connects to multiple Nostr relays, allowing for redundancy and increased reliability. It supports configurable transport modes, including SSE and stdin, providing flexibility for different deployment scenarios. The server also includes error handling and logging mechanisms to ensure stability and facilitate debugging. The project structure is well-organized, with clear separation of concerns between the main server logic, the Nostr client implementation, and the type definitions. This modular design promotes code reusability and simplifies future development efforts.