@@ -29,6 +29,18 @@ An MCP server for ClickHouse.
2929 * Input: ` sql ` (string): The SQL query to execute.
3030 * Query data directly from various sources (files, URLs, databases) without ETL processes.
3131
32+ ### Health Check Endpoint
33+
34+ When running with HTTP or SSE transport, a health check endpoint is available at ` /health ` . This endpoint:
35+ - Returns ` 200 OK ` with the ClickHouse version if the server is healthy and can connect to ClickHouse
36+ - Returns ` 503 Service Unavailable ` if the server cannot connect to ClickHouse
37+
38+ Example:
39+ ``` bash
40+ curl http://localhost:8000/health
41+ # Response: OK - Connected to ClickHouse 24.3.1
42+ ```
43+
3244## Configuration
3345
3446This MCP server supports both ClickHouse and chDB. You can enable either or both depending on your needs.
@@ -179,6 +191,18 @@ CLICKHOUSE_PASSWORD=clickhouse
179191
1801924 . For easy testing with the MCP Inspector, run ` fastmcp dev mcp_clickhouse/mcp_server.py ` to start the MCP server.
181193
194+ 5 . To test with HTTP transport and the health check endpoint:
195+ ``` bash
196+ # Using default port 8000
197+ CLICKHOUSE_MCP_SERVER_TRANSPORT=http python -m mcp_clickhouse.main
198+
199+ # Or with a custom port
200+ CLICKHOUSE_MCP_SERVER_TRANSPORT=http CLICKHOUSE_MCP_BIND_PORT=4200 python -m mcp_clickhouse.main
201+
202+ # Then in another terminal:
203+ curl http://localhost:8000/health # or http://localhost:4200/health for custom port
204+ ```
205+
182206### Environment Variables
183207
184208The following environment variables are used to configure the ClickHouse and chDB connections:
@@ -216,7 +240,14 @@ The following environment variables are used to configure the ClickHouse and chD
216240 * Set this to automatically connect to a specific database
217241* ` CLICKHOUSE_MCP_SERVER_TRANSPORT ` : Sets the transport method for the MCP server.
218242 * Default: ` "stdio" `
219- * Valid options: ` "stdio" ` , ` "http" ` , ` "streamable-http" ` , ` "sse" ` . This is useful for local development with tools like MCP Inspector.
243+ * Valid options: ` "stdio" ` , ` "http" ` , ` "sse" ` . This is useful for local development with tools like MCP Inspector.
244+ * ` CLICKHOUSE_MCP_BIND_HOST ` : Host to bind the MCP server to when using HTTP or SSE transport
245+ * Default: ` "127.0.0.1" `
246+ * Set to ` "0.0.0.0" ` to bind to all network interfaces (useful for Docker or remote access)
247+ * Only used when transport is ` "http" ` or ` "sse" `
248+ * ` CLICKHOUSE_MCP_BIND_PORT ` : Port to bind the MCP server to when using HTTP or SSE transport
249+ * Default: ` "8000" `
250+ * Only used when transport is ` "http" ` or ` "sse" `
220251* ` CLICKHOUSE_ENABLED ` : Enable/disable ClickHouse functionality
221252 * Default: ` "true" `
222253 * Set to ` "false" ` to disable ClickHouse tools when using chDB only
@@ -227,7 +258,7 @@ The following environment variables are used to configure the ClickHouse and chD
227258 * Default: ` "false" `
228259 * Set to ` "true" ` to enable chDB tools
229260* ` CHDB_DATA_PATH ` : The path to the chDB data directory
230- * Default: ` ":memory:" ` (in-memory database)
261+ * Default: ` ":memory:" ` (in-memory database)
231262 * Use ` :memory: ` for in-memory database
232263 * Use a file path for persistent storage (e.g., ` /path/to/chdb/data ` )
233264
@@ -286,6 +317,21 @@ CLICKHOUSE_ENABLED=false
286317CHDB_DATA_PATH=/path/to/chdb/data
287318```
288319
320+ For MCP Inspector or remote access with HTTP transport:
321+
322+ ``` env
323+ CLICKHOUSE_HOST=localhost
324+ CLICKHOUSE_USER=default
325+ CLICKHOUSE_PASSWORD=clickhouse
326+ CLICKHOUSE_MCP_SERVER_TRANSPORT=http
327+ CLICKHOUSE_MCP_BIND_HOST=0.0.0.0 # Bind to all interfaces
328+ CLICKHOUSE_MCP_BIND_PORT=4200 # Custom port (default: 8000)
329+ ```
330+
331+ When using HTTP transport, the server will run on the configured port (default 8000). For example, with the above configuration:
332+ - MCP endpoint: ` http://localhost:4200/mcp `
333+ - Health check: ` http://localhost:4200/health `
334+
289335You can set these variables in your environment, in a ` .env ` file, or in the Claude Desktop configuration:
290336
291337``` json
@@ -305,13 +351,18 @@ You can set these variables in your environment, in a `.env` file, or in the Cla
305351 "CLICKHOUSE_HOST" : " <clickhouse-host>" ,
306352 "CLICKHOUSE_USER" : " <clickhouse-user>" ,
307353 "CLICKHOUSE_PASSWORD" : " <clickhouse-password>" ,
308- "CLICKHOUSE_DATABASE" : " <optional-database>"
354+ "CLICKHOUSE_DATABASE" : " <optional-database>" ,
355+ "CLICKHOUSE_MCP_SERVER_TRANSPORT" : " stdio" ,
356+ "CLICKHOUSE_MCP_BIND_HOST" : " 127.0.0.1" ,
357+ "CLICKHOUSE_MCP_BIND_PORT" : " 8000"
309358 }
310359 }
311360 }
312361}
313362```
314363
364+ Note: The bind host and port settings are only used when transport is set to "http" or "sse".
365+
315366### Running tests
316367
317368``` bash
0 commit comments