Configure DataSources
DataSources are the foundation of Data MCP - they define the connections to your data sources. This guide will walk you through configuring various types of data source connections.
Overview
A DataSource in Data MCP contains:
- Connection Information: Host, port, database name, credentials
- Data Source Type: PostgreSQL, MySQL, Databricks, SQLite, APIs, or more
- Security Settings: SSL configuration, connection pooling
- Additional Parameters: Custom connection options
Supported Data Source Types
1. PostgreSQL
- Driver:
postgresql
- Port: 5432 (default)
- Features: Full async support, SSL, connection pooling
2. MySQL/MariaDB
- Driver:
mysql
- Port: 3306 (default)
- Features: Full async support, SSL, connection pooling
3. SQLite
- Driver:
sqlite
- Features: File-based, no network configuration needed
4. Databricks
- Driver:
databricks
- Features: Cloud data warehouse
5. APIs (Coming Soon)
- Driver:
http
- Features: HTTP request capabilities for external services
Creating DataSources
Via Web UI
- Navigate to http://localhost:8000/dmcp/ui (when server is running)
- Click on "DataSources" in the sidebar
- Click "Add New DataSource"
- Fill in the connection details
- Click "Test Connection" to verify
- Click "Save" to create the datasource
Via API
PostgreSQL Example
bash
curl -X POST http://localhost:8000/dmcp/datasources \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "production_postgres",
"database_type": "postgresql",
"host": "localhost",
"port": 5432,
"database": "myapp",
"username": "postgres",
"password": "your_password",
"ssl_mode": "prefer",
"additional_params": {
"pool_size": 10,
"max_overflow": 20
}
}'
MySQL Example
bash
curl -X POST http://localhost:8000/dmcp/datasources \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "analytics_mysql",
"database_type": "mysql",
"host": "analytics.example.com",
"port": 3306,
"database": "analytics",
"username": "analytics_user",
"password": "your_password",
"ssl_mode": "required",
"additional_params": {
"charset": "utf8mb4",
"autocommit": true
}
}'
SQLite Example
bash
curl -X POST http://localhost:8000/dmcp/datasources \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "local_sqlite",
"database_type": "sqlite",
"database": "/path/to/your/database.db",
"additional_params": {
"timeout": 30,
"check_same_thread": false
}
}'
Databricks Example
bash
curl -X POST http://localhost:8000/dmcp/datasources \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "databricks_warehouse",
"database_type": "databricks",
"host": "your-workspace.cloud.databricks.com",
"port": 443,
"database": "default",
"username": "token",
"password": "your_databricks_token",
"additional_params": {
"http_path": "/sql/1.0/warehouses/your-warehouse-id",
"catalog": "hive_metastore",
"schema": "default"
}
}'
Connection Parameters
Common Parameters
Parameter | Type | Required | Description |
---|---|---|---|
name | string | Yes | Unique name for the datasource |
database_type | string | Yes | One of: postgresql , mysql , sqlite , databricks |
host | string | Yes* | Data source host (not required for SQLite) |
port | integer | Yes* | Data source port (not required for SQLite) |
database | string | Yes | Database name or file path |
username | string | Yes* | Data source username (not required for SQLite) |
password | string | Yes* | Data source password (not required for SQLite) |
ssl_mode | string | No | SSL mode for secure connections |
additional_params | object | No | Additional connection parameters |
SSL Modes
For PostgreSQL and MySQL, you can specify SSL modes:
disable
- No SSLallow
- Try SSL, fallback to non-SSLprefer
- Try SSL, fallback to non-SSL (default)require
- Require SSLverify-ca
- Require SSL and verify CAverify-full
- Require SSL and verify CA + hostname
Additional Parameters
PostgreSQL
json
{
"pool_size": 10,
"max_overflow": 20,
"pool_timeout": 30,
"pool_recycle": 3600
}
MySQL
json
{
"charset": "utf8mb4",
"autocommit": true,
"pool_size": 10,
"max_overflow": 20
}
SQLite
json
{
"timeout": 30,
"check_same_thread": false,
"isolation_level": "READ_COMMITTED"
}
Databricks
json
{
"http_path": "/sql/1.0/warehouses/your-warehouse-id",
"catalog": "hive_metastore",
"schema": "default",
"session_configuration": {
"ansi_mode": true
}
}
Testing Connections
Via Web UI
- In the DataSource creation/edit form
- Click "Test Connection" button
- Check the result message
Via API
bash
curl -X POST http://localhost:8000/dmcp/datasources/{id}/test \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Managing DataSources
List All DataSources
bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8000/dmcp/datasources
Get Specific DataSource
bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8000/dmcp/datasources/{id}
Update DataSource
bash
curl -X PUT http://localhost:8000/dmcp/datasources/{id} \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "updated_name",
"host": "new_host",
"port": 5432,
"database": "new_database",
"username": "new_user",
"password": "new_password"
}'
Delete DataSource
bash
curl -X DELETE http://localhost:8000/dmcp/datasources/{id} \
-H "Authorization: Bearer YOUR_TOKEN"
Security Best Practices
1. Credential Management
- Use environment variables for sensitive data
- Rotate passwords regularly
- Use service accounts with minimal privileges
2. Network Security
- Use SSL/TLS for all connections
- Restrict data source access to specific IPs
- Use VPN or private networks when possible
3. Connection Security
- Enable SSL for all production connections
- Use connection pooling to manage resources
- Set appropriate timeouts
4. Databricks Specific
- Use personal access tokens instead of passwords
- Configure workspace access properly
- Use appropriate warehouse sizes
Debugging Tips
Enable Debug Logging
bashLOG_LEVEL=DEBUG
Test with Simple Tools
- Create a simple "SELECT 1" tool
- Test basic connectivity
Check Network Connectivity
bashtelnet your_host your_port
Verify Data Source Permissions
sql-- PostgreSQL GRANT CONNECT ON DATABASE your_db TO your_user; GRANT USAGE ON SCHEMA public TO your_user; GRANT SELECT ON ALL TABLES IN SCHEMA public TO your_user;
Next Steps
Now that you have configured your DataSources, you can:
- Create Tools - Build MCP tools from your data queries and operations
- Connect MCP Clients - Integrate with AI assistants
Ready to create your first tool? Let's move on to the Tool Creation Guide!