fix the way to start server
This commit is contained in:
@@ -24,114 +24,86 @@ This document demonstrates how to integrate and use `doris-mcp-server` in Dify t
|
|||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [Prerequisites](#prerequisites)
|
- [Prerequisites](https://www.google.com/search?q=%23prerequisites)
|
||||||
- [Installation & Configuration](#installation--configuration)
|
- [Installation & Configuration](https://www.google.com/search?q=%23installation--configuration)
|
||||||
- [Starting the MCP Server](#starting-the-mcp-server)
|
- [Starting the MCP Server](https://www.google.com/search?q=%23starting-the-mcp-server)
|
||||||
- [Ngrok Tunnel (Optional)](#ngrok-tunnel-optional)
|
- [Ngrok Tunnel (Optional)](https://www.google.com/search?q=%23ngrok-tunnel-optional)
|
||||||
- [Installing & Configuring the Plugin in Dify](#installing--configuring-the-plugin-in-dify)
|
- [Installing & Configuring the Plugin in Dify](https://www.google.com/search?q=%23installing--configuring-the-plugin-in-dify)
|
||||||
- [Creating a Dify App](#creating-a-dify-app)
|
- [Creating a Dify App](https://www.google.com/search?q=%23creating-a-dify-app)
|
||||||
- [Adding MCP Tools](#adding-mcp-tools)
|
- [Adding MCP Tools](https://www.google.com/search?q=%23adding-mcp-tools)
|
||||||
- [Example Calls](#example-calls)
|
- [Example Calls](https://www.google.com/search?q=%23example-calls)
|
||||||
|
|
||||||
---
|
-----
|
||||||
|
|
||||||
## Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
1. Clone the repository:
|
First, install `mcp-doris-server`:
|
||||||
```bash
|
|
||||||
git clone https://github.com/apache/doris-mcp-server.git
|
|
||||||
|
|
||||||
cd doris-mcp-server
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Install the latest Python package and copy the environment template:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install mcp-doris-server
|
|
||||||
|
|
||||||
cp .env.example .env
|
|
||||||
|
|
||||||
vim .env
|
|
||||||
```
|
|
||||||
|
|
||||||
Fill in your Doris FE connection settings in `.env`:
|
|
||||||
|
|
||||||
```env
|
|
||||||
DORIS_HOST=localhost
|
|
||||||
DORIS_PORT=9030
|
|
||||||
DORIS_USER=root
|
|
||||||
DORIS_PASSWORD=
|
|
||||||
DORIS_DATABASE=information_schema
|
|
||||||
|
|
||||||
DORIS_FE_HTTP_PORT=8030
|
|
||||||
|
|
||||||
# Optional: custom BE host list
|
|
||||||
DORIS_BE_HOSTS=
|
|
||||||
```
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install mcp-doris-server
|
||||||
|
```
|
||||||
|
|
||||||
## Starting the MCP Server
|
## Starting the MCP Server
|
||||||
|
|
||||||
Run the startup script:
|
Run the startup script:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./start_server.sh
|
# Full configuration with database connection
|
||||||
|
doris-mcp-server \
|
||||||
|
--transport http \
|
||||||
|
--host 0.0.0.0 \
|
||||||
|
--port 3000 \
|
||||||
|
--db-host 127.0.0.1 \
|
||||||
|
--db-port 9030 \
|
||||||
|
--db-user root \
|
||||||
|
--db-password your_password
|
||||||
```
|
```
|
||||||
|
|
||||||
If successful, you will see logs like this:
|
If successful, you'll see logs similar to this:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
---
|
-----
|
||||||
|
|
||||||
## Ngrok Tunnel (Optional)
|
## Ngrok Tunnel (Optional)
|
||||||
|
|
||||||
If your Dify deployment requires a public endpoint, use [ngrok](https://ngrok.com):
|
If your Dify deployment requires a publicly accessible endpoint, you can use the **ngrok** tool. Ngrok is a third-party service that securely exposes local servers to the internet.
|
||||||
|
|
||||||
```bash
|
|
||||||
ngrok http http://localhost:3000
|
|
||||||
```
|
|
||||||
|
|
||||||
Use the generated public URL in subsequent steps.
|
-----
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Installing & Configuring the Plugin in Dify
|
## Installing & Configuring the Plugin in Dify
|
||||||
|
|
||||||
1. In the Dify console, go to **Plugin Marketplace**, search for and install **MCP‑SSE / StreamableHTTP**:
|
1. In the Dify console, go to **Plugin Marketplace**, search for, and install **MCP‑SSE / StreamableHTTP**:
|
||||||

|

|
||||||
|
|
||||||
2. After installation, click **Configure** and set the URL to your public or local address (e.g., `https://abc123.ngrok.io/mcp`):
|
2. After installation, click **Configure** and set the URL to your public or local address. For example, if you're using `ngrok`, this should be the public URL `ngrok` provides, in the format `https://<your-domain>/mcp`. If Dify can directly access your local server, use `http://localhost:3000/mcp`.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"doris_mcp_server": {
|
"doris_mcp_server": {
|
||||||
"transport": "streamable_http",
|
"transport": "streamable_http",
|
||||||
"url": "https://<your-domain>/mcp"
|
"url": "https://<your-domain>/mcp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|

|
||||||
|
|
||||||

|
3. Click **Save**. If configured correctly, you'll see a green **Authorized** indicator:
|
||||||
|
|
||||||
3. Click **Save**. If configured correctly, you will see a green **Authorized** indicator:
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
---
|
-----
|
||||||
|
|
||||||
|
|
||||||
## Creating a Dify App
|
## Creating a Dify App
|
||||||
|
|
||||||
1. In the Dify console, click **New App** → **Blank App**.
|
1. In the Dify console, click **New App** → **Blank App**.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
2. Select **Agent** as the template, set **App Name** (e.g., `Doris ChatBI`).
|
2. Select **Agent** as the template and set the **App Name** (e.g., `Doris ChatBI`).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
---
|
-----
|
||||||
|
|
||||||
## Instructions & Tool Configuration
|
## Instructions & Tool Configuration
|
||||||
|
|
||||||
@@ -142,18 +114,15 @@ Paste the following into the **Instruction** field:
|
|||||||
```
|
```
|
||||||
<instruction>
|
<instruction>
|
||||||
Use MCP tools to complete tasks as much as possible. Carefully read the annotations, method names, and parameter descriptions of each tool. Please follow these steps:
|
Use MCP tools to complete tasks as much as possible. Carefully read the annotations, method names, and parameter descriptions of each tool. Please follow these steps:
|
||||||
|
|
||||||
1. Analyze the user's question and match the most appropriate tool.
|
1. Analyze the user's question and match the most appropriate tool.
|
||||||
2. Use tool names and parameters exactly as defined; do not invent new ones.
|
2. Use tool names and parameters exactly as defined; do not invent new ones.
|
||||||
3. Pass parameters in the required JSON format.
|
3. Pass parameters in the required JSON format.
|
||||||
4. When calling tools, use:
|
4. When calling tools, use:
|
||||||
{"mcp_sse_call_tool": {"tool_name": "<tool_name>", "arguments": "{}"}}
|
{"mcp_sse_call_tool": {"tool_name": "<tool_name>", "arguments": "{}"}}
|
||||||
5. Output plain text only—no XML tags.
|
5. Output plain text only—no XML tags.
|
||||||
|
|
||||||
<input>
|
<input>
|
||||||
User question: user_query
|
User question: user_query
|
||||||
</input>
|
</input>
|
||||||
|
|
||||||
<output>
|
<output>
|
||||||
Return tool results or a final answer, including analysis.
|
Return tool results or a final answer, including analysis.
|
||||||
</output>
|
</output>
|
||||||
@@ -162,209 +131,23 @@ Return tool results or a final answer, including analysis.
|
|||||||
|
|
||||||
### Adding MCP Tools
|
### Adding MCP Tools
|
||||||
|
|
||||||
In the **Tools** pane, click **Add** twice to add two entries both named `mcp_sse` (they will inherit transport and URL from the plugin):
|
In the **Tools** pane, click **Add** twice to add two entries, both named `mcp_sse` (they will inherit the transport and URL from the plugin):
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
-----
|
||||||
---
|
|
||||||
|
|
||||||
## Example Calls
|
## Example Calls
|
||||||
|
|
||||||
### List Tables in Database
|
### List Tables in Database
|
||||||
|
|
||||||
* **User**: What tables are in the database?
|
* **User**: What tables are in the database?
|
||||||
* **Result**: Dify will call the MCP tool to run `SHOW TABLES` and return the list.
|
|
||||||
|
* **Result**: Dify will call the MCP tool to run `SHOW TABLES` and return the list.
|
||||||

|

|
||||||
|
|
||||||
### Sales Trend Over Ten Years
|
### Sales Trend Over Ten Years
|
||||||
|
|
||||||
* **User**: What has been the sales trend over the past ten years in the ssb database, and which year had the fastest growth?
|
* **User**: What has been the sales trend over the past ten years in the ssb database, and which year had the fastest growth?
|
||||||
* **Result**: The tool will execute the SQL, calculate growth rates, and return a trend chart or table.
|
|
||||||
|
* **Result**: The tool will execute the SQL, calculate growth rates, and return data.
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
````md
|
|
||||||
<!--
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
... (license omitted for brevity)
|
|
||||||
-->
|
|
||||||
|
|
||||||
# Dify Example: Integrating Doris MCP Server
|
|
||||||
|
|
||||||
This document demonstrates how to integrate and use the `doris-mcp-server` in Dify to perform Doris SQL calls via MCP.
|
|
||||||
|
|
||||||
## Table of Contents
|
|
||||||
|
|
||||||
- [Prerequisites](#prerequisites)
|
|
||||||
- [Installation & Configuration](#installation--configuration)
|
|
||||||
- [Starting the MCP Server](#starting-the-mcp-server)
|
|
||||||
- [Ngrok Tunnel (Optional)](#ngrok-tunnel-optional)
|
|
||||||
- [Installing & Configuring the Plugin](#installing--configuring-the-plugin)
|
|
||||||
- [Creating a Dify App](#creating-a-dify-app)
|
|
||||||
- [Instructions & Tool Configuration](#instructions--tool-configuration)
|
|
||||||
- [Example Calls](#example-calls)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
1. Clone the repository:
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/apache/doris-mcp-server.git
|
|
||||||
cd doris-mcp-server
|
|
||||||
````
|
|
||||||
|
|
||||||
2. Install the Python package and prepare the environment file:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install mcp-doris-server
|
|
||||||
cp .env.example .env
|
|
||||||
vim .env
|
|
||||||
```
|
|
||||||
|
|
||||||
3. In `.env`, set your Doris front-end connection:
|
|
||||||
|
|
||||||
```env
|
|
||||||
DORIS_HOST=localhost
|
|
||||||
DORIS_PORT=9030
|
|
||||||
DORIS_USER=root
|
|
||||||
DORIS_PASSWORD=
|
|
||||||
DORIS_DATABASE=information_schema
|
|
||||||
DORIS_FE_HTTP_PORT=8030
|
|
||||||
# Optional: custom BE host list
|
|
||||||
DORIS_BE_HOSTS=
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Installation & Configuration
|
|
||||||
|
|
||||||
1. Install the MCP server package:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install mcp-doris-server
|
|
||||||
```
|
|
||||||
2. Copy and edit the environment template as shown above.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Starting the MCP Server
|
|
||||||
|
|
||||||
Run the startup script:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./start_server.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
If successful, you will see logs like this:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Ngrok Tunnel (Optional)
|
|
||||||
|
|
||||||
If your Dify deployment requires a public endpoint, use [ngrok](https://ngrok.com/):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ngrok http http://localhost:3000
|
|
||||||
```
|
|
||||||
|
|
||||||
Use the generated URL in the plugin configuration.
|
|
||||||
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Installing & Configuring the Plugin
|
|
||||||
|
|
||||||
1. In the Dify console, go to **Plugin Marketplace**, search for **MCP‑SSE / StreamableHTTP**, and install it.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
2. Click **Configure**, and set the URL (e.g., `https://<your-domain>/mcp`):
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"doris_mcp_server": {
|
|
||||||
"transport": "streamable_http",
|
|
||||||
"url": "https://<your-domain>/mcp"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
3. Click **Save**. A green **Authorized** indicator should appear:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Creating a Dify App
|
|
||||||
|
|
||||||
1. In the Dify console, click **New App** → **Blank App**.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
2. Select **Agent** as the template, set **App Name** (e.g., `Doris ChatBI`).
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Instructions & Tool Configuration
|
|
||||||
|
|
||||||
### Instruction Block
|
|
||||||
|
|
||||||
Paste the following into the **Instruction** field:
|
|
||||||
|
|
||||||
```
|
|
||||||
<instruction>
|
|
||||||
Use MCP tools to complete tasks as much as possible. Carefully read the annotations, method names, and parameter descriptions of each tool. Please follow these steps:
|
|
||||||
|
|
||||||
1. Analyze the user's question and match the most appropriate tool.
|
|
||||||
2. Use tool names and parameters exactly as defined; do not invent new ones.
|
|
||||||
3. Pass parameters in the required JSON format.
|
|
||||||
4. When calling tools, use:
|
|
||||||
{"mcp_sse_call_tool": {"tool_name": "<tool_name>", "arguments": "{}"}}
|
|
||||||
5. Output plain text only—no XML tags.
|
|
||||||
|
|
||||||
<input>
|
|
||||||
User question: user_query
|
|
||||||
</input>
|
|
||||||
|
|
||||||
<output>
|
|
||||||
Return tool results or a final answer, including analysis.
|
|
||||||
</output>
|
|
||||||
</instruction>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Adding MCP Tools
|
|
||||||
|
|
||||||
In the **Tools** pane, click **Add** twice to add two entries both named `mcp_sse` (they will inherit transport and URL from the plugin):
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Example Calls
|
|
||||||
|
|
||||||
### List Tables in Database
|
|
||||||
|
|
||||||
* **User**: What tables are in the database?
|
|
||||||
* **Result**: Dify calls the MCP tool to run `SHOW TABLES` and returns the list.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Sales Trend Over Ten Years
|
|
||||||
|
|
||||||
* **User**: What has been the sales trend in the `ssb` database over the past ten years, and which year saw the fastest growth?
|
|
||||||
* **Result**: The tool executes SQL, computes growth rates, and returns a chart or table.
|
|
||||||
|
|
||||||

|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 63 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 73 KiB |
Reference in New Issue
Block a user