Skip to content

Latest commit

Β 

History

History
393 lines (323 loc) Β· 13 KB

File metadata and controls

393 lines (323 loc) Β· 13 KB

HUMMBL MCP Server: OLD vs NEW Architecture

Date: 2026-01-21 Status: NEW architecture implemented, enhancements planned


Quick Summary

Aspect OLD Version NEW Version
Purpose Stateless mental models lookup Stateful sessions + observability
Storage None (ephemeral) Redis (cache) + D1 (persistent)
Observability None Full stack (logs, metrics, traces)
Complexity ~500 LOC ~2,000+ LOC
Deployment stdio only stdio + potential HTTP/SSE
State None Session + History tracking

Architecture Comparison

OLD Version: Minimal MCP Server

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         MCP Client (Claude)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚ stdio
                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          HUMMBL MCP Server           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Tools Layer (6 tools)       β”‚  β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
β”‚  β”‚   Resources (3 URIs)          β”‚  β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
β”‚  β”‚   Base120 Framework (data)    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Characteristics:

  • βœ… Simple, fast, reliable
  • βœ… Perfect for read-only mental models
  • ❌ No state persistence
  • ❌ No usage tracking
  • ❌ Can't build on previous interactions

NEW Version: Production-Ready with Persistence

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         MCP Client (Claude)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚ stdio
                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               HUMMBL MCP Server                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚          Tools Layer (6 + new)                β”‚  β”‚
β”‚  β”‚    β€’ get_model                                β”‚  β”‚
β”‚  β”‚    β€’ search_models                            β”‚  β”‚
β”‚  β”‚    β€’ recommend_models                         β”‚  β”‚
β”‚  β”‚    β€’ [future: guided workflows]               β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                           β”‚                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚          Storage Layer                        β”‚  β”‚
β”‚  β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚  β”‚
β”‚  β”‚    β”‚ Session Mgr  β”‚    β”‚ History Mgr  β”‚     β”‚  β”‚
β”‚  β”‚    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  β”‚
β”‚  β”‚           β”‚                     β”‚             β”‚  β”‚
β”‚  β”‚    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”     β”‚  β”‚
β”‚  β”‚    β”‚ Redis Client β”‚    β”‚  D1 Client   β”‚     β”‚  β”‚
β”‚  β”‚    β”‚  (cache)     β”‚    β”‚ (durable)    β”‚     β”‚  β”‚
β”‚  β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                           β”‚                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚       Observability Layer                     β”‚  β”‚
β”‚  β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚  β”‚
β”‚  β”‚    β”‚ Logger β”‚  β”‚ Metrics β”‚  β”‚ Tracing  β”‚    β”‚  β”‚
β”‚  β”‚    β”‚(struct)β”‚  β”‚(Prom)   β”‚  β”‚ (OTEL)   β”‚    β”‚  β”‚
β”‚  β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                           β”‚                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚          Base120 Framework                    β”‚  β”‚
β”‚  β”‚         (120 Mental Models)                   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                    β”‚
           β–Ό                    β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  Redis   β”‚        β”‚ Cloudflare β”‚
     β”‚  Cache   β”‚        β”‚     D1     β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Characteristics:

  • βœ… All benefits of OLD version
  • βœ… State persistence across conversations
  • βœ… Multi-turn workflows possible
  • βœ… Production observability (logs, metrics, traces)
  • βœ… Usage analytics capability
  • βœ… Scalable architecture (cache + database)

Detailed Component Comparison

1. Tools Layer

OLD

// 6 basic tools, no state
- get_model(code)
- list_all_models(filter?)
- search_models(query)
- recommend_models(problem)
- get_transformation(key)
- search_problem_patterns(query)

NEW

// Same 6 tools + infrastructure for stateful tools
- [All above tools] βœ…
- [PLANNED] apply_guided_workflow(problem, type)
- [PLANNED] get_my_usage_stats(period)

2. Storage Layer

OLD

❌ None - fully stateless

NEW

βœ… SessionManager
   - Redis cache (hot data, 24h TTL)
   - D1 database (cold storage, permanent)
   - Session versioning (optimistic locking)
   - Activity tracking

βœ… HistoryManager
   - Message history per session
   - Conversation context preservation
   - Replay capabilities

Storage Flow:

Request β†’ SessionManager.get(sessionId)
            ↓
        Redis Check
            β”œβ”€β”€ HIT β†’ return from Redis
            └── MISS β†’ fetch from D1 β†’ cache in Redis

Update β†’ SessionManager.update(session)
            ↓
         Write to Redis (immediate)
            ↓
         Write to D1 (async, durable)

3. Observability Layer

OLD

❌ None - no visibility into usage

NEW

βœ… Logger (src/observability/logger.ts)
   - Structured JSON logs
   - Contextual data (userId, sessionId)
   - Log levels (debug, info, warn, error)
   - Timer decorators for performance

βœ… Metrics (src/observability/metrics.ts)
   - Counter: session create/get/update counts
   - Gauge: active sessions
   - Histogram: operation durations
   - Cache hit/miss rates

βœ… Tracing (src/observability/tracing.ts)
   - OpenTelemetry instrumentation
   - Span creation with @trace decorator
   - Distributed tracing ready
   - Performance profiling

Metrics Available:

- session_create_total
- session_create_duration_seconds
- cache_hit_total / cache_miss_total
- active_sessions_count
- d1_write_total / d1_read_total

4. Type System

OLD

// Basic types only
- MentalModel
- Transformation
- ProblemPattern
- Result<T, E>

NEW

// Enhanced type coverage
- [All OLD types] βœ…
- Session (with metadata)
- SessionMetadata (tracking)
- DomainState (flexible state)
- Message (conversation history)
- MessageRole (user/assistant/system)

Code Organization

OLD Structure

src/
β”œβ”€β”€ index.ts          (80 LOC)
β”œβ”€β”€ server.ts         (27 LOC)
β”œβ”€β”€ framework/
β”‚   └── base120.ts    (~1500 LOC - data)
β”œβ”€β”€ tools/
β”‚   └── models.ts     (405 LOC)
β”œβ”€β”€ resources/
β”‚   └── models.ts     (109 LOC)
β”œβ”€β”€ types/
β”‚   └── domain.ts     (70 LOC)
└── utils/
    └── result.ts     (25 LOC)

Total: ~2,200 LOC (mostly data)

NEW Structure

src/
β”œβ”€β”€ index.ts                      (26 LOC)
β”œβ”€β”€ server.ts                     (27 LOC)
β”œβ”€β”€ framework/
β”‚   └── base120.ts                (~1500 LOC - data)
β”œβ”€β”€ tools/
β”‚   └── models.ts                 (405 LOC)
β”œβ”€β”€ resources/
β”‚   └── models.ts                 (109 LOC)
β”œβ”€β”€ storage/                      ⭐ NEW
β”‚   β”œβ”€β”€ session-manager.ts        (350 LOC)
β”‚   β”œβ”€β”€ history-manager.ts        (280 LOC)
β”‚   β”œβ”€β”€ redis-client.ts           (100 LOC)
β”‚   └── d1-client.ts             (120 LOC)
β”œβ”€β”€ observability/                ⭐ NEW
β”‚   β”œβ”€β”€ logger.ts                 (180 LOC)
β”‚   β”œβ”€β”€ metrics.ts                (200 LOC)
β”‚   └── tracing.ts                (180 LOC)
β”œβ”€β”€ types/
β”‚   β”œβ”€β”€ domain.ts                 (70 LOC)
β”‚   β”œβ”€β”€ session.ts                ⭐ NEW (80 LOC)
β”‚   └── message.ts                ⭐ NEW (60 LOC)
└── utils/
    β”œβ”€β”€ result.ts                 (25 LOC)
    └── sanitize.ts               ⭐ NEW (120 LOC)

Total: ~3,800 LOC (+73% code, infrastructure)

Performance Characteristics

Operation OLD NEW (Cache Hit) NEW (Cache Miss)
Get Model ~2ms ~2ms ~2ms
Search ~5ms ~5ms ~5ms
Create Session N/A ~15ms (Redis) ~50ms (Redis+D1)
Get Session N/A ~3ms (Redis) ~20ms (D1)
Update Session N/A ~8ms (Redis) ~30ms (Redis+D1)

Memory:

  • OLD: ~10MB (data only)
  • NEW: ~15MB (data + Redis client + OTEL)

Migration Path

If you're on OLD version:

# No breaking changes - NEW is backward compatible
npm install @hummbl/mcp-server@latest

# Optional: Enable storage (requires env vars)
REDIS_URL=redis://localhost:6379
D1_DATABASE_ID=your-d1-id

# Optional: Enable observability
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

If you don't need persistence:

  • NEW version works exactly like OLD (stateless mode)
  • Storage only activates when Redis URL is configured
  • Zero performance penalty if not used

Use Case Fit

When to use OLD architecture:

  • βœ… Simple mental model lookup
  • βœ… One-off queries
  • βœ… No need for history
  • βœ… Minimal dependencies
  • βœ… Learning/experimentation

When to use NEW architecture:

  • βœ… Multi-turn problem solving
  • βœ… Guided workflows
  • βœ… Usage analytics needed
  • βœ… Production deployment
  • βœ… Team/organization rollout
  • βœ… Continuous improvement based on data

What This Enables

With the NEW architecture, we can now build:

  1. Guided Workflows ✨

    • Multi-step problem solving
    • Session-based state tracking
    • Resume interrupted analysis
  2. User Analytics πŸ“Š

    • Which models are most useful
    • Common problem patterns
    • Workflow success rates
  3. Personalization 🎯

    • Recommend models based on user history
    • Adapt to user expertise level
    • Custom workflow templates
  4. Collaboration 🀝

    • Share analysis sessions
    • Team-wide usage patterns
    • Organizational learning
  5. Production Operations πŸš€

    • Monitor health and performance
    • Debug issues with traces
    • Scale based on metrics

Summary

The NEW version is backward compatible but adds a production-grade foundation for:

  • State persistence
  • Multi-turn interactions
  • Usage analytics
  • Operational visibility

The mental models are the same. The capabilities are vastly expanded.


Ready for enhancement implementation. See ENHANCEMENT_PLAN.md for next steps.