connect_databaseLABSCO SUMMARY
A CockroachDB session that survives the conversation.
Schema reads and query execution are the whole job, and the reconnection and keep-alive behaviour is what makes it usable across a long conversation rather than only the first few minutes. Whatever the connected database user can do, the assistant can do.
What it is
A Python MCP server for CockroachDB. It connects over a JDBC URL, lists tables, returns table structure and executes SQL, with automatic reconnection and a keep-alive so a long session does not drop, plus database status resources and SQL query templates.
What you get
- A connection opened from a JDBC URL, username and password (connect_database), or established as soon as the client attaches (initialize_connection)
- Every table in the database listed (get_tables)
- One table's structure returned in full (get_table_schema)
- SQL executed against the cluster (execute_query)
- A manual disconnect when you want the connection closed (disconnect_database)
- Automatic reconnection and a keep-alive, so an idle session does not time out
- Database status exposed as a resource, plus SQL query templates and detailed logging
Requirements
Python with the repo's requirements and uv, run from a clone. The JDBC URL, username and password are passed when the assistant calls connect_database, and the grants on that database user decide what any query can do.
Setup effort
Build from source — git clone https://github.com/Swayingleaves/cockroachdb-mcp-server.git
USE CASES
Getting oriented in an unfamiliar database
List the tables, then read the structure of the ones that matter, before writing a single line of SQL against them.
Answering a question with a query instead of a guess
SQL runs against the live cluster and the rows come back in the conversation, so the answer is the data rather than an assumption about it.
Setting the connection up once
The connection is established when the client attaches, so the first useful question does not have to be preceded by connection plumbing.
Closing the connection deliberately
A manual disconnect ends the session on your terms, rather than leaving a connection open against a production cluster.
6 tools
Listed in project docs. Your client may show a different list.
initialize_connectiondisconnect_databaseget_tablesget_table_schemaexecute_queryBEFORE YOU INSTALL
What to know first
Tools you get
6 tools named in the project's documentation.
Requires
- uv
- A reachable CockroachDB and a database user
Where it runs
The documented client runs the server on your machine.
INSTALLATION
Connect your client
Server setup
git clone https://github.com/Swayingleaves/cockroachdb-mcp-server.git
cd cockroachdb-mcp-server
pip install -r requirements.txt
curl -LsSf https://astral.sh/uv/install.sh | shMCP Clients
Cursor
{
"mcpServers": {
"cockroachdb-mcp": {
"command": "uv",
"args": [
"--directory",
"<YOUR_PATH_TO_COCKROACHDB_MCP_SERVER>",
"run",
"server.py"
]
}
}
}<YOUR_PATH_TO_COCKROACHDB_MCP_SERVER> is the full path of the folder the git clone created. The connection details are not set here: the assistant passes jdbc_url (e.g. jdbc:postgresql://localhost:26257/defaultdb), username and password when it calls connect_database or initialize_connection.