Skip to content

FEATURE: MCP Server Integration for Tool Calling #1

@BenGWeeks

Description

@BenGWeeks

Overview

Add Model Context Protocol (MCP) server support to enable Nod.ie to interact with external tools and services through voice commands. This will allow users to perform actions like Lightning Network operations, file management, and API interactions through natural conversation.

Background

  • MCP is an open standard by Anthropic for AI-tool communication
  • Unmute doesn't have native tool calling, but the underlying LLM supports it
  • Integration requires intercepting LLM calls and handling tool execution

Architecture Design

1. New Module: modules/mcp-bridge.js

  • MCP client implementation
  • Server discovery and connection management
  • Tool execution with error handling
  • Response formatting for voice

2. LLM Wrapper Service

  • Intercept Unmute's vLLM calls
  • Parse tool calling intents from conversation
  • Execute tools and inject results
  • Maintain conversation context

3. Configuration Structure

{
  "mcpServers": {
    "lnd": {
      "command": "lightning-mcp-server",
      "args": ["--node-url", "localhost:10009"],
      "transport": "stdio",
      "env": {
        "LND_MACAROON_PATH": "~/.lnd/admin.macaroon",
        "LND_TLS_CERT_PATH": "~/.lnd/tls.cert"
      }
    },
    "files": {
      "command": "file-mcp-server",
      "args": ["--root", "~/Documents"],
      "transport": "stdio"
    }
  }
}

Implementation Tasks

Phase 1: MCP Client Foundation

  • Create MCP client module with stdio/SSE transport support
  • Implement server lifecycle management (start/stop/restart)
  • Add tool discovery protocol
  • Create tool execution pipeline with timeout handling

Phase 2: LLM Integration Layer

  • Create FastAPI wrapper for vLLM with tool calling support
  • Implement tool detection in conversation flow
  • Add context injection for tool results
  • Handle streaming responses with tool calls

Phase 3: Voice Optimization

  • Convert JSON tool responses to natural language
  • Add confirmation prompts for destructive operations
  • Implement progress indicators for long-running tools
  • Create voice-friendly error messages

Phase 4: LND MCP Server

  • Use/adapt existing lightning-mcp-server
  • Implement core operations:
    • getBalance() - Check Lightning and on-chain balance
    • listChannels() - List active/inactive channels
    • createInvoice(amount, memo) - Generate payment requests
    • payInvoice(bolt11) - Send Lightning payments
    • getNodeInfo() - Node status and stats
  • Add safety features (payment limits, confirmations)

Phase 5: User Experience

  • Update SYSTEM-PROMPT.md with tool capabilities
  • Add visual indicators during tool execution
  • Create tool discovery commands ("What tools do you have?")
  • Implement tool help system

Example Interactions

User: "What's my Lightning balance?"
Nod.ie: "Let me check your Lightning node... You have 0.05 Bitcoin in your Lightning channels and 0.02 Bitcoin in your on-chain wallet."

User: "Create an invoice for 10,000 sats with memo 'Coffee payment'"
Nod.ie: "I've created a Lightning invoice for 10,000 satoshis. The payment request is... [reads bolt11]. Should I display the QR code?"

User: "List my active channels"
Nod.ie: "You have 3 active channels: One with ACINQ with 2 million sats capacity, one with Lightning Labs with 5 million sats, and one with Voltage with 1 million sats."

Technical Considerations

Security

  • MCP servers run in separate processes
  • Macaroon/cert authentication for LND
  • User confirmation for payments
  • Rate limiting on sensitive operations

Performance

  • Tool calls add latency to responses
  • Cache frequently accessed data
  • Implement timeouts for long operations
  • Stream partial results when possible

Error Handling

  • Graceful degradation if MCP servers unavailable
  • Voice-friendly error messages
  • Retry logic for transient failures
  • Clear user feedback on tool status

Dependencies

  • MCP protocol implementation
  • FastAPI for LLM wrapper
  • lightning-mcp-server or custom implementation
  • Updated Unmute integration

Testing Plan

  1. Unit tests for MCP client
  2. Integration tests with mock MCP servers
  3. End-to-end voice interaction tests
  4. LND testnet integration tests

References

This feature will transform Nod.ie from a conversational assistant into an action-capable voice interface for Bitcoin/Lightning operations and beyond.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions