Cover image
Try Now
2025-03-22

3 years

Works with Finder

1

Github Watches

2

Github Forks

0

Github Stars

CockroachDB MCP Server

smithery badge English | 简体中文

This is a CockroachDB MCP server for Cursor, implemented based on the Model Context Protocol (MCP) specification, allowing you to interact directly with CockroachDB database in Cursor.

Features

  • Connect to CockroachDB database
  • Get all tables from the database
  • Get table structure information
  • Execute SQL queries
  • Provide database status resources
  • Provide SQL query templates
  • Automatic reconnection mechanism to ensure connection stability
  • Connection keep-alive mechanism to prevent connection timeout
  • Graceful process exit handling
  • Detailed logging for troubleshooting
  • Support manual disconnection

Installation

Installing via Smithery

To install CockroachDB MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @Swayingleaves/cockroachdb-mcp-server --client claude
  1. Clone the repository and enter the project directory
  2. Install dependencies:
pip install -r requirements.txt
  1. Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

Using in Cursor

{
    "mcpServers": {
        "cockroachdb-mcp": {
            "command": "uv",
            "args": [
                "--directory",
                "/Users/local/cockroachdb-mcp",
                "run",
                "server.py"
            ],
            "jdbc_url": "jdbc:postgresql://localhost:26257/defaultdb",
            "username": "root",
            "password": "root"
        }
    }
  }

MCP Function Description

Tools

connect_database

Connect to CockroachDB database.

Parameters:

  • jdbc_url: JDBC connection URL (e.g., jdbc:postgresql://localhost:26257/defaultdb)
  • username: Database username
  • password: Database password

initialize_connection

Initialize database connection, can be called immediately after connecting to the MCP server to establish a database connection.

Parameters:

  • jdbc_url: JDBC connection URL (e.g., jdbc:postgresql://localhost:26257/defaultdb)
  • username: Database username
  • password: Database password

disconnect_database

Manually disconnect from the database.

No parameters.

get_tables

Get all tables from the database.

No parameters.

get_table_schema

Get structure information of a specified table.

Parameters:

  • table_name: Table name

execute_query

Execute SQL query.

Parameters:

  • query: SQL query statement

Resources

db://status

Get database connection status.

Returns:

  • When not connected: "Not connected"
  • When connected: "Connected - [Database version]"
  • When connection error: "Connection error - [Error message]"

Prompts

sql_query_template

SQL query template to help users write SQL queries.

Logs

Server logs are saved in logs/cockroachdb_mcp.log file. You can check this file to understand the server's running status and detailed logs.

The log file uses a rotating log mechanism, with each log file maximum size of 10MB and keeping up to 5 backup files to prevent excessive disk space usage.

Special Character Handling

This server uses psycopg2 to connect directly to CockroachDB database, which automatically handles special characters in usernames and passwords without additional URL encoding. This ensures correct database connection even when passwords contain special characters (such as @, %, &, etc.).

TCP Keep-alive Settings

The server is configured with TCP keep-alive mechanism by default to prevent connections from being closed due to long periods of inactivity:

  • keepalives=1: Enable TCP keepalive
  • keepalives_idle=30: Send keepalive after 30 seconds of idle time
  • keepalives_interval=10: Send keepalive every 10 seconds
  • keepalives_count=5: Give up after 5 attempts

Troubleshooting

If you encounter problems, please check the log file logs/cockroachdb_mcp.log, which will help you understand the server's running status and potential issues.

Common Issues

  1. Connection Refused: Ensure the CockroachDB server is running and accessible from your machine.
  2. Authentication Failed: Check if the username and password are correct.
  3. Connection Timeout: Check if the network connection is stable, especially when connecting to a remote database.
  4. Database Server Issues: Check if the CockroachDB server is running properly.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • apappascs
  • Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • OffchainLabs
  • Go implementation of Ethereum proof of stake

  • huahuayu
  • A unified API gateway for integrating multiple etherscan-like blockchain explorer APIs with Model Context Protocol (MCP) support for AI assistants.

  • deemkeen
  • control your mbot2 with a power combo: mqtt+mcp+llm

    Reviews

    5 (1)
    Avatar
    user_zbGnhpeq
    2025-04-16

    Chatwork MCP Server is an incredible tool for seamless communication and project management. The user interface is intuitive, making it easy to collaborate with team members. The robust features and reliable performance enhance productivity and keep everyone on the same page. Highly recommended for any business looking to streamline their workflows and improve team communication! Check it out here: https://mcp.so/server/chatwork-mcp-server/chatwork