Recommended: MotherDuck Remote MCP
For production deployments with third-party access, we recommend MotherDuck Remote MCP — a fully-managed, zero-setup solution hosted by MotherDuck. Benefits:- Zero-setup required
- Read-write capability
- Hosted and maintained by MotherDuck
- Built-in security controls
- No local filesystem exposure
| Remote MCP | Local MCP (this server) | |
|---|---|---|
| Hosting | Hosted by MotherDuck | Runs locally/self-hosted |
| Setup | Zero-setup | Requires local installation |
| Access | Read-write supported | Read-write supported |
| Local filesystem | - | Query across local and remote databases |
Self-Hosting MotherDuck MCP
If you need to self-host the MCP server for MotherDuck, follow these security best practices:1. Use Service Accounts
Create dedicated service accounts for the MCP server instead of using personal tokens:- Separate credentials from personal accounts
- Granular access control
- Easier credential rotation
- Audit trail for service activity
2. Use Read-Scaling Tokens
For read-only access, use read-scaling tokens instead of regular tokens:Read-scaling tokens provide read-only access and better performance for analytics workloads. They cannot be used with
--read-write mode.3. Enable SaaS Mode
Enable SaaS mode to restrict local file access:- Blocks access to the local filesystem
- Prevents reading or writing local files
- Limits operations to MotherDuck cloud databases only
- Reduces attack surface for third-party access
Complete Secure Configuration
Here’s a fully secured configuration combining all best practices:Self-Hosting DuckDB MCP
When self-hosting the MCP server for local DuckDB databases, use the--init-sql parameter to apply security settings.
Using —init-sql for Security
The--init-sql parameter executes SQL commands on startup to configure security settings:
Security Initialization SQL
Create asecurity-init.sql file with DuckDB security settings:
You can also pass SQL directly as a string:
DuckDB Security Guide
Refer to the official DuckDB Securing Guide for comprehensive security options:- Restricting file system access
- Controlling extension loading
- Setting resource limits
- Configuring network access
- Managing temporary directories
General Security Practices
1. Use Read-Only Mode by Default
Always start with read-only mode unless write access is explicitly required:2. Limit Database Switching
By default, theswitch_database_connection tool is disabled. Only enable it in trusted environments:
3. Set Resource Limits
Limit query resource consumption to prevent abuse:--max-rows: Maximum rows returned (default: 1024)--max-chars: Maximum characters in results (default: 50000)--query-timeout: Query timeout in seconds (default: -1, disabled)
4. Secure Token Storage
Never hardcode tokens in configuration files:- System environment variables
- Secure credential managers (e.g., AWS Secrets Manager)
- Encrypted configuration files
- Password managers
5. Fork and Customize
For advanced security requirements, fork the repository and customize:- Add authentication layers
- Implement custom access controls
- Add audit logging
- Restrict allowed SQL operations
- Add rate limiting
Security Checklist
Use this checklist for production deployments:MotherDuck Deployment
MotherDuck Deployment
- Use service accounts instead of personal tokens
- Use read-scaling tokens for read-only access
- Enable SaaS mode (
--motherduck-saas-mode) - Store tokens in secure credential storage
- Set resource limits (
--max-rows,--query-timeout) - Disable
--allow-switch-databasesunless required - Consider MotherDuck Remote MCP for zero-setup security
Local DuckDB Deployment
Local DuckDB Deployment
- Use read-only mode by default
- Configure security settings with
--init-sql - Set memory and resource limits
- Disable external access and risky extensions
- Review DuckDB security guide
- Set query timeout (
--query-timeout) - Disable
--allow-switch-databases - Restrict file system access paths
Network and Infrastructure
Network and Infrastructure
- Run MCP server in isolated network segment
- Use firewall rules to restrict access
- Enable logging and monitoring
- Implement rate limiting if exposed to network
- Use HTTPS for HTTP transport mode
- Regular security updates and patches
Common Security Pitfalls
❌ Pitfall 1: Assuming Read-Only Mode is Sufficient
- Reading any file accessible to the process
- Changing DuckDB settings
- Loading extensions
- Accessing environment variables
❌ Pitfall 2: Hardcoded Credentials
- Accidentally committed to version control
- Exposed in logs or error messages
- Read by unauthorized users with file access
❌ Pitfall 3: Overly Permissive Database Switching
- System databases
- Other users’ databases
- Sensitive production databases