Apache Doris MCP (Model Context Protocol) Server is a backend service built on Python and FastAPI, designed to seamlessly integrate with the Apache Doris database through the Model Context Protocol (MCP). It provides standardized interfaces for AI agents and clients, supporting Natural Language to SQL (NL2SQL), SQL query execution, metadata management, and data analysis. This project is a significant extension of the Apache Doris community, particularly suitable for business scenarios requiring efficient data interaction and intelligent analysis.
Since the release of version 0.3.0 in 2025, the project has undergone a major architectural update, migrating from SSE (Server-Sent Events) based communication to a unified Streamable HTTP protocol, and adding enterprise-grade security frameworks and performance optimization features. The core goal of the project is to bridge AI systems with the Apache Doris database through the MCP protocol, enabling intelligent data exploration and analysis.
Apache Doris MCP Server provides the following main features:
Natural Language to SQL (NL2SQL)
SQL Query Execution
exec_query
tool, with customizable database selection, row limits, and timeout settings.Metadata Management
get_all_databases
, get_database_tables
).get_table_schema
, get_table_comment
, get_column_comments
, get_table_indexes
).get_catalog_list
).Audit Log Query
get_recent_audit_logs
, supporting custom time ranges and record limits.Enterprise-Grade Security Framework
Performance Optimization
performance_stats
).Multiple Communication Modes
/mcp
endpoint (src/streamable_server.py
)./sse
and /mcp/messages
endpoints (src/sse_server.py
).src/stdio_server.py
).Experimental Features
column_analysis
), providing data insights.The project's architecture is modular and efficient, mainly including the following components:
/mcp
endpoint, simplifying integration.doris_mcp_server/utils/db.py
: Provides database connection (get_db_connection
) and query execution (execute_query
, execute_query_df
) functions.doris_mcp_server/utils/schema_extractor.py
: The MetadataExtractor
class is responsible for metadata extraction, including caching mechanisms.doris_mcp_server/utils/sql_executor_tools.py
: The execute_sql_query
function encapsulates query logic, including security checks and result serialization.DB_HOST
, DB_PORT
, DB_USER
, DB_PASSWORD
).Architectural Changes: Version 0.3.0 removed approximately 300 lines of legacy SSE code, migrated to Streamable HTTP, unified tool naming (removed the
mcp_doris_
prefix), and improved modularity.
uv
or pip
)Clone the Repository:
git clone https://github.com/apache/doris-mcp-server.git
cd doris-mcp-server
Install Dependencies:
Use uv
(recommended) or pip
to install:
uv sync
Or
pip install -r requirements.txt
Configure Environment Variables:
Create a .env
file or set environment variables directly:
export DORIS_HOST=<doris-host>
export DORIS_PORT=<port>
export DORIS_USER=<doris-user>
export DORIS_PASSWORD=<doris-pwd>
export SERVER_PORT=3000
Start the Server:
uv run --with mcp-doris --python 3.13 mcp-doris
Or
python -m mcp_doris.mcp_server
Verify Startup:
After successful startup, you can interact through an MCP client (such as Cursor) or the built-in MCP browser (http://localhost:5173
).
Run the test script to verify the database connection:
python src/doris-mcp-server/test.py
Expected output:
🚀 Doris MCP Server is starting...
[DorisConnector] Connected to 127.0.0.1:9030
✅ Database connection successful.
[DorisConnector] Connection closed.
Real-time Data Analysis
Metadata Exploration
AI-Driven Business Intelligence
Security Compliance Management
Multi-Catalog Environment
column_analysis
) are experimental and may contain bugs. Apache Doris MCP Server is a powerful and flexible tool that bridges the Apache Doris database with AI-driven analysis needs. Its NL2SQL, metadata management, security, and performance optimization features make it widely applicable in real-time data analysis, business intelligence, and enterprise-grade applications.