Skip to content

Commit 57f8364

Browse files
authored
Merge pull request #40 from kshashikumar/fix-codeowners
Fix codeowners
2 parents 1b4537b + f80a0e9 commit 57f8364

174 files changed

Lines changed: 23892 additions & 14969 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 135 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[![Contributors](https://img.shields.io/github/contributors/kshashikumar/dbfuse-ai)](https://github.com/kshashikumar/dbfuse-ai/graphs/contributors)
1414
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/kshashikumar/dbfuse-ai/badge)](https://securityscorecards.dev/viewer/?uri=github.com/kshashikumar/dbfuse-ai)
1515

16-
**DBFuse AI** is a simple web UI to connect to your databases, run SQL, and generate SQL with AI. It works with MySQL, PostgreSQL, SQL Server, Oracle, and SQLite.
16+
**DBFuse AI** is a simple web UI to connect to your databases, run SQL, and generate SQL with AI. It works with MySQL, PostgreSQL, SQL Server, Oracle, and SQLite. Now with Claude Desktop integration via Model Context Protocol (MCP) - 12 tools available for natural database interactions.
1717

1818
Quick links:
1919

@@ -47,11 +47,17 @@ Quick links:
4747
- **Basic Authentication**
4848
Optional authentication for added security when running on remote servers.
4949

50+
- **Connection Encryption**
51+
Secure database credentials with AES-256 encryption.
52+
53+
- **Claude Desktop Integration (MCP)**
54+
12 powerful tools for Claude Desktop to interact with your databases naturally.
55+
5056
- **Clipboard Copy**
5157
Quickly copy cell data with a single click.
5258

5359
- **AI Integration**
54-
Leverage OpenAI and Google Gemini for generating intelligent SQL queries. Talk to your selected Database
60+
Leverage multiple AI providers (Gemini, OpenAI, Anthropic, Mistral, Cohere, HuggingFace, Perplexity) for generating intelligent SQL queries. Talk to your selected Database
5561

5662
## Prerequisites
5763

@@ -85,9 +91,12 @@ Pick the option that fits your setup. All commands below assume a Bash-compatibl
8591
- `-p, --port <number>`: Server port (default 5000)
8692
- `--dbuser <username>` and `--dbpass <password>`: Set Basic Auth credentials for the web UI
8793
- `--model <name>` and `--apikey <key>`: Enable AI with the selected model and API key
94+
- `--connections-key <value>`: Provide the AES-256 key used to encrypt `dbConnections.json` (type `clear` to disable)
95+
- `--connections-reset`: Delete `dbConnections.json` before starting (useful if you've lost the encryption key)
96+
- `--mcp`: Start only MCP server without HTTP server (for Claude Desktop integration)
8897
- `-v, --verbose`: Show detailed prompts and info in the CLI
8998

90-
Supported AI providers include: Gemini, OpenAI, Anthropic, Mistral, Cohere, Hugging Face, and Perplexity. Without `--model` and `--apikey`, the CLI will ask whether to enable AI and guide you interactively.
99+
Supported AI providers include: Gemini, OpenAI, Anthropic, Mistral, Cohere, Hugging Face, and Perplexity. Without `--model`, `--apikey`, or `--connections-key`, the CLI will walk you through the required prompts (you can press Enter to keep plaintext storage if you do not want encryption).
91100

92101
Then open http://localhost:5000.
93102

@@ -109,6 +118,8 @@ Pick the option that fits your setup. All commands below assume a Bash-compatibl
109118
# Optional basic auth for UI (set both to enable)
110119
- DBFUSE_USERNAME=admin
111120
- DBFUSE_PASSWORD=admin
121+
# Optional: encrypt saved db connections (recommended)
122+
- CONNECTIONS_ENCRYPTION_KEY=your_32_character_encryption_key
112123
# AI configuration (optional)
113124
- AI_PROVIDER=gemini
114125
- AI_MODEL=gemini-2.5-flash
@@ -247,6 +258,8 @@ Notes:
247258
- PORT: Server port (default 5000)
248259
- DBFUSE_USERNAME / DBFUSE_PASSWORD: enable Basic Auth for the web UI (optional)
249260
- AI_PROVIDER, AI_MODEL, AI_API_KEY: AI settings (optional)
261+
- CONNECTIONS_ENCRYPTION_KEY: AES-256 key to encrypt database connections (optional, 32 characters recommended)
262+
- MCP_ONLY: Run only MCP server without HTTP (true/false, default false)
250263
- BODY_SIZE: request body size limit (default 50mb)
251264
- NODE_ENV: set to `production` in containers for best performance
252265
Note: Database connection details are entered via the UI; no DB URL environment variables are used by the server.
@@ -265,6 +278,125 @@ Tips:
265278
- Oracle Database
266279
- SQLite
267280

281+
## MCP Server Integration (Claude Desktop)
282+
283+
DBFuse AI includes a Model Context Protocol (MCP) server that enables Claude Desktop to directly access your databases.
284+
285+
### Available MCP Tools (12 total)
286+
287+
**Authentication:**
288+
289+
- `login` - Authenticate with DBFuse AI server
290+
291+
**Connection Management:**
292+
293+
- `list_connections` - List all saved database connections
294+
- `connect_database` - Connect to a specific database
295+
296+
**Query Operations:**
297+
298+
- `execute_query` - Execute SQL queries with pagination
299+
- `get_tables` - List all tables in the current database
300+
301+
**Schema Exploration:**
302+
303+
- `get_databases` - List all databases on the server
304+
- `get_table_info` - Get detailed table information (columns, types, constraints)
305+
- `switch_database` - Switch to a different database
306+
- `get_views` - List all views in the database
307+
- `get_procedures` - List all stored procedures
308+
309+
**Analysis & AI:**
310+
311+
- `analyze_query` - Get query performance analysis (EXPLAIN)
312+
- `generate_sql` - Generate SQL from natural language using AI
313+
314+
### Setup for Claude Desktop
315+
316+
**Option 1: NPX (Quick Start)**
317+
318+
Edit your Claude Desktop config file:
319+
320+
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
321+
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
322+
323+
Add this configuration:
324+
325+
```json
326+
{
327+
"mcpServers": {
328+
"dbfuse-ai": {
329+
"command": "npx",
330+
"args": ["-y", "dbfuse-ai", "--mcp"],
331+
"env": {
332+
"DBFUSE_USERNAME": "your username",
333+
"DBFUSE_PASSWORD": "your password"
334+
}
335+
}
336+
}
337+
}
338+
```
339+
340+
**Option 2: Global Install**
341+
342+
```bash
343+
# Install globally
344+
npm install -g dbfuse-ai
345+
346+
# Find the installation path
347+
npm root -g
348+
```
349+
350+
Then configure Claude Desktop:
351+
352+
```json
353+
{
354+
"mcpServers": {
355+
"dbfuse-ai": {
356+
"command": "node",
357+
"args": ["d:/vs-code/dbfuse-ai/src/mcp/server.js"],
358+
"transport": "stdio",
359+
"workingDirectory": "d:/vs-code/dbfuse-ai",
360+
"env": {
361+
"MCP_ENABLED": "true",
362+
"MCP_ONLY": "true",
363+
"LOG_LEVEL": "error",
364+
"DBFUSE_USERNAME": "root",
365+
"DBFUSE_PASSWORD": "root"
366+
}
367+
}
368+
}
369+
}
370+
```
371+
372+
**Option 3: MCP Server Only Mode**
373+
374+
Run DBFuse AI as MCP server only (no web UI):
375+
376+
```bash
377+
# Using CLI
378+
dbfuse-ai --mcp --dbuser admin --dbpass admin
379+
380+
# Using environment variable
381+
MCP_ONLY=true DBFUSE_USERNAME=admin DBFUSE_PASSWORD=admin npm start
382+
```
383+
384+
**Note:** By default, both HTTP (Web UI) and MCP servers run simultaneously. Use `--mcp` flag or `MCP_ONLY=true` to run only the MCP server.
385+
386+
### Example Usage with Claude
387+
388+
Once configured, you can ask Claude:
389+
390+
> "Connect to my database and show me all tables"
391+
392+
> "What's the structure of the users table?"
393+
394+
> "Generate SQL to find all orders from last month"
395+
396+
> "Execute: SELECT \* FROM products WHERE stock < 10"
397+
398+
Claude will use the appropriate MCP tools to interact with your databases.
399+
268400
## CLI (optional)
269401

270402
If you installed globally with npm, you can start with:
@@ -314,7 +446,6 @@ To disable authentication, remove these variables from `.env` and restart the se
314446
- AI: Explain/optimize queries and suggest indexes in addition to SQL generation
315447
- Charts and visual analysis for query results (line/bar/pie), with quick pivots
316448
- Pluggable driver/extension SDK to add new databases and tools
317-
- MCP servers implementation to connect to different databases
318449

319450
## Contributions
320451

0 commit comments

Comments
 (0)