The StarRocks MCP Server serves as a bridge between AI assistants and StarRocks databases, allowing you to execute SQL, explore databases, visualize data, and retrieve schema information without complex setup. It streamlines database interactions for AI applications with features like direct query execution and intelligent caching.
You can run the StarRocks MCP server in different modes, with the Streamable HTTP mode being recommended.
Before starting the server, test your connection:
STARROCKS_URL=root:@localhost:8000 uv run mcp-server-starrocks --test
Start the server in Streamable HTTP mode:
uv run mcp-server-starrocks --mode streamable-http --port 8000
You can configure the MCP server through various methods:
{
"mcpServers": {
"mcp-server-starrocks": {
"url": "http://localhost:8000/mcp"
}
}
}
{
"mcpServers": {
"mcp-server-starrocks": {
"command": "uv",
"args": ["run", "--with", "mcp-server-starrocks", "mcp-server-starrocks"],
"env": {
"STARROCKS_HOST": "default localhost",
"STARROCKS_PORT": "default 9030",
"STARROCKS_USER": "default root",
"STARROCKS_PASSWORD": "default empty",
"STARROCKS_DB": "default empty"
}
}
}
}
{
"mcpServers": {
"mcp-server-starrocks": {
"command": "uv",
"args": ["run", "--with", "mcp-server-starrocks", "mcp-server-starrocks"],
"env": {
"STARROCKS_URL": "root:password@localhost:9030/my_database"
}
}
}
}
View available command-line arguments:
uv run mcp-server-starrocks --help
Common usage examples:
# Start in streamable HTTP mode on custom host/port
uv run mcp-server-starrocks --mode streamable-http --host 0.0.0.0 --port 8080
# Start in stdio mode (default)
uv run mcp-server-starrocks --mode stdio
# Run test mode
uv run mcp-server-starrocks --test
Option 1: Individual Environment Variables
STARROCKS_HOST: Hostname (defaults to localhost)STARROCKS_PORT: MySQL protocol port (defaults to 9030)STARROCKS_USER: Username (defaults to root)STARROCKS_PASSWORD: Password (defaults to empty)STARROCKS_DB: Default database (optional)Option 2: Connection URL
STARROCKS_URL: A connection URL in the format [<schema>://]user:password@host:port/databaseExamples:
root:mypass@localhost:9030/test_dbmysql://admin:[email protected]:9030/productionstarrocks://user:[email protected]:9030/analyticsSTARROCKS_OVERVIEW_LIMIT: Character limit for overview tools (defaults to 20000)STARROCKS_MYSQL_AUTH_PLUGIN: Authentication plugin (optional)MCP_TRANSPORT_MODE: Communication mode (stdio, streamable-http, or sse - deprecated)Execute SELECT queries or commands that return results:
{
"query": "SELECT * FROM my_table LIMIT 10",
"db": "my_database" // Optional
}
Execute DDL/DML commands:
{
"query": "CREATE TABLE example (id INT, name VARCHAR(50))",
"db": "my_database" // Optional
}
Analyze query performance:
{
"uuid": "12345678-1234-1234-1234-123456789012", // Query ID
"sql": "SELECT * FROM large_table", // Alternative to uuid
"db": "my_database" // Optional
}
Generate visualizations from query results:
{
"query": "SELECT date, sales FROM transactions",
"plotly_expr": "px.line(df, x='date', y='sales', title='Sales Over Time')",
"db": "my_database" // Optional
}
Get comprehensive information about a table:
{
"table": "my_database.my_table", // Or just "my_table" if using default DB
"refresh": false // Optional, bypass cache if true
}
Get information about all tables in a database:
{
"db": "my_database", // Optional if default database is set
"refresh": false // Optional, bypass cache if true
}
Access starrocks:///databases to list all available databases.
Access starrocks:///{db}/{table}/schema to get the schema of a specific table.
Access starrocks:///{db}/tables to list all tables in a database.
Access proc:///{path} to retrieve internal StarRocks system information. Common paths include:
/frontends - Information about FE nodes/backends - Information about BE nodes/dbs - Information about databases/transactions - Transaction informationAfter starting the server, you can use the inspector tool to debug:
npx @modelcontextprotocol/inspector
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-server-starrocks" '{"command":"uv","args":["run","--with","mcp-server-starrocks","mcp-server-starrocks"],"env":{"STARROCKS_HOST":"default localhost","STARROCKS_PORT":"default 9030","STARROCKS_USER":"default root","STARROCKS_PASSWORD":"default empty","STARROCKS_DB":"default empty","STARROCKS_OVERVIEW_LIMIT":"default 20000","STARROCKS_MYSQL_AUTH_PLUGIN":"mysql_clear_password"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-server-starrocks": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-server-starrocks",
"mcp-server-starrocks"
],
"env": {
"STARROCKS_HOST": "default localhost",
"STARROCKS_PORT": "default 9030",
"STARROCKS_USER": "default root",
"STARROCKS_PASSWORD": "default empty",
"STARROCKS_DB": "default empty",
"STARROCKS_OVERVIEW_LIMIT": "default 20000",
"STARROCKS_MYSQL_AUTH_PLUGIN": "mysql_clear_password"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
"mcpServers": {
"mcp-server-starrocks": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-server-starrocks",
"mcp-server-starrocks"
],
"env": {
"STARROCKS_HOST": "default localhost",
"STARROCKS_PORT": "default 9030",
"STARROCKS_USER": "default root",
"STARROCKS_PASSWORD": "default empty",
"STARROCKS_DB": "default empty",
"STARROCKS_OVERVIEW_LIMIT": "default 20000",
"STARROCKS_MYSQL_AUTH_PLUGIN": "mysql_clear_password"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect