nowledge-mem icon indicating copy to clipboard operation
nowledge-mem copied to clipboard

Feature Request: Configurable Network Binding for MCP Server

Open ferstar opened this issue 2 months ago • 0 comments

Summary

Request for configuration options to bind the MCP server to specific network interfaces instead of only localhost.

Current Situation

The Nowledge Mem MCP server currently only listens on localhost:14242. While this is the secure default, it prevents legitimate use cases where users need to access the service from other devices on their network.

Current Workaround

I'm using Caddy as a reverse proxy with token-based authentication:

:14243 {
    @authorized {
        expression {query.token} == "your-secret-token" || {header.Authorization} == "Bearer your-secret-token"
    }
    
    handle @authorized {
        reverse_proxy localhost:14242 {
            flush_interval -1
        }
    }
    
    handle {
        respond "Unauthorized: Invalid or missing token" 401 {
            close
        }
    }
}

Benefits of this approach:

  1. ✅ Production-grade reverse proxy with excellent stability
  2. ✅ Native SSE support (required for MCP streamableHttp)
  3. ✅ Simple token-based authentication built-in
  4. ✅ Easy to add HTTPS with automatic certificate management
  5. ✅ Cross-platform compatibility

Remaining limitations:

  1. Requires external service management
  2. Token is hardcoded in config (need Caddy restart to change)
  3. Additional complexity compared to native solution
  4. Need to maintain separate proxy configuration

Use Cases

  1. Multi-device development: Access the same knowledge base from desktop and laptop on the same network
  2. Remote workstation: Connect to a home server running Nowledge Mem from a remote location via VPN
  3. Flexible deployment: Run Nowledge Mem on a dedicated always-on machine while accessing from multiple clients

Proposed Solution

Add configuration options for network binding in Nowledge Mem settings:

Configuration Options

[server]
# Bind address: localhost (default), specific IP, or 0.0.0.0 for all interfaces
bind_address = "localhost"  # Default for security

# Port configuration
port = 14242

Example Configurations

Default (current behavior):

bind_address = "localhost"  # or "127.0.0.1"

Specific interface:

bind_address = "192.168.1.100"  # Bind to specific private IP

All interfaces (for advanced users):

bind_address = "0.0.0.0"  # Listen on all network interfaces

Security Considerations

  • Default to localhost: Maintain current secure default
  • Show warnings: Display security warning when binding to non-localhost addresses
  • Documentation: Clearly document security implications in the settings UI
  • Recommend authentication: Strongly recommend enabling authentication (see #5) when binding to non-localhost

Example Warning Message:

⚠️ Warning: Binding to non-localhost address exposes your knowledge base to network access.
   Only do this on trusted private networks (VPN/Tailscale).
   Consider enabling authentication for additional security.

Implementation Priority

P1 (High):

  • Configuration option for bind address
  • Input validation (valid IP addresses only)
  • Security warnings in UI

P2 (Medium):

  • Test mode to verify network accessibility
  • Auto-detection of available network interfaces
  • Platform-specific firewall guidance

Alternatives Considered

  1. Reverse proxy (Caddy)Current solution

    • Pros: Battle-tested, native SSE support, can add authentication
    • Cons: External service, additional complexity
  2. Reverse proxy (Nginx)

    • Pros: Widely used, highly configurable
    • Cons: More complex config, additional service to manage
  3. SSH tunneling

    • Pros: Secure by design
    • Cons: Complex setup, not user-friendly
  4. socat/netcat (Previous workaround)

    • Pros: Lightweight
    • Cons: Platform-specific, no authentication, requires manual management

Related Issues

  • #5 - Authentication Support (recommended companion feature for network-exposed deployments)

Willingness to Contribute

I'd be happy to help test this feature or contribute to the implementation if guidance is provided.


Environment:

  • Nowledge Mem Version: 0.4.9
  • Operating System: Linux (Arch Linux)
  • Current Workaround: Caddy reverse proxy with token authentication
  • Network: Tailscale private network (100.64.0.0/10)

ferstar avatar Nov 09 '25 12:11 ferstar