@@ -17,11 +17,18 @@ This tutorial shows you how to build a conversational Business Intelligence tool
17
17
18
18
![ Databend MCP ChatBI] ( @site/static/img/connect/databend-mcp-chatbi.png )
19
19
20
+ ## Prerequisites
21
+
22
+ Before getting started, you'll need:
23
+
24
+ 1 . ** Databend Database** - Either [ Databend Cloud] ( https://app.databend.com ) (free tier available) or a self-hosted instance
25
+ 2 . ** DeepSeek API Key** - Get your key from [ https://platform.deepseek.com/api_keys ] ( https://platform.deepseek.com/api_keys )
26
+
20
27
## Step-by-Step Tutorial
21
28
22
29
### Step 1: Setup Databend Connection
23
30
24
- First, you need a Databend database to connect to :
31
+ If you don't already have a Databend database:
25
32
26
33
1 . ** Sign up for [ Databend Cloud] ( https://app.databend.com ) ** (free tier available)
27
34
2 . ** Create a warehouse and database**
@@ -34,7 +41,19 @@ For detailed DSN format and examples, see [Connection String Documentation](http
34
41
| ** Databend Cloud** | ` databend://user:pwd@host:443/database?warehouse=wh ` |
35
42
| ** Self-hosted** | ` databend://user:pwd@localhost:8000/database?sslmode=disable ` |
36
43
37
- ### Step 2: Install Dependencies
44
+ ### Step 2: Setup API Keys and Environment
45
+
46
+ Set up your API key and database connection:
47
+
48
+ ``` bash
49
+ # Set your DeepSeek API key
50
+ export DEEPSEEK_API_KEY=" your-deepseek-api-key"
51
+
52
+ # Set your Databend connection string
53
+ export DATABEND_DSN=" your-databend-connection-string"
54
+ ```
55
+
56
+ ### Step 3: Install Dependencies
38
57
39
58
Create a virtual environment and install the required packages:
40
59
@@ -44,10 +63,10 @@ python3 -m venv .venv
44
63
source .venv/bin/activate
45
64
46
65
# Install packages
47
- pip install packaging openai agno openrouter sqlalchemy fastapi mcp-databend
66
+ pip install packaging openai agno sqlalchemy fastapi mcp-databend
48
67
```
49
68
50
- ### Step 3 : Create ChatBI Agent
69
+ ### Step 4 : Create ChatBI Agent
51
70
52
71
Now create your ChatBI agent that uses mcp-databend to interact with your database.
53
72
@@ -63,17 +82,16 @@ from agno.agent import Agent
63
82
from agno.playground import Playground
64
83
from agno.storage.sqlite import SqliteStorage
65
84
from agno.tools.mcp import MCPTools
66
- from agno.models.openrouter import OpenRouter
85
+ from agno.models.deepseek import DeepSeek
67
86
from fastapi import FastAPI
68
87
69
88
logging.basicConfig(level = logging.INFO )
70
89
logger = logging.getLogger(__name__ )
71
90
72
91
def check_env_vars ():
73
- """ Check required environment variables"""
74
92
required = {
75
93
" DATABEND_DSN" : " https://docs.databend.com/developer/drivers/#connection-string-dsn" ,
76
- " OPENROUTER_API_KEY " : " https://openrouter.ai/settings/keys "
94
+ " DEEPSEEK_API_KEY " : " https://platform.deepseek.com/api_keys "
77
95
}
78
96
79
97
missing = [var for var in required if not os.getenv(var)]
@@ -82,7 +100,7 @@ def check_env_vars():
82
100
print (" ❌ Missing environment variables:" )
83
101
for var in missing:
84
102
print (f " • { var} : { required[var]} " )
85
- print (" \n Example: export DATABEND_DSN='...' OPENROUTER_API_KEY ='...'" )
103
+ print (" \n Example: export DATABEND_DSN='...' DEEPSEEK_API_KEY ='...'" )
86
104
sys.exit(1 )
87
105
88
106
print (" ✅ Environment variables OK" )
@@ -117,10 +135,7 @@ databend = DatabendTool()
117
135
118
136
agent = Agent(
119
137
name = " ChatBI" ,
120
- model = OpenRouter(
121
- id = os.getenv(" MODEL_ID" , " anthropic/claude-sonnet-4" ),
122
- api_key = os.getenv(" OPENROUTER_API_KEY" )
123
- ),
138
+ model = DeepSeek(),
124
139
tools = [],
125
140
instructions = [
126
141
" You are ChatBI - a Business Intelligence assistant for Databend." ,
@@ -164,18 +179,7 @@ if __name__ == "__main__":
164
179
print (" 🤖 Starting MCP Server for Databend" )
165
180
print (" Open http://localhost:7777 to start chatting!" )
166
181
playground.serve(app = " agent:app" , host = " 127.0.0.1" , port = 7777 )
167
- ```
168
-
169
- ### Step 4: Configure Environment
170
-
171
- Set up your API keys and database connection:
172
182
173
- ``` bash
174
- # Set your OpenRouter API key
175
- export OPENROUTER_API_KEY=" your-openrouter-key"
176
-
177
- # Set your Databend connection string
178
- export DATABEND_DSN=" your-databend-connection-string"
179
183
```
180
184
181
185
### Step 5: Start Your ChatBI Agent
0 commit comments