### Install DBHub Globally and Run Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Install DBHub globally using npm and then run the server. Includes an example for demo mode. ```bash # Install globally npm install -g @bytebase/dbhub@latest # Run the server dbhub --transport http --port 8080 --dsn "postgres://..." # Or use demo mode for testing dbhub --transport http --port 8080 --demo ``` -------------------------------- ### Starting DBHub with TOML Configuration Source: https://github.com/bytebase/dbhub/blob/main/docs/config/toml.mdx Examples of how to start the DBHub server, either automatically loading a local TOML file or specifying a custom path. ```bash # Automatically loads ./dbhub.toml npx @bytebase/dbhub@latest --transport http --port 8080 # Or specify custom location npx @bytebase/dbhub@latest --config=/path/to/config.toml ``` -------------------------------- ### Start DBHub HTTP Server with Config File Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Start DBHub as an HTTP server using a configuration file for multi-database setups. This allows for more complex configurations. ```bash npx @bytebase/dbhub@latest --transport http --port 8080 --config /path/to/dbhub.toml ``` -------------------------------- ### Install DBHub with DSN Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-dbhub.mdx Install and run DBHub using npm with a direct connection string (DSN) to your database. No configuration file is needed for basic setup. ```bash npx @bytebase/dbhub@latest --dsn "postgres://user:password@localhost:5432/dbname" ``` -------------------------------- ### Start DBHub with NPM (HTTP Transport) Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx Use this command to start the DBHub server using NPM for HTTP transport in demo mode. Ensure Node.js is installed. ```bash npx @bytebase/dbhub@latest --transport http --port 8080 --demo ``` -------------------------------- ### Start DBHub with Docker (HTTP Transport) Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx Use this command to start the DBHub server using Docker for HTTP transport in demo mode. Ensure Docker is installed. ```bash docker run --rm -p 8080:8080 bytebase/dbhub --transport http --port 8080 --demo ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/bytebase/dbhub/blob/main/docs/README.md Install the Mintlify CLI globally using npm. This is required to preview documentation locally. ```bash npm i -g mint ``` -------------------------------- ### Install Dependencies Source: https://github.com/bytebase/dbhub/blob/main/README.md Installs the necessary project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### TOML Configuration Example Source: https://github.com/bytebase/dbhub/blob/main/docs/config/toml.mdx A basic TOML configuration file defining database sources and tool settings. ```toml # Define database sources [[sources]] id = "production" dsn = "postgres://user:pass@localhost:5432/mydb" connection_timeout = 60 [[sources]] id = "staging" dsn = "mysql://root:pass@localhost:3306/myapp" # Configure tools for each source [[tools]] name = "execute_sql" source = "production" readonly = true max_rows = 1000 [[tools]] name = "execute_sql" source = "staging" readonly = false ``` -------------------------------- ### Start DBHub Server Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Runs the compiled server. Use this for production deployment. ```bash pnpm run start ``` -------------------------------- ### Setting DBHub Environment Variables Source: https://github.com/bytebase/dbhub/blob/main/docs/config/toml.mdx Example of how to set environment variables before starting DBHub to be used in TOML configuration. ```bash # Set env vars, then start DBHub export DB_PASSWORD="s3cret" export STAGING_HOST="staging.example.com" export STAGING_PASSWORD="staging_pass" export SSH_PASSWORD="ssh_pass" npx @bytebase/dbhub@latest --config dbhub.toml ``` -------------------------------- ### DSN Query Parameter Examples Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Illustrative examples of DSNs incorporating query parameters for SSL mode, certificate paths, instance names, and authentication methods. ```bash # Examples postgres://user:password@localhost:5432/dbname?sslmode=disable postgres://user:password@localhost:5432/dbname?sslmode=require postgres://user:password@rds-host:5432/dbname?sslmode=verify-ca&sslrootcert=~/.ssl/rds-ca.pem sqlserver://jsmith:secret@localhost:1433/mydb?authentication=ntlm&domain=CORP ``` -------------------------------- ### Start Claude Code Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Start Claude Code in your project directory to begin using its features. ```bash claude ``` -------------------------------- ### Minimal npm Installation (PostgreSQL) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Install DBHub globally with only the PostgreSQL driver to reduce installation size. Requires installing the 'pg' package separately. ```bash npm install -g @bytebase/dbhub@latest --omit=optional && npm install -g pg ``` -------------------------------- ### Complete TOML Configuration Example Source: https://github.com/bytebase/dbhub/blob/main/docs/config/toml.mdx Illustrates a comprehensive TOML configuration for Bytebase, including multiple data sources, SSH tunneling, and various tool definitions with parameters. ```toml # Multi-database configuration with different tool settings [[sources]] id = "production" dsn = "postgres://user:pass@db.prod.internal:5432/mydb" lazy = true # Defer connection until first query connection_timeout = 60 query_timeout = 30 sslmode = "require" # Production SSH tunnel through bastion ssh_host = "bastion.prod.example.com" ssh_user = "deploy" ssh_key = "~/.ssh/prod_key" [[sources]] id = "staging" dsn = "postgres://user:pass@db.staging.internal:5432/mydb" connection_timeout = 30 query_timeout = 15 # Staging SSH tunnel ssh_host = "bastion.staging.example.com" ssh_user = "ubuntu" ssh_key = "~/.ssh/staging_key" [[sources]] id = "local_sqlite" dsn = "sqlite:///./data/local.db" # Production tool - read-only with row limits [[tools]] name = "execute_sql" source = "production" readonly = true max_rows = 1000 # Staging tool - full access with row limits [[tools]] name = "execute_sql" source = "staging" readonly = false max_rows = 5000 # Local tool - full access, unlimited rows [[tools]] name = "execute_sql" source = "local_sqlite" readonly = false # Custom tool - search employees with parameters [[tools]] name = "search_employees" description = "Search employees by name with configurable result limit" source = "production" statement = "SELECT emp_no, first_name, last_name FROM employee WHERE first_name ILIKE '%' || $1 || '%' LIMIT $2" [[tools.parameters]] name = "search_term" type = "string" description = "Name to search for (case-insensitive partial match)" [[tools.parameters]] name = "limit" type = "integer" description = "Maximum number of results" default = 10 ``` -------------------------------- ### PostgreSQL DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for connecting to a PostgreSQL database. ```sql postgres://user:password@localhost:5432/dbname?sslmode=disable ``` -------------------------------- ### Install DBHub Agent Skill Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx Command to install the DBHub agent skill, which enhances AI database interaction by guiding it through an explore-then-query workflow. ```bash npx skills add bytebase/dbhub ``` -------------------------------- ### Start MCP Toolbox Server Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-mcp-toolbox.mdx Launch the MCP Toolbox server using the generated configuration file. The server logs indicate initialization status and readiness. ```bash ./toolbox --tools-file "tools.yaml" 2025-12-19T08:10:47.443076-08:00 INFO "Initialized 1 sources: local-pg" 2025-12-19T08:10:47.443379-08:00 INFO "Initialized 0 authServices: " 2025-12-19T08:10:47.443488-08:00 INFO "Initialized 1 tools: current_managers" 2025-12-19T08:10:47.443512-08:00 INFO "Initialized 1 toolsets: default" 2025-12-19T08:10:47.443517-08:00 INFO "Initialized 0 prompts: " 2025-12-19T08:10:47.443524-08:00 INFO "Initialized 1 promptsets: default" 2025-12-19T08:10:47.443665-08:00 WARN "wildcard (`*`) allows all origin to access the resource and is not secure. Use it with cautious for public, non-sensitive data, or during local development. Recommended to use `--allowed-origins` flag to prevent DNS rebinding attacks" 2025-12-19T08:10:47.444054-08:00 INFO "Server ready to serve!" ``` -------------------------------- ### Minimal npm Installation (PostgreSQL and MySQL) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Install DBHub globally with only PostgreSQL and MySQL drivers. Requires installing 'pg' and 'mysql2' packages separately. ```bash npm install -g @bytebase/dbhub@latest --omit=optional && npm install -g pg mysql2 ``` -------------------------------- ### Run DBHub with npx (PostgreSQL) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Use npx to run DBHub directly without global installation. This example connects to a PostgreSQL database. ```bash npx @bytebase/dbhub@latest \ --transport http \ --port 8080 \ --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable" ``` -------------------------------- ### MySQL DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for connecting to a MySQL database. ```sql mysql://user:password@localhost:3306/dbname?sslmode=disable ``` -------------------------------- ### SQL Server DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for connecting to a SQL Server database. ```sql sqlserver://user:password@localhost:1433/dbname?sslmode=disable ``` -------------------------------- ### Start DBHub in Demo Mode Source: https://github.com/bytebase/dbhub/blob/main/docs/workbench/overview.mdx Use demo mode to explore the Workbench without setting up a database. This command starts DBHub with HTTP transport on port 8080. ```bash npx @bytebase/dbhub --transport http --port 8080 --demo ``` -------------------------------- ### Build and Run for Production Source: https://github.com/bytebase/dbhub/blob/main/README.md Builds the DBHub application for production and starts it using stdio transport with a PostgreSQL DSN. ```bash pnpm build && pnpm start --transport stdio --dsn "postgres://user:password@localhost:5432/dbname" ``` -------------------------------- ### MariaDB DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for connecting to a MariaDB database. ```sql mariadb://user:password@localhost:3306/dbname?sslmode=disable ``` -------------------------------- ### AI Prompt: List Available Schemas Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx An example prompt to ask an AI tool to list all available schemas in the connected database. ```text What schemas are available in the database? ``` -------------------------------- ### SQL Server Named Instance DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for connecting to a SQL Server named instance. ```sql sqlserver://user:password@localhost:1433/dbname?instanceName=ENV1 ``` -------------------------------- ### Download and Install MCP Toolbox Binary Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-mcp-toolbox.mdx Download the MCP Toolbox binary for your system and make it executable. Ensure you set the VERSION environment variable to the desired release. ```bash export VERSION=0.24.0 curl -L -o toolbox https://storage.googleapis.com/genai-toolbox/v$VERSION/darwin/arm64/toolbox chmod +x toolbox ``` -------------------------------- ### Install DBHub in Cursor (One-Click) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Use this deeplink to install DBHub in Cursor IDE with a single click. After installation, you may need to adjust the DSN in your Cursor MCP settings. ```html Install DBHub MCP server in Cursor ``` -------------------------------- ### SQL Server Connection Strings Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Examples of SQL Server Data Source Names (DSN), including basic, named instance, Windows authentication, and Azure AD authentication. ```bash # Format: sqlserver://[user]:[password]@[host]:[port]/[database]?[options] sqlserver://sa:YourPassword123@localhost:1433/mydb # Named instance (e.g., ENV1, ENV2, ENV3) sqlserver://sa:YourPassword123@localhost:1433/mydb?instanceName=ENV1 # Windows/NTLM authentication sqlserver://jsmith:secret@localhost:1433/mydb?authentication=ntlm&domain=CORP # Azure AD authentication (password optional/empty) sqlserver://username@localhost:1433/mydb?authentication=azure-active-directory-access-token ``` -------------------------------- ### PostgreSQL Connection String Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Example of a PostgreSQL Data Source Name (DSN). Ensure the format matches the specified pattern. ```bash # Format: postgres://[user]:[password]@[host]:[port]/[database]?[options] postgres://myuser:mypassword@localhost:5432/mydb ``` -------------------------------- ### SQLite File DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for connecting to a SQLite database file. ```sql sqlite:///path/to/database.db ``` -------------------------------- ### Get Product Tool for SQL Server Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/custom-tools.mdx Define a tool to retrieve a product by ID using SQL Server's '@p1' parameter placeholder syntax. ```toml [[tools]] name = "get_product" description = "Get product by ID" source = "sqlserver_db" statement = "SELECT * FROM products WHERE id = @p1" [[tools.parameters]] name = "product_id" type = "integer" description = "Product ID" ``` -------------------------------- ### SQLite In-Memory DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for connecting to an in-memory SQLite database. ```sql sqlite:///:memory: ``` -------------------------------- ### MariaDB Connection String Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Example of a MariaDB Data Source Name (DSN). Use the specified format for MariaDB connections. ```bash # Format: mariadb://[user]:[password]@[host]:[port]/[database]?[options] mariadb://root:password@localhost:3306/mydb ``` -------------------------------- ### AI Prompt: Show Tables in a Schema Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx An example prompt to ask an AI tool to list all tables within a specific schema, such as 'public'. ```text What tables are in the public schema? ``` -------------------------------- ### MySQL Connection String Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Example of a MySQL Data Source Name (DSN). Follow the standard connection string format. ```bash # Format: mysql://[user]:[password]@[host]:[port]/[database]?[options] mysql://root:password@localhost:3306/mydb ``` -------------------------------- ### Configure DBHub for Project-Specific Connections Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Set up project-specific database connections by creating a `.cursor/mcp.json` file in your project root. This example uses stdio transport and a local `dbhub.toml` configuration file. ```json { "mcpServers": { "project-db": { "command": "npx", "args": [ "@bytebase/dbhub@latest", "--transport", "stdio", "--config", "${workspaceFolder}/dbhub.toml" ] } } } ``` -------------------------------- ### Configure MCP Toolbox Sources and Tools Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-mcp-toolbox.mdx Define database connections and custom SQL tools in a YAML configuration file. This example shows a local PostgreSQL connection and a tool to list department managers. ```yaml sources: local-pg: kind: postgres host: 127.0.0.1 port: 5432 database: employee user: postgres password: testpwd1 tools: current_managers: kind: postgres-sql source: local-pg description: List all current department managers statement: | SELECT e.emp_no, e.first_name, e.last_name, d.dept_name, dm.from_date FROM dept_manager dm JOIN employee e ON dm.emp_no = e.emp_no JOIN department d ON dm.dept_no = d.dept_no ORDER BY d.dept_name ``` -------------------------------- ### Run DBHub in Demo Mode on Loopback Source: https://github.com/bytebase/dbhub/blob/main/README.md Starts DBHub in demo mode using NPM, binding it to the loopback interface (127.0.0.1) on port 8080 for enhanced security. ```bash npx @bytebase/dbhub@latest --transport http --host 127.0.0.1 --port 8080 --demo ``` -------------------------------- ### SQL Server NTLM Authentication DSN Example Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Example of a DSN string for SQL Server using NTLM authentication. ```sql sqlserver://user:password@localhost:1433/dbname?authentication=ntlm&domain=MYDOMAIN ``` -------------------------------- ### Get Product Tool for PostgreSQL Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/custom-tools.mdx Define a tool to retrieve a product by ID using PostgreSQL's '$1' parameter placeholder syntax. ```toml [[tools]] name = "get_product" description = "Get product by ID" source = "postgres_db" statement = "SELECT * FROM products WHERE id = $1" [[tools.parameters]] name = "product_id" type = "integer" description = "Product ID" ``` -------------------------------- ### Start DBHub Server with HTTP Transport (CLI) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx This command starts a DBHub server with HTTP transport, typically used in conjunction with the `claude mcp add --transport http` command. ```bash npx @bytebase/dbhub@latest --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname" ``` -------------------------------- ### Run DBHub with Docker Source: https://github.com/bytebase/dbhub/blob/main/README.md Starts a DBHub instance using Docker, exposing it on port 8080 and connecting to a PostgreSQL database. ```bash docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub \ --transport http \ --port 8080 \ --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable" ``` -------------------------------- ### Configure Specific PostgreSQL Execute SQL Tool Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-mcp-toolbox.mdx Specify individual tools using a configuration file to reduce token consumption. This example configures the 'postgres-execute-sql' tool. ```yaml tools: execute_sql_tool: kind: postgres-execute-sql source: local-pg description: Use this tool to execute sql statement. ``` -------------------------------- ### Run DBHub in Demo Mode Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-dbhub.mdx Start DBHub in demo mode using npm. This option includes a bundled SQLite database for exploring the MCP integration without connecting to an existing database. ```bash npx @bytebase/dbhub@latest --demo ``` -------------------------------- ### Start DBHub with HTTP Transport Source: https://github.com/bytebase/dbhub/blob/main/docs/config/debug.mdx Use this command to start DBHub with HTTP transport enabled, specifying the port and DSN for your database connection. This is required for the MCP Inspector to connect. ```bash npx @bytebase/dbhub@latest --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/mydb" ``` -------------------------------- ### DBHub Demo Mode Output Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx This is the expected output when DBHub starts successfully in demo mode, indicating the server address and version. ```bash Running in DEMO mode - using sample employee database _____ ____ _ _ _ | __ \| _ \| | | | | | | | | | |_) | |_| |_ _| |__ | | | | _ <| _ | | | | '_ \ | |__| | |_) | | | | |_| | |_) | |_____/|____/|_| |_|\__,_|_.__/ v0.11.10 [DEMO] - Minimal Database MCP Server Workbench at http://localhost:8080/ MCP server endpoint at http://localhost:8080/mcp ``` -------------------------------- ### Get Product Tool for MySQL/MariaDB/SQLite Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/custom-tools.mdx Define a tool to retrieve a product by ID using MySQL/MariaDB/SQLite's '?' parameter placeholder syntax. ```toml [[tools]] name = "get_product" description = "Get product by ID" source = "mysql_db" statement = "SELECT * FROM products WHERE id = ?" [[tools.parameters]] name = "product_id" type = "integer" description = "Product ID" ``` -------------------------------- ### SQLite Connection Strings Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Examples of SQLite Data Source Names (DSN) for file-based and in-memory databases on different operating systems. ```bash # Format: sqlite:///[path/to/database.db] or sqlite:///:memory: # Unix/Linux/macOS sqlite:///var/lib/data/mydb.db # Windows sqlite:///C:/Users/YourName/data/database.db # In-memory sqlite:///:memory: ``` -------------------------------- ### Run in Development Mode Source: https://github.com/bytebase/dbhub/blob/main/README.md Starts the DBHub application in development mode for active coding and testing. ```bash pnpm dev ``` -------------------------------- ### AI Prompt: Query Employee Data Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx An example prompt to retrieve the top 5 employees by salary from the database. ```text Show me the top 5 employees by salary ``` -------------------------------- ### Run DBHub with NPM Source: https://github.com/bytebase/dbhub/blob/main/README.md Installs and runs DBHub using NPM, configuring it to use HTTP transport on port 8080 and connect to a PostgreSQL database. ```bash npx @bytebase/dbhub@latest --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable" ``` -------------------------------- ### Select Specific Supabase Feature Groups Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-supabase-mcp.mdx Configure the MCP server to load only specific feature groups, such as 'database' and 'docs', for reduced token usage. This example uses a URL parameter to specify features. ```bash https://mcp.supabase.com/mcp?features=database,docs ``` -------------------------------- ### Configure DBHub to Expose Only execute_sql Tool Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-dbhub.mdx Example TOML configuration to minimize DBHub's tool load by exposing only the `execute_sql` tool. This reduces token usage significantly. ```toml [[sources]] id = "prod" dsn = "postgres://..." [[tools]] name = "execute_sql" source = "prod" ``` -------------------------------- ### Start DBHub with HTTP Transport Source: https://github.com/bytebase/dbhub/blob/main/docs/workbench/overview.mdx Run DBHub with HTTP transport to access the Workbench. Specify the port and your database connection string (DSN). ```bash npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://..." ``` -------------------------------- ### AI Prompt: Change Data Source: https://github.com/bytebase/dbhub/blob/main/docs/quickstart.mdx An example prompt to instruct an AI tool to update an employee's salary. This requires the `execute_sql` tool to be configured for write operations. ```text Update the salary of employee 10001 to 100000 ``` -------------------------------- ### List of Prebuilt PostgreSQL Tools Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-mcp-toolbox.mdx This displays the available tools when using the prebuilt PostgreSQL toolset. Note the significant token cost associated with loading all tools. ```bash │ Tools for mcp-toolbox (28 tools) \ │ \ │ ❯ 1. list_memory_configurations \ │ 2. list_autovacuum_configurations \ │ 3. database_overview \ │ 4. get_query_plan \ │ ↓ 5. list_triggers ``` -------------------------------- ### Preview Documentation Locally Source: https://github.com/bytebase/dbhub/blob/main/docs/README.md Navigate to the docs directory and run the mint dev command to preview documentation locally. Ensure you are at the root of your documentation where docs.json is located. ```bash cd docs mint dev ``` -------------------------------- ### Testing DBHub with Demo Mode Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Run DBHub with a bundled SQLite sample database for testing purposes using the `--demo` flag. This is useful for quick evaluations without setting up actual databases. ```bash npx @bytebase/dbhub@latest --demo --transport http --port 8080 ``` -------------------------------- ### Configure and Run Bytebase CLI Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Set database connection environment variables and run the Bytebase CLI. This is useful for automating database tasks or integrating with CI/CD pipelines. ```bash export DB_TYPE=postgres export DB_HOST=localhost export DB_PORT=5432 export DB_USER=myuser export DB_PASSWORD='p@ss:word#123' export DB_NAME=mydb npx @bytebase/dbhub@latest ``` -------------------------------- ### Export PostgreSQL Environment Variables and Launch Toolbox Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-mcp-toolbox.mdx Set environment variables for PostgreSQL connection details and then launch the toolbox with the --prebuilt postgres flag to use the prebuilt PostgreSQL toolset. ```bash export POSTGRES_HOST=127.0.0.1 export POSTGRES_PORT=5432 export POSTGRES_DATABASE=employee export POSTGRES_USER=postgres export POSTGRES_PASSWORD=testpwd1 ./toolbox --prebuilt postgres ``` -------------------------------- ### Start MCP Inspector Source: https://github.com/bytebase/dbhub/blob/main/docs/config/debug.mdx Launch the MCP Inspector in a separate terminal after starting DBHub. This web-based tool allows you to test and inspect DBHub server functionality. ```bash npx @modelcontextprotocol/inspector ``` -------------------------------- ### Basic SSL Configuration Source: https://github.com/bytebase/dbhub/blob/main/docs/config/toml.mdx Configure basic SSL/TLS encryption for database connections. Use 'require' for encrypted but unverified connections. ```toml [[sources]] id = "production" dsn = "postgres://user:pass@localhost:5432/mydb" sslmode = "require" ``` -------------------------------- ### Discover Schemas with search_objects Source: https://github.com/bytebase/dbhub/blob/main/skills/dbhub/SKILL.md Use search_objects with object_type='schema' and detail_level='names' to get a list of available schemas in the database. ```python search_objects(object_type="schema", detail_level="names") ``` -------------------------------- ### Error Response Format Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/custom-tools.mdx Example of an error response from a custom tool execution, indicating failure and providing an error message and code. ```json { "success": false, "error": "Parameter validation failed: user_id: Required", "code": "EXECUTION_ERROR" } ``` -------------------------------- ### Context Usage with Prebuilt PostgreSQL Tools Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-mcp-toolbox.mdx Visual representation of context token usage when employing the prebuilt PostgreSQL toolset, highlighting the high token cost for MCP tools. ```text > /context ⎿   Context Usage ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ claude-sonnet-4-5-20250929 · 86k/200k tokens (43%) ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 2.7k tokens (1.3%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 15.9k tokens (7.9%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: 19.0k tokens (9.5%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Custom agents: 247 tokens (0.1%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Memory files: 2.4k tokens (1.2%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛁ Messages: 1.2k tokens (0.6%) ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛶ Free space: 114k (56.8%) ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ Autocompact buffer: 45.0k tokens (22.5%) ``` -------------------------------- ### Individual Parameters for SQL Server Source: https://github.com/bytebase/dbhub/blob/main/docs/config/toml.mdx Configure SQL Server connections with options for named instances, NTLM authentication, and Azure AD. ```toml # SQL Server with named instance [[sources]] id = "sqlserver_dev" type = "sqlserver" host = "localhost" port = 1433 database = "mydb" user = "sa" password = "YourPassword123" instanceName = "SQLEXPRESS" # SQL Server with NTLM [[sources]] id = "corp_sqlserver" type = "sqlserver" host = "sqlserver.corp.local" database = "app_db" user = "jsmith" password = "secret" authentication = "ntlm" domain = "CORP" # SQL Server with Azure AD (no password) [[sources]] id = "azure_sqlserver" type = "sqlserver" host = "myserver.database.windows.net" database = "mydb" user = "admin@tenant.onmicrosoft.com" authentication = "azure-active-directory-access-token" ``` -------------------------------- ### Success Response Format Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/custom-tools.mdx Example of a successful response from a custom tool execution, including status, returned rows, count, and source identifier. ```json { "success": true, "rows": [ { "id": 12345, "name": "Alice Johnson", "email": "alice@example.com", "created_at": "2024-01-15T10:30:00Z" } ], "count": 1, "source_id": "prod_pg" } ``` -------------------------------- ### Project Configuration for DBHub (Stdio) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Configure DBHub with stdio transport for project-specific database connections shared with your team by creating a `.mcp.json` file. ```json { "mcpServers": { "dbhub": { "type": "stdio", "command": "npx", "args": [ "@bytebase/dbhub@latest", "--transport", "stdio", "--dsn", "postgres://user:password@localhost:5432/dbname" ] } } } ``` -------------------------------- ### Context Usage with All Tools Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-supabase-mcp.mdx Illustrates the token cost and context breakdown when all 29 Supabase tools are loaded. This configuration uses 19.3k tokens. ```bash > /context ⎿   Context Usage ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ claude-sonnet-4-5-20250929 · 87k/200k tokens (43%) ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛀ ⛁ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 2.6k tokens (1.3%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 15.9k tokens (7.9%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: 19.3k tokens (9.6%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Custom agents: 247 tokens (0.1%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Memory files: 2.4k tokens (1.2%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛁ Messages: 1.3k tokens (0.6%) ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛶ Free space: 113k (56.6%) ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ Autocompact buffer: 45.0k tokens (22.5%) ``` -------------------------------- ### Claude Desktop Configuration for DBHub Demo Mode Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Enable demo mode for DBHub in Claude Desktop for testing purposes, using the built-in demo database. ```json { "mcpServers": { "dbhub": { "command": "npx", "args": [ "@bytebase/dbhub@latest", "--transport", "stdio", "--demo" ] } } } ``` -------------------------------- ### DBHub Docker Compose Configuration Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Example docker-compose.yml configuration to integrate DBHub into a development environment. It includes service definitions for DBHub and a PostgreSQL database. ```yaml services: dbhub: image: bytebase/dbhub:latest container_name: dbhub ports: - "8080:8080" environment: - DBHUB_LOG_LEVEL=info command: - --transport - http - --port - "8080" - --dsn - "postgres://user:password@database:5432/dbname" depends_on: - database database: image: postgres:15-alpine environment: POSTGRES_PASSWORD: password POSTGRES_DB: dbname ``` -------------------------------- ### Search Database Objects with DBHub Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/state-of-postgres-mcp-servers-2025.mdx This is an example of using DBHub to search for database objects in a PostgreSQL database. It specifies the object type and pattern for the search. ```json dbhub - Search Database Objects (postgres) (MCP)(object_type: "table", pattern: "%", detail_level: "summary") ``` -------------------------------- ### DBHub stdio Transport Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Use the stdio transport for desktop tools like Claude Desktop, Claude Code, and Cursor. This configuration does not start an HTTP server. ```bash npx @bytebase/dbhub@latest --transport stdio --dsn "..." ``` -------------------------------- ### Project Configuration for DBHub with Environment Variables (Stdio) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Use environment variable expansion for sensitive values like database URLs in your project's `.mcp.json` configuration. ```json { "mcpServers": { "dbhub": { "type": "stdio", "command": "npx", "args": [ "@bytebase/dbhub@latest", "--transport", "stdio", "--dsn", "${DATABASE_URL}" ] } } } ``` -------------------------------- ### Enable Default Tools Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/overview.mdx If no [[tools]] entries are defined for a source, both execute_sql and search_objects are enabled by default. ```toml [[sources]] id = "dev" dsn = "sqlite:///dev.db" # No [[tools]] entries = both execute_sql and search_objects enabled ``` -------------------------------- ### Configuring DBHub with a TOML File Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Use the `--config` flag to specify a TOML configuration file for managing multiple database connections and advanced settings. The tool automatically loads `./dbhub.toml` if it exists. ```bash npx @bytebase/dbhub@latest --config ./dbhub.toml --transport http --port 8080 ``` -------------------------------- ### Run DBHub with Docker (PostgreSQL) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Run DBHub using the official Docker image, connecting to a PostgreSQL database. Includes options for demo mode. ```bash docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub \ --transport http \ --port 8080 \ --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable" # Or use demo mode for testing docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub \ --transport http \ --port 8080 \ --demo ``` -------------------------------- ### DBHub http Transport with Custom Port Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Use the http transport for web clients, workbench, and remote access. This configuration starts an HTTP server on a specified port. ```bash npx @bytebase/dbhub@latest --transport http --port 8080 --dsn "..." ``` -------------------------------- ### Load All Supabase Tools Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-supabase-mcp.mdx This configuration loads all 29 available tools across all feature groups for Supabase projects. It provides comprehensive access but may result in higher token usage. ```bash │ Tools for supabase (29 tools) │ │ │ │ ❯ 1. Search docs read-only │ │ 2. List organizations read-only │ │ 3. Get organization details read-only │ │ 4. List projects read-only │ │ ↓ 5. Get project details read-only ``` -------------------------------- ### Prefill SQL Editor with URL Parameter Source: https://github.com/bytebase/dbhub/blob/main/docs/workbench/tool-execution.mdx Use the 'sql' URL parameter to prefill the SQL editor for bookmarking and sharing. ```url ?sql=SELECT%20*%20FROM%20users%20LIMIT%2010 ``` -------------------------------- ### Context Usage with Selected Feature Groups Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-supabase-mcp.mdx Demonstrates the reduced token usage (4.2k tokens) when only specific feature groups like 'database' and 'docs' are loaded. This is a 4.6x reduction compared to loading all tools. ```bash > /context ⎿   Context Usage ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ claude-sonnet-4-5-20250929 · 72k/200k tokens (36%) ⛁ ⛀ ⛁ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 2.7k tokens (1.3%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 15.9k tokens (7.9%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: 4.2k tokens (2.1%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Custom agents: 247 tokens (0.1%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Memory files: 2.4k tokens (1.2%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛁ Messages: 1.3k tokens (0.6%) ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛶ Free space: 128k (64.1%) ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ Autocompact buffer: 45.0k tokens (22.5%) MCP tools · /mcp └ mcp__supabase__search_docs (supabase): 1.1k tokens └ mcp__supabase__list_tables (supabase): 640 tokens └ mcp__supabase__list_extensions (supabase): 596 tokens └ mcp__supabase__list_migrations (supabase): 596 tokens └ mcp__supabase__apply_migration (supabase): 668 tokens └ mcp__supabase__execute_sql (supabase): 657 tokens ``` -------------------------------- ### Define Date Range Query Tool Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/custom-tools.mdx Configure a custom tool to retrieve records within a specified date range. Requires start and end dates in ISO 8601 format. ```toml [[tools]] name = "get_orders_by_date_range" description = "Retrieve orders within a date range" source = "production" statement = "SELECT * FROM orders WHERE created_at BETWEEN $1 AND $2 ORDER BY created_at DESC" [[tools.parameters]] name = "start_date" type = "string" description = "Start date (ISO 8601 format: YYYY-MM-DD)" [[tools.parameters]] name = "end_date" type = "string" description = "End date (ISO 8601 format: YYYY-MM-DD)" ``` -------------------------------- ### Configure DBHub for Remote HTTP Transport (MacOS/Linux) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Configure DBHub for remote or shared database servers on MacOS or Linux by editing the `~/.cursor/mcp.json` file. This setup uses the HTTP transport method. ```json { "mcpServers": { "dbhub": { "url": "http://localhost:8080/mcp" } } } ``` -------------------------------- ### SSH Tunneling using SSH Config Alias Source: https://github.com/bytebase/dbhub/blob/main/docs/config/command-line.mdx Utilize an SSH configuration alias defined in `~/.ssh/config` for simplified tunnel setup. DBHub will resolve host, user, key, and ProxyJump from the alias. ```bash npx @bytebase/dbhub@latest --dsn "..." --ssh-host mybastion ``` -------------------------------- ### Build DBHub Project Source: https://github.com/bytebase/dbhub/blob/main/CLAUDE.md Use this command to compile TypeScript to JavaScript for building the project. ```bash pnpm run build ``` -------------------------------- ### Enable Debug Logging for DBHub Source: https://github.com/bytebase/dbhub/blob/main/docs/config/debug.mdx Start DBHub with the `--log-level debug` flag to enable verbose logging. This is useful for troubleshooting connection and database query errors by providing more detailed error messages. ```bash npx @bytebase/dbhub@latest --transport http --port 8080 --dsn "your-dsn" --log-level debug ``` -------------------------------- ### Define Basic User Query Tool Source: https://github.com/bytebase/dbhub/blob/main/docs/tools/custom-tools.mdx Configure a simple SELECT query tool with a single integer parameter for retrieving user details. ```toml [[tools]] name = "get_user_by_id" description = "Retrieve user details by their unique ID" source = "production" statement = "SELECT id, name, email, created_at FROM users WHERE id = $1" [[tools.parameters]] name = "user_id" type = "integer" description = "The unique user ID" ``` -------------------------------- ### VS Code MCP Configuration (Config File) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Configure VS Code's MCP to use a separate configuration file for multi-database setups. This snippet points to a 'dbhub.toml' file for connection details. ```json { "servers": { "dbhub": { "type": "stdio", "command": "npx", "args": [ "@bytebase/dbhub@latest", "--transport", "stdio", "--config", "${workspaceFolder}/dbhub.toml" ] } } } ``` -------------------------------- ### Add DBHub for User Configuration (CLI) Source: https://github.com/bytebase/dbhub/blob/main/docs/installation.mdx Add DBHub to your user configuration using the CLI for personal use across all projects. ```bash claude mcp add --scope user dbhub -- npx @bytebase/dbhub@latest --transport stdio --dsn "postgres://user:password@localhost:5432/dbname" ``` -------------------------------- ### Supabase MCP Server Tool Mapping to Supabase API Source: https://github.com/bytebase/dbhub/blob/main/docs/blog/postgres-mcp-server-review-supabase-mcp.mdx Supabase MCP Server tools act as wrappers around the Supabase Management API. For example, `execute_sql` maps to the `query` endpoint, and `apply_migration` maps to the `migration` endpoint. ```plaintext - [execute_sql](https://github.com/supabase-community/supabase-mcp/blob/c5b2b044/packages/mcp-server-supabase/src/platform/api-platform.ts#L179) calls the [query](https://supabase.com/docs/reference/api/v1-run-a-query) endpoint - [apply_migration](https://github.com/supabase-community/supabase-mcp/blob/c5b2b044/packages/mcp-server-supabase/src/platform/api-platform.ts#L218) calls the [migration](https://supabase.com/docs/reference/api/v1-upsert-a-migration) endpoint. ``` -------------------------------- ### Execute SQL Tool Configuration Source: https://github.com/bytebase/dbhub/blob/main/docs/config/toml.mdx Define the 'execute_sql' tool, specifying the data source it should use. ```toml [[tools]] name = "execute_sql" source = "production" ```