connect_database
Establish a pooled connection to a database to enable subsequent operations, returning a connection ID. Choose a named configuration or direct SQLAlchemy URL.
Instructions
Connect to a database.
Establishes a pooled connection to a database. Required before any other database operations. Returns a connection_id for subsequent calls.
Two connection methods:
connection_name: Use a named connection from dbmcp.toml config file
sqlalchemy_url: Connect directly with a SQLAlchemy URL (e.g., 'postgresql://user:pass@host/db')
Provide exactly one of connection_name or sqlalchemy_url.
MSSQL URL query parameters (mssql+pyodbc://...):
authentication_method: sql | windows | azure_ad | azure_ad_integrated (default: sql when credentials are present, else windows)
trust_server_cert: true | false (default: false)
tenant_id: Azure AD tenant (optional)
Example (MSSQL): mssql+pyodbc://user:pass@host/db?authentication_method=sql&trust_server_cert=true
Args: connection_name: Named connection from config file (optional) sqlalchemy_url: SQLAlchemy connection URL (optional)
Returns: TOON-encoded string with connection details:
status: "success" | "error"
connection_id: string // on success only
message: string // on success only
dialect: string // on success only
schema_count: int // on success only
has_cached_docs: bool // on success only
error_message: string // on error only
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sqlalchemy_url | No | ||
| connection_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |