Skip to content

Commit 8831ecd

Browse files
AI Translate 51-ai-functions to Simplified-Chinese (#2668)
* [INIT] Start translation to Simplified-Chinese * 🌐 Translate 02-mcp.md to Simplified-Chinese --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent cb61e14 commit 8831ecd

File tree

2 files changed

+56
-58
lines changed

2 files changed

+56
-58
lines changed

.translation-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Translation initialization: 2025-08-07T12:15:30.045055
1+
Translation initialization: 2025-08-08T08:55:14.760013

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

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import DetailsWrap from '@site/src/components/DetailsWrap';
22

33
# 适用于 Databend 的 MCP Server
44

5-
[mcp-databend](https://github.com/databendlabs/mcp-databend) 是一个 MCP(Model Context Protocol)服务器,它让 AI 助手能够使用自然语言直接与您的 Databend 数据库交互。
5+
[mcp-databend](https://github.com/databendlabs/mcp-databend) 是一个 MCP(Model Context Protocol)服务器,使 AI 助手能够使用自然语言直接与你的 Databend 数据库交互。
66

77
## mcp-databend 能做什么
88

@@ -13,28 +13,47 @@ import DetailsWrap from '@site/src/components/DetailsWrap';
1313

1414
## 构建 ChatBI 工具
1515

16-
本教程将演示如何使用 mcp-databend 和 Agno 框架构建一个对话式商业智能(Business Intelligence)工具。您将创建一个本地 Agent,能够用自然语言回答数据问题。
16+
本教程将展示如何使用 mcp-databend 和 Agno 框架构建对话式商业智能(Business Intelligence)工具。你将创建一个本地 Agent,能够用自然语言回答数据问题。
1717

1818
![Databend MCP ChatBI](@site/static/img/connect/databend-mcp-chatbi.png)
1919

20+
## 前置条件
21+
22+
开始前,你需要:
23+
24+
1. **Databend 数据库** - 可选择 [Databend Cloud](https://app.databend.cn)(提供免费套餐)或自托管实例
25+
2. **DeepSeek API Key** - 从 [https://platform.deepseek.com/api_keys](https://platform.deepseek.com/api_keys) 获取
26+
2027
## 分步教程
2128

2229
### 第 1 步:配置 Databend 连接
2330

24-
首先,您需要一个可连接的 Databend 数据库:
31+
如果还没有 Databend 数据库:
32+
33+
1. **注册 [Databend Cloud](https://app.databend.cn)**(免费套餐可用)
34+
2. **创建 Warehouse 和数据库**
35+
3. **在控制台获取连接字符串**
36+
37+
有关 DSN 格式和示例,参阅[连接字符串文档](https://docs.databend.cn/developer/drivers/#connection-string-dsn)
2538

26-
1. **注册 [Databend Cloud](https://app.databend.cn)**(提供免费套餐)
27-
2. **创建 Warehouse 和 Database**
28-
3. **在控制台获取连接字符串(Connection String)**
39+
| 部署方式 | 连接字符串示例 |
40+
| ------------------ | ------------------------------------------------------------- |
41+
| **Databend Cloud** | `databend://user:pwd@host:443/database?warehouse=wh` |
42+
| **自托管** | `databend://user:pwd@localhost:8000/database?sslmode=disable` |
2943

30-
有关 DSN 格式和示例的详细信息,请参阅[连接字符串文档](https://docs.databend.cn/developer/drivers/#connection-string-dsn)
44+
### 第 2 步:配置 API Key 和环境变量
3145

32-
| 部署方式 | 连接字符串示例 |
33-
| ------------------ | ------------------------------------------------------------ |
34-
| **Databend Cloud** | `databend://user:pwd@host:443/database?warehouse=wh` |
35-
| **自托管** | `databend://user:pwd@localhost:8000/database?sslmode=disable`|
46+
设置 API Key 和数据库连接:
3647

37-
### 第 2 步:安装依赖
48+
```bash
49+
# 设置 DeepSeek API Key
50+
export DEEPSEEK_API_KEY="your-deepseek-api-key"
51+
52+
# 设置 Databend 连接字符串
53+
export DATABEND_DSN="your-databend-connection-string"
54+
```
55+
56+
### 第 3 步:安装依赖
3857

3958
创建虚拟环境并安装所需包:
4059

@@ -44,18 +63,14 @@ python3 -m venv .venv
4463
source .venv/bin/activate
4564

4665
# 安装包
47-
pip install packaging openai agno openrouter sqlalchemy fastapi mcp-databend
66+
pip install packaging openai agno sqlalchemy fastapi mcp-databend
4867
```
4968

50-
### 3 步:创建 ChatBI Agent
69+
### 4 步:创建 ChatBI Agent
5170

52-
现在创建 ChatBI Agent,它将使用 mcp-databend 与您的数据库交互
71+
现在创建 ChatBI Agent,它将使用 mcp-databend 与数据库交互
5372

5473
创建文件 `agent.py`
55-
<DetailsWrap>
56-
57-
<details>
58-
<summary>点击查看 agent.py 代码</summary>
5974

6075
```python
6176
from contextlib import asynccontextmanager
@@ -67,17 +82,16 @@ from agno.agent import Agent
6782
from agno.playground import Playground
6883
from agno.storage.sqlite import SqliteStorage
6984
from agno.tools.mcp import MCPTools
70-
from agno.models.openrouter import OpenRouter
85+
from agno.models.deepseek import DeepSeek
7186
from fastapi import FastAPI
7287

7388
logging.basicConfig(level=logging.INFO)
7489
logger = logging.getLogger(__name__)
7590

7691
def check_env_vars():
77-
"""检查必需的环境变量"""
7892
required = {
7993
"DATABEND_DSN": "https://docs.databend.cn/developer/drivers/#connection-string-dsn",
80-
"OPENROUTER_API_KEY": "https://openrouter.ai/settings/keys"
94+
"DEEPSEEK_API_KEY": "https://platform.deepseek.com/api_keys"
8195
}
8296

8397
missing = [var for var in required if not os.getenv(var)]
@@ -86,7 +100,7 @@ def check_env_vars():
86100
print("❌ 缺少环境变量:")
87101
for var in missing:
88102
print(f"{var}: {required[var]}")
89-
print("\n示例:export DATABEND_DSN='...' OPENROUTER_API_KEY='...'")
103+
print("\n示例:export DATABEND_DSN='...' DEEPSEEK_API_KEY='...'")
90104
sys.exit(1)
91105

92106
print("✅ 环境变量检查通过")
@@ -121,16 +135,13 @@ databend = DatabendTool()
121135

122136
agent = Agent(
123137
name="ChatBI",
124-
model=OpenRouter(
125-
id=os.getenv("MODEL_ID", "anthropic/claude-sonnet-4"),
126-
api_key=os.getenv("OPENROUTER_API_KEY")
127-
),
138+
model=DeepSeek(),
128139
tools=[],
129140
instructions=[
130141
"你是 ChatBI - 专为 Databend 打造的商业智能助手。",
131142
"帮助用户使用自然语言探索和分析数据。",
132-
"始终先探索可用的数据库和表",
133-
"以清晰、易读的表格格式展示查询结果",
143+
"始终从探索可用数据库和表开始",
144+
"将查询结果格式化为清晰易读的表格",
134145
"在分析中提供见解和解释。"
135146
],
136147
storage=SqliteStorage(table_name="chatbi", db_file="chatbi.db"),
@@ -145,7 +156,7 @@ agent = Agent(
145156
async def lifespan(app: FastAPI):
146157
tool = databend.create()
147158
if not await databend.init():
148-
logger.error("Databend 初始化失败")
159+
logger.error("初始化 Databend 失败")
149160
raise RuntimeError("Databend 连接失败")
150161

151162
agent.tools.append(tool)
@@ -165,23 +176,10 @@ playground = Playground(
165176
app = playground.get_app(lifespan=lifespan)
166177

167178
if __name__ == "__main__":
168-
print("🤖 正在启动 Databend MCP Server")
179+
print("🤖 正在为 Databend 启动 MCP Server")
169180
print("打开 http://localhost:7777 开始聊天!")
170181
playground.serve(app="agent:app", host="127.0.0.1", port=7777)
171-
```
172-
173-
</details>
174-
</DetailsWrap>
175-
### 第 4 步:配置环境
176-
177-
设置您的 API 密钥和数据库连接:
178182

179-
```bash
180-
# 设置 OpenRouter API 密钥
181-
export OPENROUTER_API_KEY="your-openrouter-key"
182-
183-
# 设置 Databend 连接字符串
184-
export DATABEND_DSN="your-databend-connection-string"
185183
```
186184

187185
### 第 5 步:启动 ChatBI Agent
@@ -192,22 +190,22 @@ export DATABEND_DSN="your-databend-connection-string"
192190
python agent.py
193191
```
194192

195-
您将看到
193+
你将看到
196194

197195
```
198196
✅ 环境变量检查通过
199-
🤖 正在启动 Databend MCP Server
197+
🤖 正在为 Databend 启动 MCP Server
200198
打开 http://localhost:7777 开始聊天!
201-
INFO Starting playground on http://127.0.0.1:7777
199+
INFO 正在 http://127.0.0.1:7777 启动 playground
202200
INFO: Started server process [189851]
203-
INFO: Waiting for application startup.
201+
INFO: 等待应用启动。
204202
INFO:agent:✓ 已连接到 Databend
205203
INFO:agent:ChatBI 初始化成功
206-
INFO: Application startup complete.
207-
INFO: Uvicorn running on http://127.0.0.1:7777 (Press CTRL+C to quit)
204+
INFO: 应用启动完成。
205+
INFO: Uvicorn 运行在 http://127.0.0.1:7777(按 CTRL+C 退出)
208206
```
209207

210-
### 第 6 步:设置 Web 界面
208+
### 第 6 步:配置 Web 界面
211209

212210
为获得更佳体验,可配置 Agno 的 Web 界面:
213211

@@ -219,11 +217,11 @@ npx create-agent-ui@latest
219217
cd agent-ui && npm run dev
220218
```
221219

222-
**连接到您的 Agent:**
220+
**连接到 Agent:**
223221

224222
1. 打开 [http://localhost:3000](http://localhost:3000)
225223
2. 选择 "localhost:7777" 作为端点
226-
3. 开始提问关于您的数据
224+
3. 开始提问关于数据的问题
227225

228226
**试试这些查询:**
229227

@@ -234,7 +232,7 @@ cd agent-ui && npm run dev
234232

235233
## 资源
236234

237-
- **GitHub 仓库**[databendlabs/mcp-databend](https://github.com/databendlabs/mcp-databend)
238-
- **PyPI 包**[mcp-databend](https://pypi.org/project/mcp-databend)
239-
- **Agno 框架**[Agno MCP](https://docs.agno.com/tools/mcp/mcp)
240-
- **Agent UI**[Agent UI](https://docs.agno.com/agent-ui/introduction)
235+
- **GitHub 仓库**: [databendlabs/mcp-databend](https://github.com/databendlabs/mcp-databend)
236+
- **PyPI 包**: [mcp-databend](https://pypi.org/project/mcp-databend)
237+
- **Agno 框架**: [Agno MCP](https://docs.agno.com/tools/mcp/mcp)
238+
- **Agent UI**: [Agent UI](https://docs.agno.com/agent-ui/introduction)

0 commit comments

Comments
 (0)