Skip to main content
Glama

CockroachDB MCP Server

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
CRDB_PWDNoThe user's password.
CRDB_HOSTNoThe host name or address of a CockroachDB node or load balancer.127.0.0.1
CRDB_PORTNoThe port number of the SQL interface of the CockroachDB node or load balancer.26257
CRDB_DATABASENoA database name to use as the current database.defaultdb
CRDB_SSL_MODENoWhich type of secure connection to use.disable
CRDB_USERNAMENoThe SQL user that will own the client session.root
CRDB_SSL_CA_PATHNoPath to the CA certificate, when sslmode is not 'disable'.
CRDB_SSL_KEYFILENoPath to the client private key, when sslmode is not 'disable'.
CRDB_SSL_CERTFILENoPath to the client certificate, when sslmode is not 'disable'.

Schema

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

Tools

Functions exposed to the LLM to take actions

NameDescription
get_cluster_status

Get cluster health and node distribution.

Args: detailed (bool): If True, returns all node details. If False, returns summary info.

Returns: Details about the cluster's status and how nodes/ranges are distributed or an error message.

show_running_queries

Show currently running queries on the cluster.

Args: node_id (int): Node ID to filter (default: 1). user (str): Username to filter (default: 'root'). min_duration (str): Minimum query duration (default: '1:0', format: 'minutes').

Returns: The queries running on the cluster.

get_replication_status

Get replication and distribution status for a table or the whole database.

Args: table_name (str): Table name to filter (default: "", for all tables).

Returns: Details about range replication for a specific table or the current database.

connect

Connect to the default CockroachDB database and create a connection pool.

Returns: A success message or an error message.

connect_database

Connect to a CockroachDB database and create a connection pool.

Args: host (str): CockroachDB host. port (int): CockroachDB port (default: 26257). database (str): Database name (default: "defaultdb"). username (str): Username (default: "root"). password (str): Password. sslmode (str): SSL mode (default: disable - Possible values: allow, prefer, require, verify-ca, verify-full). sslcert (str): Path to user certificate file. sslkey (str): Path to user key file. sslrootcert (str): Path to CA certificate file.

Returns: A success message or an error message.

list_databases

List all databases in the CockroachDB cluster.

Returns: A list of databases with row count or an error message.

get_connection_status

Get the current connection status and details.

Returns: The connection status or an error message.

switch_database

Switch the connection to a different database.

Args: database (str): Name of the database to switch to.

Returns: A success message or an error message.

get_active_connections

List active connections/sessions to the current database.

Returns: Active sessions on the cluster.

get_database_settings

Retrieve current database or cluster settings.

Returns: All cluster settings.

create_database

Enable the creation of new databases.

Args: database_name (str): Name of the database to create.

Returns: A success message or an error message.

drop_database

Drop an existing database.

Args: database_name (str): Name of the database to drop.

Returns: A success message or an error message.

create_table

Enable the creation of new tables in the current database. You can instruct the AI to define table names, columns, and their types, streamlining database setup and schema evolution directly through natural language.

Args: table_name (str): Name of the table. columns (List[Dict[str, str]]): List of dicts with keys: - 'name' (str): column name (required) - 'datatype' (str): column datatype (required) - 'constraint' (str): column constraint (optional)

Returns: A success message or an error message.

Example: columns = [ {"name": "id", "datatype": "SERIAL", "constraint": "PRIMARY KEY"}, {"name": "username", "datatype": "TEXT", "constraint": "NOT NULL"}, {"name": "created_at", "datatype": "TIMESTAMP"} ]

bulk_import

Bulk import data into a table from a file (CSV or Avro) stored in cloud or web storage. Supports S3, Azure Blob, Google Storage, HTTP/HTTPS URLs.

Args: table_name (str): Name of the table to import data into. file_url (str): URL to the data file (s3://, azure://, gs://, http://, https://, etc.). format (str): File format ('csv' or 'avro'). delimiter (str): CSV delimiter (default: ','). skip_header (bool): Whether to skip the first row as header (default: True).

Returns: A success message or an error message.

Example: bulk_import(ctx, table_name="users", file_url="s3://bucket/data.csv", format="csv", delimiter=";", skip_header=True)

drop_table

Facilitate the deletion of existing tables from the database. This tool is useful for cleaning up test environments or managing schema changes, always with the necessary confirmations for security.

Args: table_name (str): Name of the table to drop.

Returns: A success message or an error message.

create_index

Create a new index on a specified table to improve query performance. This tool allows users to define indexes on one or more columns, enabling faster data retrieval and optimized execution plans for read-heavy workloads.

Args: table_name (str): Name of the table. index_name (str): Name of the index. columns (List[str]): List of column names to include in the index.

Returns: A success message or an error message.

drop_index

Drop an existing index.

Args: index_name (str): Name of the index to drop.

Returns: A success message or an error message.

create_view

Create a view from a specific query.

Args: view_name (str): Name of the view. query (str): SQL query for the view definition.

Returns: A success message or an error message.

drop_view

Drop an existing view.

Args: view_name (str): Name of the view to drop.

Returns: A success message or an error message.

list_tables

List all tables present in the connected Cockroach database instance. This is invaluable for AI to understand the database’s landscape and identify relevant data sources for a given query.

Args: db_schema (str): Schema name (default: "public").

Returns: The list of all tables present in the connected Cockroach database.

describe_table

Provide detailed schema information, column definitions, data types, and other metadata for a specified table. This allows the AI to accurately interpret table structures and formulate precise queries or data manipulation commands.

Args: table_name (str): Name of the table. db_schema (str): Schema name (default: "public").

Returns: Table details including columns, constraints, indexes, and metadata.

list_views

List all views in a schema.

Args: db_schema (str): Schema name (default: "public").

Returns: All views in a schema

get_table_relationships

Get foreign key relationships for a table or all tables.

Args: table_name (str, optional): Table name to filter relationships (default: None).

Returns: List all relationships for a specific table or in a schema.

analyze_schema

Analyze the schema and provide a summary of tables, views, and relationships.

Args: db_schema (str): Schema name (default: "public").

Returns: Summary and details of tables, views, and relationships.

execute_query

Execute a SQL query with optional parameters and formatting.

Args: query (str): SQL query to execute. params (List, optional): Query parameters. format (str): Output format ('json', 'csv', 'table'). limit (int, optional): Limit number of rows returned.

Returns: The query resultset in json or csv format.

execute_transaction

Execute a list of SQL queries as a single transaction.

Args: queries (List[str]): List of SQL queries to execute.

Returns: A success message or an error message.

explain_query

Return CockroachDB's statement plan for a preparable statement. You can use this information to optimize the query. If you run it with Analyze, it executes the SQL query and generates a statement plan with execution statistics.

Args: query (str): SQL query to explain. analyze (bool): If True, run EXPLAIN ANALYZE.

Returns: A success message or an error message.

analyze_performance

Analyze query performance statistics for a given query or time range.

Args: query (str): Query string to filter (default: ""). time_range (str): Time range for analysis (default: '1:0', format: 'minutes').

Returns: Statistics about performance and latency (e.g., P50, P99).

get_query_history

Get the history of executed queries.

Args: limit (int): Number of recent queries to return (default: 10).

Returns: A list of the last executed queries.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/amineelkouhen/mcp-cockroachdb'

If you have feedback or need assistance with the MCP directory API, please join our Discord server