{"id":26362291,"url":"https://github.com/bytebase/dbhub","last_synced_at":"2025-03-22T15:18:19.403Z","repository":{"id":281521195,"uuid":"945530209","full_name":"bytebase/dbhub","owner":"bytebase","description":"Universal database MCP server connecting to MySQL, PostgreSQL, SQL Server, SQLite, and etc.","archived":false,"fork":false,"pushed_at":"2025-03-18T15:57:18.000Z","size":747,"stargazers_count":32,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T16:46:26.162Z","etag":null,"topics":["ai","anthropic","claude","claude-ai","cursor","cursorai","database","mcp","mcp-server","mysql","postgres","sqlite","sqlserver"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytebase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-09T16:36:38.000Z","updated_at":"2025-03-18T15:57:23.000Z","dependencies_parsed_at":"2025-03-11T08:19:44.563Z","dependency_job_id":null,"html_url":"https://github.com/bytebase/dbhub","commit_stats":null,"previous_names":["bytebase/dbx","bytebase/dbhub"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fdbhub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fdbhub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fdbhub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fdbhub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytebase","download_url":"https://codeload.github.com/bytebase/dbhub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244973810,"owners_count":20541025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","anthropic","claude","claude-ai","cursor","cursorai","database","mcp","mcp-server","mysql","postgres","sqlite","sqlserver"],"created_at":"2025-03-16T18:01:32.316Z","updated_at":"2025-03-22T15:18:19.390Z","avatar_url":"https://github.com/bytebase.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://dbhub.ai/\" target=\"_blank\"\u003e\n\u003cpicture\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/logo-full.svg\" width=\"50%\"\u003e\n\u003c/picture\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\nDBHub is a universal database gateway implementing the Model Context Protocol (MCP) server interface. This gateway allows MCP-compatible clients to connect to and explore different databases.\n\n```bash\n +------------------+    +--------------+    +------------------+\n |                  |    |              |    |                  |\n |                  |    |              |    |                  |\n |  Claude Desktop  +---\u003e+              +---\u003e+    PostgreSQL    |\n |                  |    |              |    |                  |\n |      Cursor      +---\u003e+    DBHub     +---\u003e+    SQL Server    |\n |                  |    |              |    |                  |\n |     Other MCP    +---\u003e+              +---\u003e+     SQLite       |\n |      Clients     |    |              |    |                  |\n |                  |    |              +---\u003e+     MySQL        |\n |                  |    |              |    |                  |\n |                  |    |              +---\u003e+  Other Databases |\n |                  |    |              |    |                  |\n +------------------+    +--------------+    +------------------+\n      MCP Clients           MCP Server             Databases\n```\n\n## Demo SSE Endpoint\n\nhttps://demo.dbhub.ai/sse connects a [sample employee database](https://github.com/bytebase/employee-sample-database). You can point Cursor or MCP Inspector to it to see it in action.\n\n![mcp-inspector](https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/mcp-inspector.webp)\n\n## Supported Matrix\n\n### Database Resources\n\n| Resource |        URI Format         | PostgreSQL | MySQL | SQL Server | SQLite |\n| -------- | :-----------------------: | :--------: | :---: | :--------: | :----: |\n| Tables   |       `db://tables`       |     ✅     |  ✅   |     ✅     |   ✅   |\n| Schema   | `db://schema/{tableName}` |     ✅     |  ✅   |     ✅     |   ✅   |\n\n### Database Tools\n\n| Tool            |   Command Name    | PostgreSQL | MySQL | SQL Server | SQLite |\n| --------------- | :---------------: | :--------: | :---: | :--------: | :----: |\n| Execute Query   |    `run_query`    |     ✅     |  ✅   |     ✅     |   ✅   |\n| List Connectors | `list_connectors` |     ✅     |  ✅   |     ✅     |   ✅   |\n\n### Prompt Capabilities\n\n| Prompt              |  Command Name  | PostgreSQL | MySQL | SQL Server | SQLite |\n| ------------------- | :------------: | :--------: | :---: | :--------: | :----: |\n| Generate SQL        | `generate_sql` |     ✅     |  ✅   |     ✅     |   ✅   |\n| Explain DB Elements |  `explain_db`  |     ✅     |  ✅   |     ✅     |   ✅   |\n\n## Installation\n\n### Docker\n\n```bash\n# PostgreSQL example\ndocker run --rm --init \\\n   --name dbhub \\\n   --publish 8080:8080 \\\n   bytebase/dbhub \\\n   --transport sse \\\n   --port 8080 \\\n   --dsn \"postgres://user:password@localhost:5432/dbname?sslmode=disable\"\n```\n\n```bash\n# Demo mode with sample employee database\ndocker run --rm --init \\\n   --name dbhub \\\n   --publish 8080:8080 \\\n   bytebase/dbhub \\\n   --transport sse \\\n   --port 8080 \\\n   --demo\n```\n\n### NPM\n\n```bash\n# PostgreSQL example\nnpx @bytebase/dbhub --transport sse --port 8080 --dsn \"postgres://user:password@localhost:5432/dbname\"\n```\n\n```bash\n# Demo mode with sample employee database\nnpx @bytebase/dbhub --transport sse --port 8080 --demo\n```\n\n\u003e Note: The demo mode includes a bundled SQLite sample \"employee\" database with tables for employees, departments, salaries, and more.\n\n### Claude Desktop\n\n![claude-desktop](https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/claude-desktop.webp)\n\n- Claude Desktop only supports `stdio` transport https://github.com/orgs/modelcontextprotocol/discussions/16\n\n```json\n// claude_desktop_config.json\n{\n  \"mcpServers\": {\n    \"dbhub-postgres-docker\": {\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\",\n        \"-i\",\n        \"--rm\",\n        \"bytebase/dbhub\",\n        \"--transport\",\n        \"stdio\",\n        \"--dsn\",\n        // Use host.docker.internal as the host if connecting to the local db\n        \"postgres://user:password@host.docker.internal:5432/dbname?sslmode=disable\"\n      ]\n    },\n    \"dbhub-postgres-npx\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"@bytebase/dbhub\",\n        \"--transport\",\n        \"stdio\",\n        \"--dsn\",\n        \"postgres://user:password@localhost:5432/dbname?sslmode=disable\"\n      ]\n    },\n    \"dbhub-demo\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@bytebase/dbhub\", \"--transport\", \"stdio\", \"--demo\"]\n    }\n  }\n}\n```\n\n### Cursor\n\n![cursor](https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/cursor.webp)\n\n- Cursor supports both `stdio` and `sse`.\n- Follow [Cursor MCP guide](https://docs.cursor.com/context/model-context-protocol) and make sure to use [Agent](https://docs.cursor.com/chat/agent) mode.\n\n## Usage\n\n### Configure your database connection\n\nYou can use DBHub in demo mode with a sample employee database for testing:\n\n```bash\npnpm dev --demo\n```\n\nFor real databases, a Database Source Name (DSN) is required. You can provide this in several ways:\n\n- **Command line argument** (highest priority):\n\n  ```bash\n  pnpm dev --dsn \"postgres://user:password@localhost:5432/dbname?sslmode=disable\"\n  ```\n\n- **Environment variable** (second priority):\n\n  ```bash\n  export DSN=\"postgres://user:password@localhost:5432/dbname?sslmode=disable\"\n  pnpm dev\n  ```\n\n- **Environment file** (third priority):\n  - For development: Create `.env.local` with your DSN\n  - For production: Create `.env` with your DSN\n  ```\n  DSN=postgres://user:password@localhost:5432/dbname?sslmode=disable\n  ```\n\nDBHub supports the following database connection string formats:\n\n| Database   | DSN Format                                               | Example                                                          |\n| ---------- | -------------------------------------------------------- | ---------------------------------------------------------------- |\n| PostgreSQL | `postgres://[user]:[password]@[host]:[port]/[database]`  | `postgres://user:password@localhost:5432/dbname?sslmode=disable` |\n| SQLite     | `sqlite:///[path/to/file]` or `sqlite::memory:`          | `sqlite:///path/to/database.db` or `sqlite::memory:`             |\n| SQL Server | `sqlserver://[user]:[password]@[host]:[port]/[database]` | `sqlserver://user:password@localhost:1433/dbname`                |\n| MySQL      | `mysql://[user]:[password]@[host]:[port]/[database]`     | `mysql://user:password@localhost:3306/dbname`                    |\n\n### Transport\n\n- **stdio** (default) - for direct integration with tools like Claude Desktop:\n\n  ```bash\n  npx @bytebase/dbhub --transport stdio --dsn \"postgres://user:password@localhost:5432/dbname?sslmode=disable\"\n  ```\n\n- **sse** - for browser and network clients:\n  ```bash\n  npx @bytebase/dbhub --transport sse --port 5678 --dsn \"postgres://user:password@localhost:5432/dbname?sslmode=disable\"\n  ```\n\n### Command line options\n\n| Option    | Description                                                     | Default                      |\n| :-------- | :-------------------------------------------------------------- | :--------------------------- |\n| demo      | Run in demo mode with sample employee database                  | `false`                      |\n| dsn       | Database connection string                                      | Required if not in demo mode |\n| transport | Transport mode: `stdio` or `sse`                                | `stdio`                      |\n| port      | HTTP server port (only applicable when using `--transport=sse`) | `8080`                       |\n\nThe demo mode uses an in-memory SQLite database loaded with the [sample employee database](https://github.com/bytebase/dbhub/tree/main/resources/employee-sqlite) that includes tables for employees, departments, titles, and salaries.\n\n## Development\n\n1. Install dependencies:\n\n   ```bash\n   pnpm install\n   ```\n\n1. Run in development mode:\n\n   ```bash\n   pnpm dev\n   ```\n\n1. Build for production:\n   ```bash\n   pnpm build\n   pnpm start --transport stdio --dsn \"postgres://user:password@localhost:5432/dbname?sslmode=disable\"\n   ```\n\n### Debug with [MCP Inspector](https://github.com/modelcontextprotocol/inspector)\n\n#### stdio\n\n```bash\n# PostgreSQL example\nTRANSPORT=stdio DSN=\"postgres://user:password@localhost:5432/dbname?sslmode=disable\" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js\n```\n\n#### SSE\n\n```bash\n# Start DBHub with SSE transport\npnpm dev --transport=sse --port=8080\n\n# Start the MCP Inspector in another terminal\nnpx @modelcontextprotocol/inspector\n```\n\nConnect to the DBHub server `/sse` endpoint\n","funding_links":[],"categories":["Databases","Database \u0026 Messaging MCP Servers","Community Servers","TypeScript","📚 Projects (1974 total)","📦 Other","Legend","APIs and HTTP Requests","sqlserver","Agent Integration \u0026 Deployment Tools","🗄️ Databases","Table of Contents","MCP Ecosystem","Uncategorized","Tools","MCP Servers","🗂️ Extensions by Category"],"sub_categories":["Multi-Database Tools","MCP Servers","🗄️ \u003ca name=\"databases\"\u003e\u003c/a\u003eDatabases","How to Submit","MCP Server Framework","Databases","Servers","Uncategorized","Model Context Protocol","🗄️ Databases"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebase%2Fdbhub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytebase%2Fdbhub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebase%2Fdbhub/lists"}