Skip to content

Commit c321822

Browse files
authored
feat: add mcp server for overview (#2660)
1 parent dde13a0 commit c321822

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

docs/en/guides/51-ai-functions/02-mcp.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import DetailsWrap from '@site/src/components/DetailsWrap';
2+
13
# MCP Server for Databend
24

35
[mcp-databend](https://github.com/databendlabs/mcp-databend) is an MCP (Model Context Protocol) server that enables AI assistants to interact directly with your Databend database using natural language.
@@ -27,10 +29,10 @@ First, you need a Databend database to connect to:
2729

2830
For detailed DSN format and examples, see [Connection String Documentation](https://docs.databend.com/developer/drivers/#connection-string-dsn).
2931

30-
| Deployment | Connection String Example |
31-
|------------|---------------------------|
32-
| **Databend Cloud** | `databend://user:pwd@host:443/database?warehouse=wh` |
33-
| **Self-hosted** | `databend://user:pwd@localhost:8000/database?sslmode=disable` |
32+
| Deployment | Connection String Example |
33+
| ------------------ | ------------------------------------------------------------- |
34+
| **Databend Cloud** | `databend://user:pwd@host:443/database?warehouse=wh` |
35+
| **Self-hosted** | `databend://user:pwd@localhost:8000/database?sslmode=disable` |
3436

3537
### Step 2: Install Dependencies
3638

@@ -50,6 +52,7 @@ pip install packaging openai agno openrouter sqlalchemy fastapi mcp-databend
5052
Now create your ChatBI agent that uses mcp-databend to interact with your database.
5153

5254
Create a file `agent.py`:
55+
<DetailsWrap>
5356

5457
<details>
5558
<summary>Click to view agent.py code</summary>
@@ -76,16 +79,16 @@ def check_env_vars():
7679
"DATABEND_DSN": "https://docs.databend.com/developer/drivers/#connection-string-dsn",
7780
"OPENROUTER_API_KEY": "https://openrouter.ai/settings/keys"
7881
}
79-
82+
8083
missing = [var for var in required if not os.getenv(var)]
81-
84+
8285
if missing:
8386
print("❌ Missing environment variables:")
8487
for var in missing:
8588
print(f"{var}: {required[var]}")
8689
print("\nExample: export DATABEND_DSN='...' OPENROUTER_API_KEY='...'")
8790
sys.exit(1)
88-
91+
8992
print("✅ Environment variables OK")
9093

9194
check_env_vars()
@@ -94,7 +97,7 @@ class DatabendTool:
9497
def __init__(self):
9598
self.mcp = None
9699
self.dsn = os.getenv("DATABEND_DSN")
97-
100+
98101
def create(self):
99102
env = os.environ.copy()
100103
env["DATABEND_DSN"] = self.dsn
@@ -104,7 +107,7 @@ class DatabendTool:
104107
timeout_seconds=300
105108
)
106109
return self.mcp
107-
110+
108111
async def init(self):
109112
try:
110113
await self.mcp.connect()
@@ -144,12 +147,12 @@ async def lifespan(app: FastAPI):
144147
if not await databend.init():
145148
logger.error("Failed to initialize Databend")
146149
raise RuntimeError("Databend connection failed")
147-
150+
148151
agent.tools.append(tool)
149152
logger.info("ChatBI initialized successfully")
150-
153+
151154
yield
152-
155+
153156
if databend.mcp:
154157
await databend.mcp.close()
155158

@@ -168,7 +171,7 @@ if __name__ == "__main__":
168171
```
169172

170173
</details>
171-
174+
</DetailsWrap>
172175
### Step 4: Configure Environment
173176

174177
Set up your API keys and database connection:
@@ -190,11 +193,12 @@ python agent.py
190193
```
191194

192195
You should see:
196+
193197
```
194198
✅ Environment variables OK
195199
🤖 Starting MCP Server for Databend
196200
Open http://localhost:7777 to start chatting!
197-
INFO Starting playground on http://127.0.0.1:7777
201+
INFO Starting playground on http://127.0.0.1:7777
198202
INFO: Started server process [189851]
199203
INFO: Waiting for application startup.
200204
INFO:agent:✓ Connected to Databend
@@ -216,11 +220,13 @@ cd agent-ui && npm run dev
216220
```
217221

218222
**Connect to Your Agent:**
223+
219224
1. Open [http://localhost:3000](http://localhost:3000)
220225
2. Select "localhost:7777" as your endpoint
221226
3. Start asking questions about your data!
222227

223228
**Try These Queries:**
229+
224230
- "Show me all databases"
225231
- "What tables do I have?"
226232
- "Describe the structure of my tables"
@@ -231,4 +237,4 @@ cd agent-ui && npm run dev
231237
- **GitHub Repository**: [databendlabs/mcp-databend](https://github.com/databendlabs/mcp-databend)
232238
- **PyPI Package**: [mcp-databend](https://pypi.org/project/mcp-databend)
233239
- **Agno Framework**: [Agno MCP](https://docs.agno.com/tools/mcp/mcp)
234-
- **Agent UI**: [Agent UI](https://docs.agno.com/agent-ui/introduction)
240+
- **Agent UI**: [Agent UI](https://docs.agno.com/agent-ui/introduction)

src/components/DocsOverview/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import AI from "@site/static/icons/AI.svg";
3535
import Cases from "@site/static/icons/cases.svg";
3636
import ChangeLog from "@site/static/icons/changelog.svg";
3737
import FAQ from "@site/static/icons/faq.svg";
38+
import MCP from "@site/static/icons/mcp.svg";
3839
import { Col, Row } from "antd";
3940
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
4041
import $t from "@site/src/utils/tools";
@@ -59,7 +60,9 @@ const DocsOverview: FC = (): ReactElement => {
5960
<ContentCardWrap
6061
className={styles.top}
6162
title={$t("Introduction to Databend Products")}
62-
description={$t("Choose the deployment option that best fits your needs and scale.")}
63+
description={$t(
64+
"Choose the deployment option that best fits your needs and scale."
65+
)}
6366
>
6467
<div style={{ height: "100%", width: "100%" }}>
6568
<Row gutter={[12, 12]} className={styles.topCard}>
@@ -68,7 +71,9 @@ const DocsOverview: FC = (): ReactElement => {
6871
<h3>
6972
<span>{$t("Databend Cloud")}</span>
7073
</h3>
71-
<div>{$t("Fully-managed cloud service. No setup required.")}</div>
74+
<div>
75+
{$t("Fully-managed cloud service. No setup required.")}
76+
</div>
7277
</Card>
7378
</Col>
7479
<Col {...colLayout3}>
@@ -312,6 +317,13 @@ const DocsOverview: FC = (): ReactElement => {
312317
to={"/developer/drivers/rust"}
313318
/>
314319
</Col>
320+
<Col {...colLayout}>
321+
<SmallCard
322+
icon={<MCP width={24}></MCP>}
323+
text={"MCP Server"}
324+
to={"/guides/ai-functions/mcp"}
325+
/>
326+
</Col>
315327
</Row>
316328
</div>
317329
</ContentCardWrap>

static/icons/mcp.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)