See https://github.com/agentstr/agentstr-sdk/tree/main/cookbook for the latest Agentstr Demo code.
See the demo in action here.
Agentstr is a framework for building decentralized AI agents on the Nostr protocol, featuring LangChain and DSPy integrations, with Lightning Network payments via Nostr Wallet Connect.
- 🤖 Multiple Agent Backends
- Research Agent: Langgraph-based agent with Nostr MCP server integration
- Travel Agent: DSPy-based agent for flight booking and management
- ⚡ Lightning Network payments via Nostr Wallet Connect
- 🌐 Decentralized communication using Nostr protocol
- 🔐 Secure, private key-based authentication
Before you begin, ensure you have the following:
- 🐍 Python 3.11 or higher
- 💎
uvpackage manager - 📦 Dependencies from
pyproject.toml:agentstr-sdkpynostrbolt11fastapilangchain- And more...
- 🔑 Several
.envfiles with required environment variables- 📡 Access to Nostr relays - 💰 A Lightning wallet supporting NWC
We define a Langgraph-based agent with MCP server integration for general research tasks.
- Functionality:
- Initializes a
MultiServerMCPClientto connect to MCP servers via Nostr - Starts a
NostrAgentServerfor listening to Nostr messages - Exposes endpoints:
/info: Returns agent information (name, description, skills, etc.)/chat: Handles chat requests with optional thread IDs
- Manages lifecycle with async context (
lifespan)
- Initializes a
- Usage: Run the research agent API server:
./scripts/run_agent_research.sh
A DSPy-based agent specialized in flight booking and management.
- Functionality:
- Manages flight bookings, cancellations, and itinerary lookups
- Integrates with a simulated flight database
- Provides a simple API endpoint for interactions
- Uses DSPy for natural language understanding and task planning
- Features:
- Flight search and booking
- Itinerary management
- Flight cancellation
- User profile integration
- Usage: Run the travel agent server:
./scripts/run_agent_travel.sh
A script running an MCP server for Bitcoin-related queries.
- Functionality:
- Provides tools for Bitcoin price queries and blockchain information.
- Initialize a
NostrMCPServerwith Bitcoin-specific tools. - Start the server to handle Bitcoin-related requests.
- Usage: Provides Bitcoin price and blockchain data over Nostr.
- Example: Query current Bitcoin price:
{"action": "call_tool", "tool_name": "get_bitcoin_data", "arguments": {}}
A script running an MCP server for Nostr RAG (Retrieval-Augmented Generation).
- Functionality:
- Provides tools for semantic search over Nostr content.
- Implements vector embeddings and similarity search for Nostr events.
- Initialize a
NostrMCPServerwith RAG tools. - Start the server to handle semantic search requests.
- Usage: Enables semantic search over Nostr content.
- Example: Search for similar content:
{"action": "call_tool", "tool_name": "retrieve", "arguments": {"question": "what's new with bitcoin?"}}
A script running an MCP server for web search capabilities.
- Functionality:
- Provides tools for searching the web using a search engine API.
- Initialize a
NostrMCPServerwith web search tools. - Start the server to handle web search requests.
- Usage: Enables web search capabilities over Nostr.
- Example: Perform a web search:
{"action": "call_tool", "tool_name": "web_search", "arguments": {"query": "latest AI developments"}}
-
Clone the Repository:
git clone https://github.com/ehallmark/agentstr-demo cd agentstr-demo -
Install Dependencies:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -r requirements.txt
-
Configure Environment Variables:
- Copy the
.env.samplefile to.envin each agent directory - Update the environment variables with your configuration
- Copy the
-
Run MCP Servers:
# In separate terminals ./scripts/run_mcp_server_bitcoin.sh ./scripts/run_mcp_server_nostr_rag.sh ./scripts/run_mcp_server_web_search.sh -
Run the Agents:
For the Research Agent:
./scripts/run_agent_research.sh
For the Travel Agent:
./scripts/run_agent_travel.sh
- Each Agent and MCP Server requires its own Nostr private key and environment variables (see .env.sample files in each directory)
- Ensure Nostr relays are accessible and reliable.
- Payment-related operations require a valid NWC connection string.
- Both agents and the RAG MCP server require an LLM API key and base url (checkout Routstr for decentralized LLM access).
This project is licensed under the MIT License. See the LICENSE file for details.