n8n-AI-agent-DVM-MCP-client
by: r0d8lsh0p
An AI agent built in n8n which can find and use Model Context Protocol (MCP) Server Tools served as Data Vending Machines (DVM) over the Nostr network.
📌Overview
Purpose: To develop an AI Agent that utilizes the Model Context Protocol (MCP) Server Tools as Data Vending Machines (DVM) over the Nostr network, enabling access to tools that are not locally installed.
Overview: The n8n AI Agent operates by querying the Nostr network for available MCP tools based on user prompts. It facilitates the discovery and utilization of these tools remotely, addressing the challenges of traditional local installations and lack of discovery methods for LLMs.
Key Features:
-
Dynamic Tool Discovery: The agent can query and identify MCP tools available on the Nostr network, expanding its functionality without needing local installation.
-
Sequential Workflow Execution: The agent follows a structured process to send requests, wait for responses, and handle communication with various tools, ensuring efficient operation and responsiveness to user needs.
n8n AI Agent for DVM MCP
These workflows create an AI Agent which is a user of Model Context Protocol (MCP) Server Tools served as Data Vending Machines (DVM) over the Nostr network.
The Agent, given a prompt which requires a tool:
- Queries the network for available tools it can use,
- Posts requests to those tools over the network,
- Waits as required for the tool response,
- Reads responses from those tools, and replies to the User.
Why This is Interesting
- Typically, for an LLM to use an MCP Tool, the MCP Server needs to be on the same system as the LLM.
- There has been no discovery methodology for an LLM to find MCP Servers and Tools not yet installed.
- Data Vending Machines allow LLMs to discover and use Tools over the Nostr network.
- This AI Agent example demonstrates how an AI can find and use MCP Tools by querying for them as DVMs over the Nostr network.
Technologies
- MCP: The Model Context Protocol is an open protocol allowing AI agents to access data sources and tools. Read more
- DVM: Data Vending Machines listen for and respond to queries over the Nostr network. Read more
- DVMCP: Data Vending Machine Context Protocol bridges MCP servers with Nostr's DVM ecosystem. Any MCP server can serve any tool over the network, and any Agent client can access all tools served by any server. See DVMCP by Gzuuus and NostrDVM by BelieveTheHype
- n8n: A low-code platform convenient for creating Langchain Tools Agents. Read more
Prerequisites
- n8n: Install a self-hosted n8n on your system. See n8n hosting docs
- Nostrobots: Install Nostrobots Community Nodes by Ocknamo, which adds Nostr tools to your n8n instance.
- Add workflows from GitHub to n8n: Add the five workflows by copying the Raw .json URL and importing into n8n.
- Credentials: Add credentials for OpenAI API (or other LLM), SerpAPI, Nostr Private Key (Nsec), Postgresql/Supabase.
- Settings: Set workflow variables in the Set Variables Node: Assistant Name, Assistant Npub, Nostr Relays, User Localization.
If you do not have a Nostr private key, you can generate one at NostrTool.com.
Component Workflows
The main workflow is DVMCP Agent Example v1.0, used together with four Tools Subworkflows:
- AI Tool – Find Nostr DVMCP Servers
- AI Tool – Post Nostr DVMCP Server Query
- AI Tool – Wait
- AI Tool – Read Nostr DVMCP Server Response
Initial Setup on Install
- The DVMCP Agent must connect to its Tools Subworkflows.
- On initial install, manually reconnect these by opening the DVMCP Agent Example v1.0 and selecting the correct subworkflow node.
- Enter credentials also in the Post Nostr DVMCP Server Query subworkflow.
How it Works
The Agent uses its tools sequentially to satisfy user requests. An extract from its system prompt:
**Tips for DVM Use**
- If your User requests something requiring a tool you do not have, query for DVM MCP server tools on Nostr. If you find a relevant tool, ask your User if you should use it.
- If your User requests to use a tool, follow these steps:
1) Post your request to the MCP server
2) Wait for 15 seconds
3) Read the response from the MCP server
4) If no response and less than 45 seconds have passed, repeat step 2
5) Otherwise, perform any final steps or required localization (e.g., query forex and convert USD to local currency)
The system prompt and workflows can be customized for your use case.
Nostr Links
- Contact me npub1r0d8u8mnj6769500nypnm28a9hpk9qg8jr0ehe30tygr3wuhcnvs4rfsft
License
This project is licensed under the MIT License.