# datastax/astra-db-mcp architecture

> Architecture diagram of the GitHub repository datastax/astra-db-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/datastax/astra-db-mcp
- Repository: https://github.com/datastax/astra-db-mcp

## Overview

Astra DB MCP Server exposes database operations as MCP tools: an MCP client requests an operation, the server dispatches it to a tool implementation, and the tool queries or changes Astra DB. The README documents collection/document management, vector and hybrid search, tables, keyspaces, administration, and client utilities. The sampled tools use a shared database connection; some query results are sanitized before returning. Tool dispatch is directly visible for selected operations in index.ts, but unsampled handlers are represented at subsystem level based on README capabilities.

Main entry points: [`index.ts`](https://github.com/datastax/astra-db-mcp/blob/main/index.ts) (MCP server), [`util/db.ts`](https://github.com/datastax/astra-db-mcp/blob/main/util/db.ts) (DB connection), [`util/sanitize.ts`](https://github.com/datastax/astra-db-mcp/blob/main/util/sanitize.ts) (Result sanitizer), [`tools`](https://github.com/datastax/astra-db-mcp/tree/main/tools) (Record queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["MCP runtime"]
  node_server["MCP server<br/>[index.ts]"]
  node_catalog["Tool schemas<br/>[tools.ts]"]
end

subgraph group_documents["Collections and documents"]
  node_collection_ops["Collection operations"]
  node_document_ops["Document operations"]
end

subgraph group_search["Search and ranking"]
  node_record_search["Record queries"]
  node_vector_search["Vector search<br/>[VectorSearch.ts]"]
  node_hybrid_search["Hybrid and rerank<br/>[HybridSearch.ts]"]
end

subgraph group_tables["Tables"]
  node_table_ops["Table operations"]
end

subgraph group_admin["Keyspace and administration"]
  node_keyspace_ops["Keyspace operations"]
  node_db_info["Database metadata<br/>[GetDatabaseInfo.ts]"]
  node_provider_discovery["Model providers"]
  node_client_helpers["Client utilities"]
end

subgraph group_shared["Shared services"]
  node_db_connection["DB connection<br/>[db.ts]"]
  node_result_sanitizer["Result sanitizer<br/>[sanitize.ts]"]
end

node_client(("MCP client"))
node_astra[("Astra DB")]

node_client -->|"requests tools"| node_server
node_server -->|"dispatches"| node_collection_ops
node_server -->|"dispatches"| node_document_ops
node_server -->|"dispatches"| node_record_search
node_server -->|"dispatches"| node_vector_search
node_server -->|"dispatches"| node_hybrid_search
node_server -->|"dispatches"| node_table_ops
node_server -->|"dispatches"| node_keyspace_ops
node_server -->|"dispatches"| node_db_info
node_server -->|"dispatches"| node_provider_discovery
node_server -.->|"advertises tools"| node_catalog
node_collection_ops -->|"uses"| node_db_connection
node_document_ops -->|"uses"| node_db_connection
node_record_search -->|"queries"| node_db_connection
node_vector_search -->|"queries"| node_db_connection
node_hybrid_search -->|"queries"| node_db_connection
node_table_ops -->|"queries"| node_db_connection
node_keyspace_ops -->|"uses"| node_db_connection
node_db_info -->|"reads metadata"| node_db_connection
node_provider_discovery -->|"lists providers"| node_db_connection
node_client_helpers -.->|"assists setup"| node_client
node_db_connection -->|"connects"| node_astra
node_record_search -->|"sanitizes results"| node_result_sanitizer
node_vector_search -->|"sanitizes results"| node_result_sanitizer
node_hybrid_search -->|"sanitizes results"| node_result_sanitizer
node_table_ops -->|"sanitizes rows"| node_result_sanitizer

click node_server "https://github.com/datastax/astra-db-mcp/blob/main/index.ts"
click node_catalog "https://github.com/datastax/astra-db-mcp/blob/main/tools.ts"
click node_collection_ops "https://github.com/datastax/astra-db-mcp/tree/main/tools"
click node_document_ops "https://github.com/datastax/astra-db-mcp/tree/main/tools"
click node_record_search "https://github.com/datastax/astra-db-mcp/tree/main/tools"
click node_vector_search "https://github.com/datastax/astra-db-mcp/blob/main/tools/VectorSearch.ts"
click node_hybrid_search "https://github.com/datastax/astra-db-mcp/blob/main/tools/HybridSearch.ts"
click node_table_ops "https://github.com/datastax/astra-db-mcp/tree/main/tools"
click node_keyspace_ops "https://github.com/datastax/astra-db-mcp/tree/main/tools"
click node_db_info "https://github.com/datastax/astra-db-mcp/blob/main/tools/GetDatabaseInfo.ts"
click node_provider_discovery "https://github.com/datastax/astra-db-mcp/blob/main/tools/ListEmbeddingProviders.ts"
click node_client_helpers "https://github.com/datastax/astra-db-mcp/tree/main/tools"
click node_db_connection "https://github.com/datastax/astra-db-mcp/blob/main/util/db.ts"
click node_result_sanitizer "https://github.com/datastax/astra-db-mcp/blob/main/util/sanitize.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_catalog,node_client toneBlue
class node_collection_ops,node_document_ops,node_astra toneAmber
class node_record_search,node_vector_search,node_hybrid_search toneMint
class node_table_ops toneRose
class node_keyspace_ops,node_db_info,node_provider_discovery,node_client_helpers toneIndigo
class node_db_connection,node_result_sanitizer toneTeal
```

## Components

### MCP runtime

- [MCP server](https://github.com/datastax/astra-db-mcp/blob/main/index.ts): `index.ts`
- [Tool schemas](https://github.com/datastax/astra-db-mcp/blob/main/tools.ts): `tools.ts`

### Collections and documents

- [Collection operations](https://github.com/datastax/astra-db-mcp/tree/main/tools): `tools`
- [Document operations](https://github.com/datastax/astra-db-mcp/tree/main/tools): `tools`

### Search and ranking

- [Record queries](https://github.com/datastax/astra-db-mcp/tree/main/tools): `tools`
- [Vector search](https://github.com/datastax/astra-db-mcp/blob/main/tools/VectorSearch.ts): `tools/VectorSearch.ts`
- [Hybrid and rerank](https://github.com/datastax/astra-db-mcp/blob/main/tools/HybridSearch.ts): `tools/HybridSearch.ts`

### Tables

- [Table operations](https://github.com/datastax/astra-db-mcp/tree/main/tools): `tools`

### Keyspace and administration

- [Keyspace operations](https://github.com/datastax/astra-db-mcp/tree/main/tools): `tools`
- [Database metadata](https://github.com/datastax/astra-db-mcp/blob/main/tools/GetDatabaseInfo.ts): `tools/GetDatabaseInfo.ts`
- [Model providers](https://github.com/datastax/astra-db-mcp/blob/main/tools/ListEmbeddingProviders.ts): `tools/ListEmbeddingProviders.ts`
- [Client utilities](https://github.com/datastax/astra-db-mcp/tree/main/tools): `tools`

### Shared services

- [DB connection](https://github.com/datastax/astra-db-mcp/blob/main/util/db.ts): `util/db.ts`
- [Result sanitizer](https://github.com/datastax/astra-db-mcp/blob/main/util/sanitize.ts): `util/sanitize.ts`

### Other components

- **MCP client**
- **Astra DB**

## Connections

- MCP client → MCP server: requests tools (evidence: `README.md`)
- MCP server → Collection operations: dispatches (evidence: `index.ts`)
- MCP server → Document operations: dispatches (evidence: `index.ts`)
- MCP server → Record queries: dispatches (evidence: `index.ts`)
- MCP server → Vector search: dispatches (evidence: `index.ts`)
- MCP server → Hybrid and rerank: dispatches (evidence: `index.ts`)
- MCP server → Table operations: dispatches (evidence: `index.ts`)
- MCP server → Keyspace operations: dispatches (evidence: `index.ts`)
- MCP server → Database metadata: dispatches (evidence: `index.ts`)
- MCP server → Model providers: dispatches (evidence: `index.ts`)
- MCP server → Tool schemas: advertises tools (evidence: `index.ts`)
- Collection operations → DB connection: uses (evidence: `tools/CreateCollection.ts`)
- Document operations → DB connection: uses (evidence: `tools/CreateRecord.ts`)
- Record queries → DB connection: queries (evidence: `tools/FindRecord.ts`)
- Vector search → DB connection: queries (evidence: `tools/VectorSearch.ts`)
- Hybrid and rerank → DB connection: queries (evidence: `tools/HybridSearch.ts`)
- Table operations → DB connection: queries (evidence: `tools/QueryTable.ts`)
- Keyspace operations → DB connection: uses (evidence: `tools/CreateKeyspace.ts`)
- Database metadata → DB connection: reads metadata (evidence: `tools/GetDatabaseInfo.ts`)
- Model providers → DB connection: lists providers (evidence: `tools/ListEmbeddingProviders.ts`)
- Client utilities → MCP client: assists setup (evidence: `README.md`)
- DB connection → Astra DB: connects (evidence: `util/db.ts`)
- Record queries → Result sanitizer: sanitizes results (evidence: `tools/FindRecord.ts`)
- Vector search → Result sanitizer: sanitizes results (evidence: `tools/VectorSearch.ts`)
- Hybrid and rerank → Result sanitizer: sanitizes results (evidence: `tools/HybridSearch.ts`)
- Table operations → Result sanitizer: sanitizes rows (evidence: `tools/QueryTable.ts`)
