Skip to content

Commit 51c3f36

Browse files
authored
Merge pull request #1 from BohuTANG/rr1
improve the readme
2 parents 0cc9d6e + 4cd9efb commit 51c3f36

File tree

11 files changed

+278
-161
lines changed

11 files changed

+278
-161
lines changed

.github/workflows/python-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ jobs:
6767
- name: Publish release distributions to PyPI
6868
uses: pypa/gh-action-pypi-publish@release/v1
6969
with:
70-
packages-dir: dist/
70+
packages-dir: dist/

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,9 @@ cython_debug/
173173

174174
# PyPI configuration file
175175
.pypirc
176+
177+
# Virtual environments
178+
.venv/
179+
myenv/
180+
venv/
181+
env/

README.md

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,75 @@
1-
# mcp-server-databend
2-
MCP server of databend
1+
# MCP Server for Databend
32

4-
# Install
3+
[![PyPI - Version](https://img.shields.io/pypi/v/mcp-databend)](https://pypi.org/project/mcp-databend)
4+
5+
An MCP server for Databend database interactions.
6+
7+
## What You Can Do
8+
9+
- **execute_sql** - Execute SQL queries with timeout protection
10+
- **show_databases** - List all databases
11+
- **show_tables** - List tables in a database (with optional filter)
12+
- **describe_table** - Get table schema information
13+
14+
## How to Use
15+
16+
### Step 1: Get Databend Connection
17+
18+
**Recommended**: Sign up for [Databend Cloud](https://app.databend.com) (free tier available)
19+
20+
Get your connection string from [Databend documentation](https://docs.databend.com/developer/drivers/#connection-string-dsn).
21+
22+
| Deployment | Connection String Example |
23+
|------------|---------------------------|
24+
| **Databend Cloud** | `databend://cloudapp:pass@host:443/database?warehouse=wh` |
25+
| **Self-hosted** | `databend://user:pass@localhost:8000/database?sslmode=disable` |
26+
27+
### Step 2: Install
528

629
```bash
7-
uv sync --all-groups --all-extras
30+
uv tool install mcp-databend
831
```
932

10-
# ENV configs
33+
### Step 3: Configure Your MCP Client
34+
35+
#### MCP Configuration
1136

12-
| ENV | usage | default value |
13-
| --- | --- | --- |
14-
| DATABEND_DSN | The dsn connect string | databend://default:@127.0.0.1:8000/?sslmode=disable|
37+
Add to your MCP client configuration (e.g., Claude Desktop, Windsurf):
1538

39+
```json
40+
{
41+
"mcpServers": {
42+
"mcp-databend": {
43+
"command": "uv",
44+
"args": ["tool", "run", "mcp-databend"],
45+
"env": {
46+
"DATABEND_DSN": "your-connection-string-here"
47+
}
48+
}
49+
}
50+
}
51+
```
52+
53+
#### Supported Clients
1654

17-
# Example for using `cherry studio`
55+
- **Windsurf** / **Claude Desktop** / **Continue.dev** / **Cursor IDE**
1856

19-
![alt text](assets/cherry-studio.png)
20-
![alt text](assets/list-database-tables.png)
57+
### Step 4: Start Using
2158

59+
Once configured, you can ask your AI assistant to:
60+
- "Show me all databases"
61+
- "List tables in the sales database"
62+
- "Describe the users table structure"
63+
- "Run this SQL query: SELECT * FROM products LIMIT 10"
2264

23-
# Dev testing
65+
## Development
2466

2567
```bash
26-
mcp dev server.py
68+
# Clone and setup
69+
git clone https://github.com/databendlabs/mcp-databend
70+
cd mcp-databend
71+
uv sync
72+
73+
# Run locally
74+
uv run python -m mcp_databend.main
2775
```

assets/cherry-studio.png

-235 KB
Binary file not shown.

assets/list-database-tables.png

-297 KB
Binary file not shown.

mcp_databend/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""MCP Server for Databend database interactions."""
2+
3+
from .main import main
4+
5+
__all__ = ["main"]
File renamed without changes.

mcp_databend/main.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Main entry point for the MCP Databend server."""
2+
3+
import sys
4+
import logging
5+
from .server import mcp, logger
6+
7+
8+
def main():
9+
"""Main entry point for the MCP server."""
10+
try:
11+
logger.info("Starting Databend MCP Server...")
12+
mcp.run()
13+
except KeyboardInterrupt:
14+
logger.info("Shutting down server by user request")
15+
except Exception as e:
16+
logger.error(f"Server startup failed: {str(e)}")
17+
sys.exit(1)
18+
19+
20+
if __name__ == "__main__":
21+
main()

server.py renamed to mcp_databend/server.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Constants
1313
SERVER_NAME = "mcp-databend"
14-
DEFAULT_TIMEOUT = 30 # seconds
14+
DEFAULT_TIMEOUT = 60 # seconds
1515

1616
# Configure logging
1717
logging.basicConfig(
@@ -159,7 +159,8 @@ def describe_table(table: str, database: Optional[str] = None):
159159
return execute_sql(sql)
160160

161161

162-
if __name__ == "__main__":
162+
def main():
163+
"""Main entry point for the MCP server."""
163164
try:
164165
logger.info("Starting Databend MCP Server...")
165166
mcp.run()
@@ -168,3 +169,7 @@ def describe_table(table: str, database: Optional[str] = None):
168169
except Exception as e:
169170
logger.error(f"Server startup failed: {str(e)}")
170171
sys.exit(1)
172+
173+
174+
if __name__ == "__main__":
175+
main()

pyproject.toml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,53 @@
11
[project]
2-
name = "mcp-server-databend"
3-
version = "0.1.0"
4-
description = "Add your description here"
2+
name = "mcp-databend"
3+
version = "0.1.2"
4+
description = "An MCP server for Databend."
55
readme = "README.md"
66
requires-python = ">=3.12"
7+
authors = [
8+
{ name = "Databend Labs", email = "[email protected]" },
9+
]
10+
maintainers = [
11+
{ name = "Databend Labs", email = "[email protected]" },
12+
]
13+
license = "Apache-2.0"
14+
keywords = ["mcp", "databend", "database", "sql", "ai"]
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Intended Audience :: Developers",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.12",
20+
"Topic :: Database",
21+
"Topic :: Software Development :: Libraries :: Python Modules",
22+
]
723
dependencies = [
824
"databend-driver>=0.27.3",
925
"mcp>=1.9.0",
1026
"python-dotenv>=1.1.0",
1127
]
1228

29+
[project.urls]
30+
Homepage = "https://github.com/databendlabs/mcp-databend"
31+
Repository = "https://github.com/databendlabs/mcp-databend"
32+
Documentation = "https://github.com/databendlabs/mcp-databend#readme"
33+
Issues = "https://github.com/databendlabs/mcp-databend/issues"
34+
35+
[project.scripts]
36+
mcp-databend = "mcp_databend.main:main"
37+
1338
[dependency-groups]
1439
dev = [
1540
"mcp[cli]>=1.9.0",
1641
"ruff>=0.1.0",
1742
]
1843

44+
[build-system]
45+
requires = ["setuptools>=61.0", "wheel"]
46+
build-backend = "setuptools.build_meta"
47+
48+
[tool.setuptools.packages.find]
49+
include = ["mcp_databend*"]
50+
1951
[tool.ruff]
2052
target-version = "py312"
2153
lint.select = ["E", "F", "I", "N", "Q", "T", "W"]

0 commit comments

Comments
 (0)