Skip to content

Latest commit

 

History

History
660 lines (522 loc) · 19.7 KB

File metadata and controls

660 lines (522 loc) · 19.7 KB

Active Work Log

2025-11-17: Docker Build & Local Binary Completed

Status: HANDOFF TO DESKTOP - READY FOR VPS DEPLOYMENT & API KEY GENERATION

Completed by Code - Session 1 (Docker Build)

  1. ✓ Docker installation on Linux environment
  2. ✓ Dockerfile creation (multi-stage build with Alpine)
  3. ✓ docker-compose.yml configuration
  4. ✓ .dockerignore setup
  5. ✓ Docker image build successful
    • Image: nexus-mcp:latest
    • Image ID: a58718be6843
    • Size: 324MB (99.7MB compressed)

Docker Configuration Summary

  • Base Images: .NET 9.0 Alpine (SDK for build, ASP.NET for runtime)
  • Build Type: Self-contained, single-file binary
  • Platform: linux-musl-x64
  • Port: 18080 (HTTP transport)
  • Network: External network nexus-network
  • Volume: /home/linux/Nexus-Data mounted as read-only to /data/event-store

Environment Variables

  • NEXUS_TRANSPORT=http
  • NEXUS_MCP_PORT=18080
  • CONTEXT_LIBRARY_PATH=/data/event-store
  • QDRANT_URL=http://qdrant:6333
  • QDRANT_API_KEY=${QDRANT_API_KEY} (from .env)
  • EMBEDDING_API_URL=http://embedding:5000/embed

Completed by Code - Session 2 (Local Binary Build)

  1. ✓ Cleaned previous builds
  2. ✓ Built single-file self-contained binary for local testing
  3. ✓ Made binary executable
  4. ✓ Tested binary with JSON-RPC initialize request

Local Binary Configuration

  • Binary Location: /home/linux/FnMCP.Nexus/bin/local/FnMCP.Nexus
  • Binary Size: 97MB
  • Build Configuration: Release, linux-x64, self-contained, single-file
  • Test Status: Successfully responds to JSON-RPC requests in stdio mode
  • Version: 0.3.0+2d64dcb16d1b6c2331f354ea242eaf928c893dfd

Usage

./bin/local/FnMCP.Nexus /home/linux/Nexus-Data

This binary can be used for:

  • Generating API keys in stdio mode
  • Local testing without Docker
  • Desktop MCP client integration

Next Steps for Desktop

Option A: Use Local Binary for API Key Generation

  1. Run the local binary: ./bin/local/FnMCP.Nexus /home/linux/Nexus-Data
  2. Use stdio mode to generate API keys
  3. Test MCP prompts and tools locally

Option B: VPS Deployment with Docker

  1. Deploy to VPS using the built Docker image
  2. Set up the nexus-network external network on VPS
  3. Configure .env file with QDRANT_API_KEY
  4. Ensure Qdrant and embedding services are running
  5. Verify /home/linux/Nexus-Data exists and contains event-store data
  6. Start container: docker-compose up -d
  7. Verify connectivity on port 18080

Files Ready

  • ./bin/local/FnMCP.Nexus - Local single-file binary (97MB) for stdio mode
  • Dockerfile - Multi-stage build configuration
  • docker-compose.yml - Service orchestration
  • .dockerignore - Build optimization
  • Docker image: nexus-mcp:latest (can be exported/pushed if needed)

Notes

  • Build completed with minor Oxpecker version resolution (1.0.0 vs 0.20.0) - no functional impact
  • ICU libraries included for globalization support
  • Container configured with restart policy: unless-stopped

2025-11-18: SSE Endpoint Naming Fix - Ready for Deployment

Status: ✅ CODE UPDATED - READY FOR BUILD & DEPLOY

Completed by Code - Session 4 (SSE Endpoint Naming)

  1. ✓ Identified endpoint naming issue: /sse/events was misleading
  2. ✓ Updated SSE endpoint from /sse/events to /sse
  3. ✓ Updated HttpServer.fs route configuration
  4. ✓ Updated Tools.fs API key generation message
  5. ✓ Verified SseTransport welcome message (already correct)
  6. ✓ Committed changes to git

Changes Made

File: src/FnMCP.Nexus/Http/HttpServer.fs

  • Changed SSE route from route "/events" to route ""
  • Updated comment: "SSE stream endpoint for all MCP operations (tools, resources, prompts)"
  • Updated log message: /sse/events/sse

File: src/FnMCP.Nexus/Tools.fs

  • Updated API key generation output: https://mcp.nexus.ivanthegeek.com/sse/events.../sse

Rationale: The SSE endpoint name /sse/events was misleading because it handles ALL MCP operations (tools, resources, prompts), not just events. The generic /sse name better reflects that this is the SSE transport endpoint for the entire MCP protocol.

Next Steps for Next Session

  1. Build Docker image with updated code

    docker build -t nexus-mcp:fixed .
  2. Export and transfer to VPS

    docker save nexus-mcp:fixed | gzip > /tmp/nexus-mcp-fixed-v2.tar.gz
    scp /tmp/nexus-mcp-fixed-v2.tar.gz root@66.179.208.238:/tmp/
  3. Deploy on VPS

    ssh root@66.179.208.238 "docker load < /tmp/nexus-mcp-fixed-v2.tar.gz && \
      docker tag nexus-mcp:fixed nexus-mcp:latest && \
      docker stop nexus-mcp && docker rm nexus-mcp && \
      docker run -d --name nexus-mcp \
        -v /data/event-store:/data/event-store \
        --restart unless-stopped nexus-mcp:latest"
  4. Test updated endpoint

    # Old endpoint (should 404)
    curl -H "Authorization: Bearer KEY" http://66.179.208.238:18080/sse/events
    
    # New endpoint (should work)
    curl -H "Authorization: Bearer KEY" http://66.179.208.238:18080/sse
  5. Update Claude Desktop config to use new endpoint:

    {
      "mcpServers": {
        "nexus-vps": {
          "url": "http://66.179.208.238:18080/sse",
          "transport": {
            "type": "sse",
            "headers": {
              "Authorization": "Bearer KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4="
            }
          }
        }
      }
    }

Commit Information

Commit: 0742fb8 Message: Fix SSE endpoint naming: /sse/events -> /sse


2025-11-19: VPS Deployment Complete - SSE/WebSocket Operational

Status: ✅ PRODUCTION READY - MCP SERVER ACCESSIBLE VIA HTTP/SSE

Completed by Code - Session 3 (VPS Deployment & Troubleshooting)

  1. ✓ VPS container deployment verified (running 33+ hours)
  2. ✓ Identified and fixed firewall blocking issue
    • Issue: Cloud provider firewall blocking port 18080
    • Solution: Added UFW firewall rule + cloud provider firewall rule
  3. ✓ API key authentication system operational
  4. ✓ Generated production API key with full access
  5. ✓ Verified SSE connection establishment and authentication
  6. ✓ Updated Claude Desktop MCP configuration to use SSE transport

VPS Server Status

Endpoint Information:

Security:

  • All endpoints (except health check) require Bearer token authentication
  • API keys stored as hashed events in event store
  • Authentication logging for usage tracking and security auditing

Production API Key

API Key: KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4=
Key ID: b8969ef4-e02e-459d-a6a8-efe52378976a
Scope: full_access (no expiration)
Description: Claude Desktop access key
Generated: 2025-11-19T02:37:15Z

⚠️ Stored securely - Key hash stored at: /data/event-store/nexus/events/system/api-keys/2025-11/2025-11-19T02-37-15Z_ApiKeyGenerated_b8969ef4_0a1cdcee.yaml

Claude Desktop Configuration

Updated configuration at ~/.config/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "nexus-vps": {
      "url": "http://66.179.208.238:18080/sse",
      "transport": {
        "type": "sse",
        "headers": {
          "Authorization": "Bearer KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4="
        }
      }
    }
  }
}

Configuration Change:

  • Before: SSH → Docker exec with stdio transport (slow, SSH overhead)
  • After: Direct HTTP/SSE with Bearer authentication (fast, native HTTP)

Connection Verification

Test Results:

# Health check
curl http://66.179.208.238:18080/
{"service":"Nexus MCP Server","status":"ok","timestamp":"...","transport":"http","version":"0.3.0"}

# SSE with authentication
curl -H "Authorization: Bearer KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4=" \
     http://66.179.208.238:18080/sse/events
# [Connection established, SSE welcome sent]

Logs confirm:

[SseTransport] SSE connection established
[SseTransport] SSE welcome sent, keeping connection alive
Request finished HTTP/1.1 GET .../sse/events - 200 - text/event-stream

Firewall Configuration

UFW (Server Firewall):

ufw allow 18080/tcp  # Added for MCP HTTP transport

Active UFW Rules:

  • 22/tcp (SSH)
  • 80/tcp (HTTP)
  • 443/tcp (HTTPS)
  • 6333/tcp (Qdrant)
  • 18080/tcp (Nexus MCP) ← NEW

Cloud Provider Firewall:

  • Configured to allow inbound TCP 18080 from 0.0.0.0/0

API Key Management

Generate new keys:

ssh root@66.179.208.238 "docker exec -i nexus-mcp ./FnMCP.Nexus /data/event-store generate-api-key \
  --scope <full_access|read_only|files_only_public> \
  --description 'Key description' \
  --expires-in-days 90"  # Optional expiration

Available scopes:

  • full_access - All MCP operations and resources
  • read_only - Resources and read-only tools
  • files_only_public - Only public classification files

Next Steps

  1. Restart Claude Desktop to load new MCP configuration
  2. Verify MCP connection in Claude Desktop
  3. Test MCP tools (create_event, timeline_projection, etc.)
  4. Monitor API key usage in event store logs
  5. Consider: Set up reverse proxy with HTTPS (nginx/caddy) for production SSL

Files Modified

  • ~/.config/Claude/claude_desktop_config.json - Updated MCP server configuration
  • active-work.md - This status update

Architecture Notes

Why SSE over stdio?

  • ✅ Native HTTP transport (faster, more reliable)
  • ✅ No SSH overhead
  • ✅ Secure API key authentication
  • ✅ Works from anywhere with internet access
  • ✅ Standard transport supported by MCP spec
  • ✅ Better for production deployments

Event Sourcing Benefits:

  • API key lifecycle tracked as events
  • Usage logging for security auditing
  • Revocation support built-in
  • Key expiration enforcement

2025-11-19: SSE Endpoint Fix Deployed - Production Updated

Status: ✅ DEPLOYED - SSE ENDPOINT UPDATED TO /sse

Completed by Code - Session 5 (Debug & Deploy)

  1. ✓ Identified SSE endpoint mismatch (VPS running old code with /sse/events)
  2. ✓ Diagnosed Docker BuildKit issues on local machine (builds hanging)
  3. ✓ Transferred source code to VPS via tar/scp
  4. ✓ Built Docker image directly on VPS (successful in 32 seconds)
  5. ✓ Deployed updated container with HTTP transport configuration
  6. ✓ Verified new /sse endpoint works correctly
  7. ✓ Confirmed old /sse/events endpoint returns 404

Root Cause Analysis

Issue: VPS container was running old code with SSE endpoint at /sse/events instead of /sse

Evidence:

  • Code was updated in commit 0742fb8 (Nov 18)
  • VPS container was never rebuilt after the code change
  • Old endpoint /sse/events worked, new /sse returned 404

Docker BuildKit Issue on Local Machine:

  • Docker builds hung indefinitely during initial stages
  • BuildKit failed to progress beyond "load build definition"
  • Root cause: BuildKit incompatibility or corruption on local machine
  • Workaround: Build on VPS where Docker works correctly

Deployment Details

Build Method:

# Transfer source
tar czf /tmp/fnmcp-nexus-src.tar.gz --exclude='bin' --exclude='.git' ... -C /home/linux FnMCP.Nexus
scp /tmp/fnmcp-nexus-src.tar.gz root@66.179.208.238:/tmp/
ssh root@66.179.208.238 "cd /root && tar xzf /tmp/fnmcp-nexus-src.tar.gz"

# Build on VPS
ssh root@66.179.208.238 "cd /root/FnMCP.Nexus && docker build -t nexus-mcp:fixed ."

Container Configuration:

docker run -d --name nexus-mcp \
  -v /data/event-store:/data/event-store \
  -e NEXUS_TRANSPORT=http \
  -e ASPNETCORE_URLS=http://+:18080 \
  -p 18080:18080 \
  --restart unless-stopped \
  nexus-mcp:latest /data/event-store

Verification Results

✅ New endpoint works:

curl -H "Authorization: Bearer KEY" http://66.179.208.238:18080/sse
# HTTP/1.1 200 OK
# Content-Type: text/event-stream
# [SSE stream established]

✅ Old endpoint gone:

curl -I http://66.179.208.238:18080/sse/events
# HTTP/1.1 404 Not Found

✅ Server logs confirm:

[HttpServer] HTTP server configured:
[HttpServer]   - Health check: http://0.0.0.0:18080/
[HttpServer]   - SSE endpoint: http://0.0.0.0:18080/sse
[HttpServer]   - SSE message: http://0.0.0.0:18080/sse/message
[HttpServer]   - WebSocket: ws://0.0.0.0:18080/ws
[SseTransport] SSE connection established
[SseTransport] SSE welcome sent, keeping connection alive

Claude Desktop Configuration

Current (correct) configuration:

{
  "mcpServers": {
    "nexus-vps": {
      "url": "http://66.179.208.238:18080/sse",
      "transport": {
        "type": "sse",
        "headers": {
          "Authorization": "Bearer KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4="
        }
      }
    }
  }
}

Next Steps

  1. Restart Claude Desktop to ensure it uses the correct endpoint
  2. Fix Docker on local machine to enable local builds
    • Investigate BuildKit corruption
    • Consider reinstalling Docker or resetting BuildKit state
  3. Test MCP connection from Claude Desktop
  4. Monitor SSE performance and connection stability

Files Modified

  • VPS: /root/FnMCP.Nexus/ - Updated source code
  • VPS: Docker image nexus-mcp:latest - Rebuilt with latest code
  • VPS: Container nexus-mcp - Redeployed with HTTP transport
  • Local: active-work.md - This documentation
  • Local: docs/2025-11-19-sse-debug-deployment.md - Detailed debug report

Detailed Report

For a comprehensive step-by-step analysis including timeline, issues discovered, and command reference, see: SSE Transport Debug & Deployment Report

This report contains:

  • Complete timeline of debugging steps
  • Detailed issue analysis and root causes
  • Docker BuildKit troubleshooting attempts
  • Full deployment configuration
  • Verification checklist
  • AI-readable structured data
  • Command reference for future deployments

Technical Notes

Docker Build Performance:

  • Local machine: BuildKit hangs indefinitely
  • VPS build: 32 seconds (successful)
  • Solution: Build on VPS until local Docker is fixed

Container Restart Issue:

  • Initial deployment failed (container restarting)
  • Cause: Missing NEXUS_TRANSPORT=http environment variable
  • Fix: Added -e NEXUS_TRANSPORT=http to docker run command

SSE Endpoint Naming:

  • Previous: /sse/events (misleading - handles all MCP operations)
  • Current: /sse (accurately represents SSE transport endpoint)

2025-11-20: Claude Desktop SSE Configuration Fixed

Status: ✅ CONFIGURED - READY FOR TESTING

Completed by Code - Session 5 Continued (Config Fix)

  1. ✓ Reviewed Claude Desktop logs
  2. ✓ Identified configuration issues in claude_desktop_config.json
  3. ✓ Fixed SSE transport configuration
  4. ✓ Verified server endpoint operational
  5. ✓ Created configuration documentation

Configuration Issues Fixed

File: /home/linux/.config/Claude/claude_desktop_config.json

Problems Found:

  1. Wrong protocol: https instead of http
  2. Wrong host: mcp.nexus.ivanthegeek.com instead of 66.179.208.238
  3. Wrong auth structure: Using apiKey field instead of transport.headers.Authorization
  4. Missing transport type specification

Before (BROKEN):

{
  "mcpServers": {
    "Nexus": {
      "url": "https://mcp.nexus.ivanthegeek.com:18080/sse",
      "apiKey": "KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4="
    }
  }
}

After (WORKING):

{
  "mcpServers": {
    "Nexus": {
      "url": "http://66.179.208.238:18080/sse",
      "transport": {
        "type": "sse",
        "headers": {
          "Authorization": "Bearer KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4="
        }
      }
    }
  }
}

Verification Results

Server Health: ✅ Operational

{
  "service": "Nexus MCP Server",
  "status": "ok",
  "version": "0.3.0",
  "transport": "http"
}

SSE Endpoint: ✅ Accepting connections

[SseTransport] SSE connection established
[SseTransport] SSE welcome sent, keeping connection alive

Next Steps

  1. Restart Claude Desktop to load new configuration
  2. Test MCP connection - should connect via SSE
  3. Verify tools/prompts/resources are available
  4. Monitor performance vs SSH/stdio transport

Files Modified

  • Local: ~/.config/Claude/claude_desktop_config.json - Fixed SSE configuration
  • Local: claude-desktop-sse-config-fixed.md - Configuration documentation
  • Local: active-work.md - This update

Expected Benefits

Performance:

  • Faster response times (no SSH overhead)
  • More reliable connections
  • Better error handling

Architecture:

  • Proper SSE transport per MCP spec
  • Direct HTTP connection to VPS
  • Ready for production use

2025-11-20: HTTP Streaming Transport Migration Complete

Status: ✅ DEPLOYED - HTTP STREAMING TRANSPORT ACTIVE

Completed by Code - Session 6 (HTTP Streaming Migration)

  1. ✓ Created HttpStreamingTransport.fs module for bidirectional streaming
  2. ✓ Updated HttpServer.fs to support new /mcp endpoint
  3. ✓ Maintained backward compatibility with SSE endpoints (marked deprecated)
  4. ✓ Built and tested locally with HTTP streaming
  5. ✓ Deployed to VPS with Docker image nexus-mcp:http-streaming
  6. ✓ Updated Claude Desktop configuration to use HTTP transport
  7. ✓ Verified authentication and session management working

Technical Implementation

New HTTP Streaming Transport:

  • Single POST endpoint: /mcp
  • Bidirectional streaming over persistent connection
  • NDJSON format (newline-delimited JSON)
  • Session ID generation via Mcp-Session-Id header
  • Proper error handling with JSON-RPC error codes

File Changes:

  • Created: src/FnMCP.Nexus/Transport/HttpStreamingTransport.fs
  • Updated: src/FnMCP.Nexus/Http/HttpServer.fs
  • Updated: src/FnMCP.Nexus/FnMCP.Nexus.fsproj
  • Updated: src/FnMCP.Nexus/Tools.fs

Endpoint Configuration

Current Endpoints:

Health: http://66.179.208.238:18080/
HTTP Streaming: http://66.179.208.238:18080/mcp [POST] ← PRIMARY
SSE (deprecated): http://66.179.208.238:18080/sse
WebSocket: ws://66.179.208.238:18080/ws

Claude Desktop Configuration

Updated to HTTP transport:

{
  "mcpServers": {
    "Nexus": {
      "url": "http://66.179.208.238:18080/mcp",
      "transport": {
        "type": "http",
        "headers": {
          "Authorization": "Bearer KvzmKD3aBYBmKY4pvOh/+NhwHBBxxiTeIKD2Kq/tAw4="
        }
      }
    }
  }
}

Verification Tests

HTTP Streaming Endpoint:

echo '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{"roots":{}}},"id":1}' | \
  curl -X POST -H "Authorization: Bearer KEY" -H "Content-Type: application/x-ndjson" \
  --data-binary @- http://66.179.208.238:18080/mcp

Response: Successful with session ID generation

Migration Benefits

Performance Improvements:

  • Single connection reduces overhead (vs SSE's GET + POST)
  • Bidirectional streaming enables real-time notifications
  • More efficient message exchange with NDJSON format

Architecture Benefits:

  • Follows current MCP specification standards
  • Simpler client implementation
  • Better error handling and session management
  • Maintains backward compatibility during transition

Docker Deployment

Container: nexus-mcp:http-streaming Status: Running (Container ID: fe8e6ed379bd) Restart Policy: unless-stopped Port Mapping: 18080:18080

Next Steps

  1. Monitor Performance - Track response times and connection stability
  2. Test Claude Desktop - Verify MCP tools work with new transport
  3. Deprecation Timeline - Plan removal of SSE endpoints after stability confirmed
  4. Documentation - Update API documentation with HTTP streaming examples