Skip to content

CrateDB MCP Server for Text-to-SQL and documentation retrieval.

License

Notifications You must be signed in to change notification settings

crate/cratedb-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CrateDB MCP Server

Bluesky Release Notes

Status License CI Coverage

» Documentation | Releases | Issues | Source code | License | CrateDB | Community Forum

About

Model Context Protocol MCP is a protocol that standardizes providing context to LLMs like Claude, ChatGPT and MistralAI.

CrateDB MCP server lets these LLMs operate directly on CrateDB enabling use cases like:

  • Answer questions about your data and database state
  • Help you debug and optimize queries directly on the database

To use a MCP server you need a client that supports the protocol, the most notable ones are: Claude Desktop, ChatGTP desktop, OPenAI agents SDK and Cursor.

Examples

For questions like optimizing queries and CrateDB specific syntax/capabilities, we encourage the LLMs to fetch https://cratedb.com/docs to offer the most accurate possible information.

These are examples of questions that have been tested and validated by the team. Remember that LLMs can still hallucinate and give incorrect answers.

  • Optimize this query: "SELECT * FROM movies WHERE release_date > '2012-12-1' AND revenue"
  • Tell me about the health of the cluster
  • What is the storage consumption of my tables, give it in a graph.
  • How can I format a timestamp column to '2019 Jan 21'.

Data integrity

We do not recommend letting the LLMs insert data or modify columns by itself, as such we tell the LLMs to only allow 'SELECT' statements in the cratedb_sql tool, you can jailbreak this against our recommendation.

Install

uv tool install --upgrade git+https://github.com/crate/cratedb-mcp

Note: We recommend to use uv tool install to install the program "user"-wide into your environment so you can use it across your terminal or MCP client sessions like Claude.

Configure

Configure the CRATEDB_MCP_HTTP_URL environment variable to match your CrateDB instance. For example, when connecting to CrateDB Cloud, use a value like https://admin:[email protected]:4200/. When connecting to CrateDB on localhost, use http://localhost:4200/.

export CRATEDB_MCP_HTTP_URL="http://localhost:4200/"
export CRATEDB_MCP_HTTP_URL="https://example.aks1.westeurope.azure.cratedb.net:4200"

The CRATEDB_MCP_DOCS_CACHE_TTL environment variable (default: 3600) defines the cache lifetime for documentation resources.

Usage

Start MCP server with stdio transport (default).

CRATEDB_MCP_TRANSPORT=stdio cratedb-mcp

Start MCP server with sse transport.

CRATEDB_MCP_TRANSPORT=sse cratedb-mcp

Note: If you are unable to use uv tool install, please use uv run cratedb-mcp to acquire and run the package ephemerally.

Simple Claude configuration

To use the MCP version within Claude Desktop, you can use the following configuration:

{
  "mcpServers": {
    "my_cratedb": {
      "command": "uvx",
      "args": ["--python", "3.13", "--from", "git+https://github.com/crate/cratedb-mcp", "cratedb-mcp"],
      "env": {
        "CRATEDB_MCP_HTTP_URL": "http://localhost:4200/",
        "CRATEDB_MCP_TRANSPORT": "stdio"
      }
    }
  }
}

Development

To learn how to set up a development sandbox, see the development documentation.