Overview
All command-line parameters can be configured via environment variables. This is particularly useful for:- Storing sensitive credentials (tokens, API keys) outside of configuration files
- Container deployments (Docker, Kubernetes)
- CI/CD pipelines
- Client configurations that support environment variable injection
Command-line parameters take precedence over environment variables when both are specified.
Authentication Variables
These environment variables handle authentication credentials for MotherDuck and cloud storage.MotherDuck Authentication
MotherDuck access token for authentication.Alternative names: In client configuration:
MOTHERDUCK_TOKEN (uppercase version)Command-line equivalent: --motherduck-tokenUsage:For read-only connections, use a read-scaling token. Regular tokens require
--read-write mode.Alternative uppercase version of
motherduck_token.Functionally identical to motherduck_token. The server checks for both variables.Usage:AWS Credentials (for S3 Access)
Required when connecting to DuckDB files hosted on Amazon S3.AWS access key ID for S3 authentication.Usage:
AWS secret access key for S3 authentication.Used in conjunction with
AWS_ACCESS_KEY_ID.AWS session token for temporary credentials.Required when using:
- IAM roles
- AWS SSO
- EC2 instance profiles
- Temporary security credentials
AWS region for S3 connections.Specifies which AWS region to use when accessing S3-hosted databases.Common values:
us-east-1, us-west-2, eu-west-1, ap-southeast-1MCP Configuration Variables
These environment variables correspond to command-line parameters and control server behavior.Connection Configuration
Database path (local file, MotherDuck, or S3 URL).Command-line equivalent:
--db-pathExamples:Additional MotherDuck connection string parameters.Command-line equivalent:
--motherduck-connection-parametersUsage:Security Configuration
Enable write access to the database.Command-line equivalent:
--read-writeValues: true, false, 1, 0Usage:Enable MotherDuck SaaS mode (restricts local filesystem access).Command-line equivalent:
--motherduck-saas-modeValues: true, false, 1, 0Usage:Enable the
switch_database_connection tool.Command-line equivalent: --allow-switch-databasesValues: true, false, 1, 0Usage:SQL file path or SQL string to execute on startup.Command-line equivalent:
--init-sqlUsage:Performance Configuration
Maximum number of rows to return from queries.Command-line equivalent:
--max-rowsUsage:Maximum number of characters in query results.Command-line equivalent:
--max-charsUsage:Query execution timeout in seconds (-1 to disable).Command-line equivalent:
--query-timeoutUsage:Use temporary connections for read-only local DuckDB files.Command-line equivalent:
--ephemeral-connections / --no-ephemeral-connectionsValues: true, false, 1, 0Usage:Transport Configuration
Transport type for the MCP server.Command-line equivalent:
--transportValues: stdio, http, sse, streamUsage:Use stateless Streamable HTTP.Command-line equivalent:
--stateless-httpValues: true, false, 1, 0Usage:Host to bind the MCP server (HTTP transport only).Command-line equivalent:
--hostUsage:Port to listen on (HTTP transport only).Command-line equivalent:
--portUsage:System Configuration
Home directory used by DuckDB for extensions and configuration.Can be overridden with
--home-dir command-line parameter.Usage:Complete Configuration Examples
Example 1: MotherDuck Read-Write via Environment Variables
Example 2: S3-Hosted Database with AWS Credentials
Example 3: Docker Container Configuration
Example 4: Client Configuration with Environment Variables
Claude Desktop / VS Code (config.json):
Example 5: Kubernetes Deployment with Secrets
Environment Variable Priority
When the same configuration is specified in multiple places, the following priority order applies (highest to lowest):- Command-line parameters (e.g.,
--db-path md:) - Environment variables (e.g.,
MCP_DB_PATH=md:) - Default values (e.g.,
:memory:for--db-path)
Security Best Practices
Recommendations
-
Use environment variables for secrets: Store
motherduck_tokenand AWS credentials in environment variables, not in configuration files. -
Use secret management tools:
- AWS Secrets Manager / Parameter Store
- HashiCorp Vault
- Kubernetes Secrets
- Docker Secrets
-
Restrict file permissions: If storing credentials in files, set restrictive permissions:
- Use read-scaling tokens: For read-only MotherDuck access, use read-scaling tokens instead of full access tokens.
- Separate environments: Use different tokens/credentials for development, staging, and production.
.env file (not committed to git):