0.2.3 • Published 5 months ago

@dvmcp/discovery v0.2.3

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

DVMCP Discovery

A MCP server implementation that aggregates tools from DVMs across the Nostr network and makes them available through a single interface.

Features

  • Discovers MCP tools from DVMs across the Nostr network
  • Provides a unified interface to access tools from multiple DVMs
  • Tool execution handling and status tracking
  • Automatic payment for paid tools using Nostr Wallet Connect (NWC)
  • Configurable DVM whitelist
  • Direct connection to specific providers or servers
  • Interactive mode with built-in tools

Configuration

DVMCP Discovery supports multiple configuration methods with a clear priority order: default < file < environment variables < CLI arguments.

Configuration File

When the package is run for the first time, it will use sensible defaults. You can create a configuration file by copying config.example.yml and modifying it:

cp config.example.yml config.dvmcp.yml
nano config.dvmcp.yml

You can also run the configuration wizard to create a configuration file interactively:

npx dvmcp-discovery --configure

To specify a custom configuration file path:

npx dvmcp-discovery --config-path /path/to/custom/config.dvmcp.yml

CLI Arguments

You can add configuration settings using command-line arguments:

# Set Nostr relay URLs
npx dvmcp-discovery -r wss://relay1.com,wss://relay2.com
# or
npx dvmcp-discovery --nostr-relay-urls wss://relay1.com,wss://relay2.com

# Set Nostr private key
npx dvmcp-discovery --nostr-private-key <hex-private-key>

# Enable interactive mode with built-in tools
npx dvmcp-discovery -i
# or
npx dvmcp-discovery --interactive

# Run in interactive mode without connecting to any relays
npx dvmcp-discovery --interactive

# Set MCP service details
npx dvmcp-discovery --mcp-name "My DVMCP Service" --mcp-version "1.2.0"

# Limit the number of DVMs to discover
npx dvmcp-discovery --discovery-limit 5

# Enable verbose output
npx dvmcp-discovery -v
# or
npx dvmcp-discovery --verbose

Environment Variables

You can also configure the service using environment variables:

# Set Nostr configuration
export DVMCP_NOSTR_PRIVATE_KEY=<hex-private-key>
export DVMCP_NOSTR_RELAY_URLS=wss://relay1.com,wss://relay2.com

# Set MCP service details
export DVMCP_MCP_NAME="My DVMCP Service"
export DVMCP_MCP_VERSION="1.2.0"
export DVMCP_MCP_ABOUT="Custom description"

# Set NWC configuration
export DVMCP_NWC_CONNECTION_STRING="nostr+walletconnect:..."

# Limit the number of DVMs to discover
export DVMCP_DISCOVERY_LIMIT=5

# Run the service
npx dvmcp-discovery

NWC Payment Configuration

To enable automatic payment for tools that require payment, add the NWC (Nostr Wallet Connect) configuration to your config.dvmcp.yml file:

nwc:
  # Your NWC connection string
  # Format: nostr+walletconnect:<pubkey>?relay=<relay_url>&secret=<secret>
  connectionString: 'nostr+walletconnect:your_wallet_pubkey_here?relay=wss%3A%2F%2Frelay.example.com&secret=your_secret_here'

# Feature flags for enabling/disabling specific features
featureFlags:
  # Enable interactive mode to load built-in tools and skip default relay connections
  interactive: false

You can obtain an NWC connection string from compatible wallets like Alby or Coinos. When a tool requires payment, the discovery server will automatically pay the invoice using the configured NWC wallet.

Usage

Prerequisite: Ensure you have Bun installed.

You can run this package directly using npx:

npx @dvmcp/discovery

Alternatively, for development:

bun run dev

For production:

bun run start

Direct Connection Options

You can connect directly to a specific provider or server without a configuration file:

Connect to a Provider

Use the --provider flag followed by an nprofile entity to discover and register all tools from a specific provider:

bun run start --provider nprofile1...

Connect to a Server

Use the --server flag followed by an naddr entity to register only the tools from a specific server:

bun run start --server naddr1...

This is useful when you want to work with a specific subset of tools rather than discovering all tools from a provider.

Interactive Mode

Interactive mode enables built-in tools that are only loaded when this mode is active. This provides a more streamlined experience when you want to use the discovery server with just the built-in tools.

# Enable interactive mode
npx dvmcp-discovery --interactive
# or
npx dvmcp-discovery -i

When interactive mode is enabled:

  1. Built-in tools are registered and available for use
  2. If no relay URLs are specified, the server will run without connecting to any Nostr relays
  3. This allows for a self-contained experience using only the built-in tools

This is particularly useful for testing or when you want to use the discovery server without relying on external Nostr relays.

Debug

You can enable debug mode by setting the DEBUG environment variable to *:

DEBUG=* npx @dvmcp/discovery

Testing

Run the test suite:

bun test
0.2.3

5 months ago

0.2.2

5 months ago

0.2.1

5 months ago

0.2.0

5 months ago

0.1.30

6 months ago

0.1.29

6 months ago

0.1.28

6 months ago

0.1.27

7 months ago

0.1.26

7 months ago

0.1.25

7 months ago

0.1.24

7 months ago

0.1.23

7 months ago

0.1.22

7 months ago

0.1.21

7 months ago

0.1.20

7 months ago

0.1.19

7 months ago

0.1.18

7 months ago

0.1.17

7 months ago

0.1.16

7 months ago

0.1.15

7 months ago

0.1.14

7 months ago

0.1.13

7 months ago

0.1.12

7 months ago

0.1.11

7 months ago

0.1.10

7 months ago

0.1.9

7 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago