A streamable MCP server that leverages virtual tables to interact with an Apache Cassandra cluster.
# Set up development environment
make dev
# Run tests
make test
# Start the server locally
make run
# Start with Docker Compose (includes Cassandra)
make docker-compose-up
# Build Docker image
make docker-build
# See all available commands
make help
-
Install uv - a fast Python package and project manager that replaces pip, pip-tools, pipx, poetry, pyenv, virtualenv, and more. Follow the installation instructions at: https://docs.astral.sh/uv/getting-started/installation/
-
Create and activate development environment:
uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
uv sync
The MCP server can be configured using environment variables or a .env
file. All configuration options are prefixed with CASSANDRA_
.
-
Copy the example configuration:
cp .env.test .env
-
Edit
.env
with your Cassandra cluster settings:# Cassandra connection settings CASSANDRA_CONTACT_POINTS=localhost # Comma-separated list: host1,host2,host3 # Or use CASSANDRA_HOST for single host (Docker-friendly): # CASSANDRA_HOST=cassandra CASSANDRA_PORT=9042 # Cassandra native port CASSANDRA_DATACENTER=datacenter1 # Your datacenter name CASSANDRA_USERNAME=cassandra # Optional: authentication username CASSANDRA_PASSWORD=cassandra # Optional: authentication password CASSANDRA_PROTOCOL_VERSION=5 # Optional: protocol version (default: 5) LOG_LEVEL=INFO # Optional: DEBUG, INFO, WARNING, ERROR
Environment Variable | Description | Default | Required |
---|---|---|---|
CASSANDRA_CONTACT_POINTS |
Comma-separated list of contact points | localhost |
No |
CASSANDRA_HOST |
Single host (alternative to CONTACT_POINTS) | None | No |
CASSANDRA_PORT |
Cassandra native protocol port | 9042 |
No |
CASSANDRA_DATACENTER |
Cassandra datacenter name | datacenter1 |
No |
CASSANDRA_USERNAME |
Authentication username | None | No |
CASSANDRA_PASSWORD |
Authentication password | None | No |
CASSANDRA_PROTOCOL_VERSION |
Cassandra protocol version | 5 |
No |
LOG_LEVEL |
Logging level (DEBUG, INFO, WARNING, ERROR) | INFO |
No |
Note: Use either CASSANDRA_CONTACT_POINTS
or CASSANDRA_HOST
, not both. CASSANDRA_HOST
is preferred for Docker environments.
Additional environment variables for testing:
Environment Variable | Description | Default | Required |
---|---|---|---|
CASSANDRA_TEST_KEYSPACE |
Keyspace for integration tests | mcp_test |
No |
CASSANDRA_TEST_CONTACT_POINTS |
Override contact points for tests | None | No |
CASSANDRA_TEST_DATACENTER |
Override datacenter for tests | None | No |
CLEANUP_TEST_DATA |
Clean up test data after tests | false |
No |
To run the MCP server in development mode:
# Run with uv
uv run python main.py
# Or if you have the virtual environment activated
python main.py
The server will:
- Load configuration from environment variables or
.env
file - Connect to your Cassandra cluster
- Start the MCP server on HTTP transport (default port: 8000)
The easy-cass-mcp server can be used with Claude Desktop or any MCP-compatible client through the MCP proxy.
The easiest way to install and configure the MCP proxy for Claude Desktop is:
-
First, ensure the MCP server is running:
uv run python main.py
-
In another terminal, install the proxy to Claude Desktop:
fastmcp install claude-desktop ecm/proxy.py:proxy
This command automatically configures Claude Desktop to use the Cassandra MCP proxy.
If you prefer manual configuration, add the following to your claude_desktop_config.json
:
{
"mcpServers": {
"cassandra": {
"command": "uv",
"args": ["run", "python", "/path/to/easy-cass-mcp/proxy.py"],
"env": {
"CASSANDRA_HOST": "localhost",
"CASSANDRA_PORT": "9042",
"CASSANDRA_DATACENTER": "datacenter1"
}
}
}
}
Replace /path/to/easy-cass-mcp
with the actual path to your easy-cass-mcp directory.
Once connected, the following tools are available through the MCP interface:
query_all_nodes
: Execute a CQL query on all nodes in the clusterquery_node
: Execute a CQL query on a specific nodeget_cluster_info
: Get detailed cluster information including topologyget_node_status
: Get status information for all nodesget_keyspace_info
: Get information about a specific keyspaceget_table_info
: Get detailed information about a tableget_virtual_tables
: List all available virtual tables
After configuring the MCP server, you can use natural language to interact with your Cassandra cluster:
- "Show me the disk usage across all nodes"
- "What's the status of my Cassandra cluster?"
- "List all keyspaces and their replication settings"
- "Show me the schema for the users table in my_keyspace"
- "Execute SELECT * FROM system_views.disk_usage on all nodes"
The easiest way to run the Cassandra MCP server is using Docker:
# Build and run with docker-compose (includes Cassandra)
make docker-compose-up
# Or build just the MCP server image
make docker-build
# Run with an existing Cassandra cluster
make docker-run CASSANDRA_HOST=your-cassandra-host
# Build a release (runs tests and builds Docker image)
make release
# Push to Docker registry
make docker-push DOCKER_REGISTRY=your-registry.com
The Docker container supports the following environment variables:
Environment Variable | Description | Default |
---|---|---|
CASSANDRA_HOST |
Cassandra hostname or IP (preferred for Docker) | cassandra |
CASSANDRA_CONTACT_POINTS |
Alternative: comma-separated list of hosts | None |
CASSANDRA_PORT |
Cassandra native protocol port | 9042 |
CASSANDRA_DATACENTER |
Cassandra datacenter name | datacenter1 |
CASSANDRA_USERNAME |
Authentication username | None |
CASSANDRA_PASSWORD |
Authentication password | None |
LOG_LEVEL |
Logging level (DEBUG, INFO, WARNING, ERROR) | INFO |
Note: For Docker environments, CASSANDRA_HOST
is preferred over CASSANDRA_CONTACT_POINTS
for single-host connections.
The docker-compose.yml
file includes:
- mcp-server: The Cassandra MCP server (port 8000)
- cassandra: A Cassandra 4.1 instance for local development (port 9042)
To use with your own Cassandra cluster, modify the environment variables in docker-compose.yml
or create a .env
file:
# .env file for docker-compose
CASSANDRA_HOST=my-cassandra-cluster.example.com
# Or for multiple hosts:
# CASSANDRA_CONTACT_POINTS=host1.example.com,host2.example.com,host3.example.com
CASSANDRA_PORT=9042
CASSANDRA_DATACENTER=datacenter1
CASSANDRA_USERNAME=myuser
CASSANDRA_PASSWORD=mypassword
LOG_LEVEL=INFO
For production deployments:
- Use specific image tags instead of
latest
- Configure resource limits in docker-compose or Kubernetes
- Use secrets management for credentials
- Enable TLS/SSL for Cassandra connections
- Configure appropriate health checks and monitoring
Example production docker-compose override:
# docker-compose.prod.yml
version: '3.8'
services:
mcp-server:
image: easy-cass-mcp:0.0.1
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
reservations:
memory: 256M
environment:
- LOG_LEVEL=WARNING
secrets:
- cassandra_password
restart: always
secrets:
cassandra_password:
external: true
The project includes a comprehensive Makefile for common development tasks:
make help
- Show all available commandsmake dev
- Set up development environmentmake install
- Install Python dependenciesmake install-dev
- Install all dependencies including devmake run
- Run the MCP server locally
make test
- Run all testsmake test-coverage
- Run tests with coverage reportmake format
- Format code with black and isortmake lint
- Run linting checksmake check
- Run all quality checks (format, lint, test)
make docker-build
- Build Docker imagemake docker-run
- Run Docker containermake docker-push
- Push image to registrymake docker-compose-up
- Start services with docker-composemake docker-compose-down
- Stop servicesmake docker-compose-logs
- Show logsmake docker-compose-clean
- Stop and remove volumes
make release
- Build a release (tests + Docker build)make release-patch
- Create patch version (x.y.Z+1)make release-minor
- Create minor version (x.Y+1.0)make release-major
- Create major version (X+1.0.0)make version
- Show current version
Run the test suite using the Makefile:
# Run all tests
make test
# Run tests with coverage
make test-coverage
# Run all code quality checks
make check
# Or use pytest directly
pytest -v
pytest --cov=.
Note: This is not production ready.