Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Server

easy-db-lab includes a server mode that provides AI assistant integration via MCP (Model Context Protocol), REST status endpoints, and live metrics streaming. This enables Claude to directly interact with your clusters, and provides programmatic access to cluster status.

The server exposes tools for all supported databases — Cassandra, ClickHouse, OpenSearch, and Spark — as well as cluster lifecycle management and observability.

Starting the Server

To start the server, run:

easy-db-lab server

By default, the server picks an available port. To specify a port:

easy-db-lab server --port 8888

The server automatically generates a .mcp.json configuration file in the current directory with the connection details.

Adding to Claude Code

Once the server is running, start Claude Code from the same directory:

claude

Claude Code automatically detects and uses the .mcp.json file generated by the server.

Available Tools

The server exposes commands annotated with @McpCommand as MCP tools to Claude. Tool names use underscores and are derived from the command's package namespace.

Cluster Lifecycle

Tool NameDescription
initInitialize a directory for easy-db-lab
upProvision AWS infrastructure
cassandra_downShut down AWS infrastructure
cleanClean up generated files
statusDisplay full environment status
hostsList all hosts in the cluster
ipGet IP address for a host by alias

Cassandra Management

Tool NameDescription
cassandra_useSelect a Cassandra version
cassandra_listList available Cassandra versions
cassandra_startStart Cassandra on all nodes
cassandra_restartRestart Cassandra on all nodes
cassandra_update_configApply configuration patch to nodes

Cassandra Stress Testing

Tool NameDescription
cassandra_stress_startStart a stress job on K8s
cassandra_stress_stopStop and delete stress jobs
cassandra_stress_statusCheck status of stress jobs
cassandra_stress_logsView logs from stress jobs
cassandra_stress_listList available workloads
cassandra_stress_fieldsList available field generators
cassandra_stress_infoShow workload information

ClickHouse

Tool NameDescription
clickhouse_startDeploy ClickHouse cluster to K8s
clickhouse_stopRemove ClickHouse cluster
clickhouse_statusCheck ClickHouse cluster status

OpenSearch

Tool NameDescription
opensearch_startCreate AWS OpenSearch domain
opensearch_stopDelete OpenSearch domain
opensearch_statusCheck OpenSearch domain status

Spark

Tool NameDescription
spark_submitSubmit Spark job to EMR cluster
spark_statusCheck status of a Spark job
spark_jobsList recent Spark jobs
spark_logsDownload EMR logs from S3

Kubernetes

Tool NameDescription
k8_applyApply observability stack to K8s

Utilities

Tool NameDescription
prune_amisPrune older private AMIs

Tool Naming Convention

MCP tool names are derived from the command's package location:

  • Top-level commands: status, hosts, ip, clean, init, up
  • Cassandra commands: cassandra_ prefix (e.g., cassandra_start, cassandra_use)
  • Nested commands: cassandra_stress_ prefix (e.g., cassandra_stress_start)
  • Hyphens become underscores: update-configcassandra_update_config

Benefits of Server Integration

BenefitDescription
Direct ControlClaude executes easy-db-lab commands directly without manual intervention
Context AwarenessClaude maintains context about your cluster state and configuration
AutomationComplex multi-step operations can be automated through Claude
Intelligent AssistanceClaude can analyze logs, metrics, and provide optimization recommendations

Example Workflow

  1. Start the server in one terminal:

    easy-db-lab server
    
  2. In another terminal, start Claude Code from the same directory:

    claude
    

    Claude Code automatically detects the .mcp.json file generated by the server.

  3. Ask Claude to help manage your cluster:

    • "Initialize a new 5-node cluster with i4i.xlarge instances"
    • "Check the status of all nodes"
    • "Select Cassandra version 5.0 and start it"
    • "Start a KeyValue stress test for 1 hour"
    • "Deploy ClickHouse and check its status"
    • "Create an OpenSearch domain and monitor its progress"
    • "Submit a Spark job to the EMR cluster"

Live Metrics Streaming

When Redis is configured via the EASY_DB_LAB_REDIS_URL environment variable, the server publishes live cluster metrics to the Redis pub/sub channel every 5 seconds. Metrics are queried from VictoriaMetrics using the same PromQL expressions as the Grafana dashboards.

Enabling

export EASY_DB_LAB_REDIS_URL=redis://localhost:6379/easydblab-events
easy-db-lab server

Metrics events are published to the same channel as command events. Consumers filter by the event.type field.

Event Types

Only metrics for running services are published. If the cluster is running ClickHouse instead of Cassandra, no Cassandra metrics events are emitted.

Metrics.System

Published every 5 seconds with per-node CPU, memory, disk I/O, and filesystem metrics:

{
  "timestamp": "2026-03-08T14:22:05.123Z",
  "commandName": "server",
  "event": {
    "type": "Metrics.System",
    "nodes": {
      "db-0": {
        "cpuUsagePct": 34.2,
        "memoryUsedBytes": 17179869184,
        "diskReadBytesPerSec": 52428800.0,
        "diskWriteBytesPerSec": 104857600.0,
        "filesystemUsedPct": 45.2
      },
      "db-1": {
        "cpuUsagePct": 28.7,
        "memoryUsedBytes": 16106127360,
        "diskReadBytesPerSec": 41943040.0,
        "diskWriteBytesPerSec": 83886080.0,
        "filesystemUsedPct": 42.8
      }
    }
  }
}

Metrics.Cassandra

Published every 5 seconds when the cluster is running Cassandra:

{
  "timestamp": "2026-03-08T14:22:05.187Z",
  "commandName": "server",
  "event": {
    "type": "Metrics.Cassandra",
    "readP99Ms": 1.247,
    "writeP99Ms": 0.832,
    "readOpsPerSec": 15234.5,
    "writeOpsPerSec": 12087.3,
    "compactionPending": 3,
    "compactionCompletedPerSec": 1.5,
    "compactionBytesWrittenPerSec": 52428800.0
  }
}

Field Reference

System — per node:

FieldTypeDescription
cpuUsagePctdoubleCPU usage percentage (0-100)
memoryUsedByteslongMemory used in bytes
diskReadBytesPerSecdoubleDisk read throughput (bytes/sec)
diskWriteBytesPerSecdoubleDisk write throughput (bytes/sec)
filesystemUsedPctdoubleFilesystem usage percentage (0-100)

Cassandra — cluster-wide:

FieldTypeDescription
readP99MsdoubleRead latency p99 in milliseconds
writeP99MsdoubleWrite latency p99 in milliseconds
readOpsPerSecdoubleRead operations per second
writeOpsPerSecdoubleWrite operations per second
compactionPendinglongNumber of pending compactions
compactionCompletedPerSecdoubleCompactions completed per second
compactionBytesWrittenPerSecdoubleCompaction write throughput (bytes/sec)

Notes

  • The server requires Docker to be installed
  • Your AWS profile must be configured (easy-db-lab setup-profile)
  • The server runs in the foreground and logs to stdout
  • Use Ctrl+C to stop the server