Overview
Switch to a different database connection at runtime. The new connection respects the server’s read-only or read-write mode setting. For local file paths, absolute paths are required. This is an “open world” tool that can connect to any accessible database path, making it powerful but potentially risky. Use with caution.Parameters
Database path to switch to. Supported formats:
- Local absolute paths:
/home/user/data/mydb.duckdb(must be absolute, not relative) - In-memory:
:memory:(creates temporary database) - MotherDuck:
md:ormd:database_name(requires MotherDuck token) - S3:
s3://bucket/path/to/database.duckdb(requires AWS credentials)
If
true, create the database file if it doesn’t exist. Only works for local file paths and only when the server is in read-write mode. Has no effect for :memory:, md:, or s3:// paths.Response
Indicates whether the switch was successful.
Confirmation message when successful.
Path of the database connection before the switch.
Path of the new current database connection.
Whether the new connection is in read-only mode. This is determined by the server’s global
--read-only flag, not the tool call.Warning message if applicable (e.g., in-memory databases cannot be read-only).
Error message when success is false.
Type of error that occurred (e.g., “ValueError”, “FileNotFoundError”, “PermissionError”).
Examples
Switch to Local Database File
Request:Switch to In-Memory Database
Request:Switch to MotherDuck Database
Request:Switch to S3 Database
Request:Create New Database File
Request:In-Memory with Read-Only Server
Request:Error - Relative Path Not Allowed
Request:Error - File Not Found
Request:Error - Cannot Create in Read-Only Mode
Request:Supported Path Formats
Local File Paths
Absolute paths only: Local file paths must be absolute (e.g.,
/home/user/data/db.duckdb). Relative paths like ./data.duckdb or data.duckdb are not allowed for security reasons.In-Memory Databases
Temporary data:
:memory: creates a temporary database that exists only for the duration of the connection. Data is lost when the server restarts or switches to another database.Cannot be read-only: Due to DuckDB limitations, in-memory databases cannot be opened in read-only mode, even if the server is started with
--read-only.MotherDuck
Token required: Switching to MotherDuck (
md: or md:database_name) requires a MotherDuck authentication token to be configured via environment variable or server startup.S3 Databases
AWS credentials required: Switching to S3 databases (
s3://) requires valid AWS credentials in environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and optionally AWS_SESSION_TOKEN.Security Implications
Read-Only vs Read-Write Mode
The new database connection respects the server’s global mode:- Read-Only Mode (
--read-only): New connections are read-only (except:memory:) - Read-Write Mode (default): New connections have write access
--read-only flag.
Tool Annotations
This tool has
openWorldHint: true, indicating it can access external resources beyond the initial configuration.Related Tools
- Use list_databases after switching to see available databases
- Use list_tables to discover tables in the new database
- Use execute_query to query the new database