connect_database
Establish a connection to a specified ClickHouse database for secure interactions and query execution, facilitating data access and management through the MCP server.
Instructions
Connect to a specific ClickHouse database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes |
Input Schema (JSON Schema)
{
"properties": {
"database": {
"title": "Database",
"type": "string"
}
},
"required": [
"database"
],
"title": "connect_databaseArguments",
"type": "object"
}
Implementation Reference
- The connect_database tool handler: switches to the specified database by executing a USE query via the QueryExecutor, returns JSON-formatted result or error message.@mcp.tool() def connect_database(database: str, ctx: Context) -> str: """Connect to a specific ClickHouse database""" try: executor = _get_executor(ctx) result = executor.execute_single_query(f"USE {database}") return json.dumps(result, indent=2) except (ConnectionError, QueryError) as e: return str(e)