Apache Doris MCP server

Enables direct SQL query execution and metadata retrieval from Apache Doris databases without switching contexts.
Back to servers
Setup instructions
Provider
Apache Doris
Release date
May 06, 2025
Language
Python
Stats
156 stars

The Doris MCP Server is a backend service built with Python and FastAPI that implements the Model Control Protocol (MCP). It allows clients to interact with Apache Doris databases through defined tools, providing capabilities for SQL execution, metadata management, and database interactions.

Installation

Prerequisites

  • Python 3.12+
  • Database connection details (Doris Host, Port, User, Password, Database)

Clone the Repository

git clone https://github.com/apache/doris-mcp-server.git
cd doris-mcp-server

Install Dependencies

pip install -r requirements.txt

Configure Environment Variables

Copy the example environment file to create your configuration:

cp env.example .env

Edit the .env file with your specific settings:

Key Configuration Options

  • Database Connection:

    • DB_HOST: Database hostname
    • DB_PORT: Database port (default 9030)
    • DB_USER: Database username
    • DB_PASSWORD: Database password
    • DB_DATABASE: Default database name
  • Server Configuration:

    • SERVER_HOST: Host address the server listens on (default 0.0.0.0)
    • SERVER_PORT: Port the server listens on (default 3000)
    • ALLOWED_ORIGINS: CORS allowed origins (comma-separated, * allows all)
    • MCP_ALLOW_CREDENTIALS: Whether to allow CORS credentials (default false)
  • Logging Configuration:

    • LOG_DIR: Directory for log files (default ./logs)
    • LOG_LEVEL: Log level (e.g., INFO, DEBUG, WARNING, ERROR, default INFO)
    • CONSOLE_LOGGING: Whether to output logs to the console (default false)

Start the Server

To run the server in SSE mode:

./start_server.sh

This starts the FastAPI application providing both SSE and Streamable HTTP MCP services.

Usage

Service Endpoints

  • SSE Initialization: http://<host>:<port>/sse
  • SSE Communication: http://<host>:<port>/mcp/messages (POST)
  • Streamable HTTP: http://<host>:<port>/mcp (Supports GET, POST, DELETE, OPTIONS)
  • Health Check: http://<host>:<port>/health

Available MCP Tools

The server provides various tools for database interaction:

Tool Name Description Key Parameters
mcp_doris_get_db_list Get a list of all database names random_string (Required)
mcp_doris_get_db_table_list Get a list of all table names in a database random_string (Required), db_name (Optional)
mcp_doris_get_table_schema Get detailed table structure random_string (Required), table_name (Required), db_name (Optional)
mcp_doris_get_table_comment Get table comment random_string (Required), table_name (Required), db_name (Optional)
mcp_doris_get_table_column_comments Get comments for all columns random_string (Required), table_name (Required), db_name (Optional)
mcp_doris_get_table_indexes Get table index information random_string (Required), table_name (Required), db_name (Optional)
mcp_doris_exec_query Execute SQL query random_string (Required), sql (Required), db_name (Optional), max_rows (Optional), timeout (Optional)
mcp_doris_get_recent_audit_logs Get recent audit logs random_string (Required), days (Optional), limit (Optional)

Note: All tools require a random_string parameter as a call identifier, typically handled automatically by the MCP client.

Interaction Flow

Interaction with the server requires an MCP client following this general flow:

  1. Client Initialization: Connect to /sse (SSE) or send an initialize method call to /mcp (Streamable)
  2. (Optional) Discover Tools: Call mcp/listTools or mcp/listOfferings to get supported tools
  3. Call Tool: Send a tool_call message/request with the tool name and arguments
  4. Handle Response: Process standard or streaming responses from the server

Connecting with Cursor

You can connect Cursor to this MCP server using either Stdio or SSE mode.

Stdio Mode

For Stdio mode (where Cursor manages the server):

  1. Prepare the environment dependency package:
uv --project /your/path/doris-mcp-server run doris-mcp
  1. Configure Cursor by adding an entry to your Cursor MCP configuration:
{
  "mcpServers": {
    "doris-stdio": {
      "command": "uv",
      "args": ["--project", "/path/to/your/doris-mcp-server", "run", "doris-mcp"],
      "env": {
        "DB_HOST": "127.0.0.1",
        "DB_PORT": "9030",
        "DB_USER": "root",
        "DB_PASSWORD": "your_db_password",
        "DB_DATABASE": "your_default_db" 
      }
    }
  }
}

SSE Mode

For SSE mode (where you run the server independently):

  1. Configure your .env file with database credentials and server settings
  2. Start the server:
./start_server.sh
  1. Configure Cursor to connect to your running server:
{
  "mcpServers": {
    "doris-sse": {
       "url": "http://127.0.0.1:3000/sse"
    }
  }
}

After configuration, you can select the server in Cursor and use its tools to interact with your Doris database.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "doris-stdio" '{"command":"uv","args":["--project","/path/to/your/doris-mcp-server","run","doris-mcp"],"env":{"DB_HOST":"127.0.0.1","DB_PORT":"9030","DB_USER":"root","DB_PASSWORD":"your_db_password","DB_DATABASE":"your_default_db"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

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.

Adding an MCP server to Cursor globally

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": {
        "doris-stdio": {
            "command": "uv",
            "args": [
                "--project",
                "/path/to/your/doris-mcp-server",
                "run",
                "doris-mcp"
            ],
            "env": {
                "DB_HOST": "127.0.0.1",
                "DB_PORT": "9030",
                "DB_USER": "root",
                "DB_PASSWORD": "your_db_password",
                "DB_DATABASE": "your_default_db"
            }
        },
        "doris-sse": {
            "url": "http://127.0.0.1:3000/sse"
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "doris-stdio": {
            "command": "uv",
            "args": [
                "--project",
                "/path/to/your/doris-mcp-server",
                "run",
                "doris-mcp"
            ],
            "env": {
                "DB_HOST": "127.0.0.1",
                "DB_PORT": "9030",
                "DB_USER": "root",
                "DB_PASSWORD": "your_db_password",
                "DB_DATABASE": "your_default_db"
            }
        },
        "doris-sse": {
            "url": "http://127.0.0.1:3000/sse"
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later