A sample Rust MCP (Model Context Protocol) server that adds two numbers together, exposed via ContextVM gateway over Nostr.
This workspace contains two crates:
- adder-cli - A simple CLI that adds two numbers
- adder-mcp - An MCP server that exposes an
addtool
- Rust (with cargo)
- ContextVM Gateway CLI
cargo build --releasecurl -fsSL https://raw.githubusercontent.com/contextvm/gateway-cli/main/install.sh | bashOr download the binary for your platform from the releases page.
Copy the example config and add your Nostr private key:
cp example.contextgw.config.yml contextgw.config.ymlEdit contextgw.config.yml and replace YOUR_NOSTR_PRIVATE_KEY_HEX_HERE with your Nostr private key in hex format.
If you have an nsec key, you can convert it to hex using a tool like nostr-tool or online converters.
./target/release/adder-cli 5 3
# Output: 8gatewayThis will:
- Start your MCP server (
adder-mcp) - Connect to the ContextVM Nostr relay
- Make it publicly discoverable
- Use NIP-44 encryption for secure communication
The gateway will display the server's public key (npub) that clients can use to connect.
The server exposes one tool:
- add - Adds two numbers together
- Parameters:
a(float): The first numberb(float): The second number
- Returns: The sum as a string
- Parameters:
Once running, clients can connect to your MCP server using:
- The npub/public key displayed by the gateway
- Any MCP client that supports ContextVM/Nostr transport
MIT