Skip to content

Commit 0b8a75d

Browse files
author
Jove Zhong
authored
Make it working with Timeplus Proton/Enterprise (#1)
* Update pyproject.toml * rename folder * update python code * Update README and uv
1 parent 8327718 commit 0b8a75d

File tree

8 files changed

+106
-105
lines changed

8 files changed

+106
-105
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ name: CI
33
on:
44
push:
55
branches:
6-
- main
6+
- timeplus
77
pull_request:
88

99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212

1313
services:
14-
clickhouse:
15-
image: clickhouse/clickhouse-server:24.10
14+
timeplus:
15+
image: d.timeplus.com/timeplus-io/proton:latest
1616
ports:
17-
- 9000:9000
1817
- 8123:8123
1918

2019
steps:
@@ -32,10 +31,10 @@ jobs:
3231

3332
- name: Run tests
3433
env:
35-
CLICKHOUSE_HOST: "localhost"
36-
CLICKHOUSE_PORT: "8123"
37-
CLICKHOUSE_USER: "default"
38-
CLICKHOUSE_PASSWORD: ""
34+
TIMEPLUS_HOST: "localhost"
35+
TIMEPLUS_PORT: "8123"
36+
TIMEPLUS_USER: "default"
37+
TIMEPLUS_PASSWORD: ""
3938
run: |
4039
uv run pytest tests
4140

README.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1-
# ClickHouse MCP Server
2-
[![PyPI - Version](https://img.shields.io/pypi/v/mcp-clickhouse)](https://pypi.org/project/mcp-clickhouse)
1+
# Timeplus MCP Server
2+
[![PyPI - Version](https://img.shields.io/pypi/v/mcp-timeplus)](https://pypi.org/project/mcp-timeplus)
33

4-
An MCP server for ClickHouse.
4+
An MCP server for Timeplus.
55

6-
<a href="https://glama.ai/mcp/servers/yvjy4csvo1"><img width="380" height="200" src="https://glama.ai/mcp/servers/yvjy4csvo1/badge" alt="mcp-clickhouse MCP server" /></a>
6+
<a href="https://glama.ai/mcp/servers/yvjy4csvo1"><img width="380" height="200" src="https://glama.ai/mcp/servers/yvjy4csvo1/badge" alt="mcp-timeplus MCP server" /></a>
77

88
## Features
99

1010
### Tools
1111

1212
* `run_select_query`
13-
- Execute SQL queries on your ClickHouse cluster.
13+
- Execute SQL queries on your Timeplus cluster.
1414
- Input: `sql` (string): The SQL query to execute.
15-
- All ClickHouse queries are run with `readonly = 1` to ensure they are safe.
15+
- All Timeplus queries are run with `readonly = 1` to ensure they are safe.
1616

1717
* `list_databases`
18-
- List all databases on your ClickHouse cluster.
18+
- List all databases on your Timeplus cluster.
1919

2020
* `list_tables`
2121
- List all tables in a database.
2222
- Input: `database` (string): The name of the database.
2323

2424
## Configuration
2525

26+
First, ensure you have the `uv` executable installed. If not, you can install it by following the instructions [here](https://docs.astral.sh/uv/).
27+
28+
This Python package is not published to PyPI yet. Please clone this repo and run `uv sync` to install the dependencies.
29+
2630
1. Open the Claude Desktop configuration file located at:
2731
- On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
2832
- On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
@@ -32,73 +36,70 @@ An MCP server for ClickHouse.
3236
```json
3337
{
3438
"mcpServers": {
35-
"mcp-clickhouse": {
36-
"command": "uv",
39+
"mcp-timeplus": {
40+
"command": "/path/to/uv",
3741
"args": [
3842
"run",
39-
"--with",
40-
"mcp-clickhouse",
43+
"--project",
44+
"/path/to/repo/mcp-timeplus",
4145
"--python",
4246
"3.13",
43-
"mcp-clickhouse"
47+
"mcp-timeplus"
4448
],
4549
"env": {
46-
"CLICKHOUSE_HOST": "<clickhouse-host>",
47-
"CLICKHOUSE_PORT": "<clickhouse-port>",
48-
"CLICKHOUSE_USER": "<clickhouse-user>",
49-
"CLICKHOUSE_PASSWORD": "<clickhouse-password>"
50+
"TIMEPLUS_HOST": "<timeplus-host>",
51+
"TIMEPLUS_PORT": "<timeplus-port>",
52+
"TIMEPLUS_USER": "<timeplus-user>",
53+
"TIMEPLUS_PASSWORD": "<timeplus-password>"
5054
}
5155
}
5256
}
5357
}
5458
```
5559

56-
Update the environment variables to point to your own ClickHouse service.
60+
Update the environment variables to point to your own Timeplus service.
5761

58-
Or, if you'd like to try it out with the [ClickHouse SQL Playground](https://sql.clickhouse.com/), you can use the following config:
62+
3. Locate the command entry for `uv` and replace it with the absolute path to the `uv` executable. This ensures that the correct version of `uv` is used when starting the server. Also point to the absolute path to the `mcp-timeplus` directory. A sample configuration:
5963

6064
```json
6165
{
6266
"mcpServers": {
63-
"mcp-clickhouse": {
64-
"command": "uv",
67+
"mcp-timeplus": {
68+
"command": "/opt/homebrew/bin/uv",
6569
"args": [
6670
"run",
67-
"--with",
68-
"mcp-clickhouse",
71+
"--project",
72+
"/Users/jove/Dev/mcp-timeplus",
6973
"--python",
7074
"3.13",
71-
"mcp-clickhouse"
75+
"mcp-timeplus"
7276
],
7377
"env": {
74-
"CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com",
75-
"CLICKHOUSE_PORT": "8443",
76-
"CLICKHOUSE_USER": "demo",
77-
"CLICKHOUSE_PASSWORD": ""
78+
"TIMEPLUS_HOST": "localhost",
79+
"TIMEPLUS_PORT": "8123",
80+
"TIMEPLUS_USER": "default",
81+
"TIMEPLUS_PASSWORD": ""
7882
}
7983
}
8084
}
8185
}
8286
```
8387

84-
85-
3. Locate the command entry for `uv` and replace it with the absolute path to the `uv` executable. This ensures that the correct version of `uv` is used when starting the server.
86-
8788
4. Restart Claude Desktop to apply the changes.
8889

8990
## Development
9091

91-
1. In `test-services` directory run `docker compose up -d` to start the ClickHouse cluster.
92+
1. In `test-services` directory run `docker compose up -d` to start a Timeplus Proton server. You can also download it via `curl https://install.timeplus.com/oss | sh`, then start with `./proton server`.
9293

9394
2. Add the following variables to a `.env` file in the root of the repository.
9495

9596
```
96-
CLICKHOUSE_HOST=localhost
97-
CLICKHOUSE_PORT=8123
98-
CLICKHOUSE_USER=default
99-
CLICKHOUSE_PASSWORD=clickhouse
97+
TIMEPLUS_HOST=localhost
98+
TIMEPLUS_PORT=8123
99+
TIMEPLUS_USER=default
100+
TIMEPLUS_PASSWORD=
100101
```
101102

102-
3. Run `uv sync` to install the dependencies. To install `uv` follow the instructions [here](https://docs.astral.sh/uv/). Then do `source .venv/bin/activate`.
103+
3. Run `uv sync` to install the dependencies. Then do `source .venv/bin/activate`.
103104

104-
4. For easy testing, you can run `fastmcp dev mcp_clickhouse/mcp_server.py` to start the MCP server.
105+
4. For easy testing, you can run `fastmcp dev mcp_timeplus/mcp_server.py` to start the MCP server. Click the "Connect" button to connect the UI with the MCP server, then switch to the "Tools" tab to run the available tools: list_databases, list_tables, run_selected_query.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .mcp_server import (
2-
create_clickhouse_client,
2+
create_timeplus_client,
33
list_databases,
44
list_tables,
55
run_select_query,
@@ -9,5 +9,5 @@
99
"list_databases",
1010
"list_tables",
1111
"run_select_query",
12-
"create_clickhouse_client",
12+
"create_timeplus_client",
1313
]
File renamed without changes.

mcp_clickhouse/mcp_server.py renamed to mcp_timeplus/mcp_server.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import os
33
from typing import Sequence
44

5-
import clickhouse_connect
5+
import timeplus_connect
66
from dotenv import load_dotenv
77
from fastmcp import FastMCP
88

9-
MCP_SERVER_NAME = "mcp-clickhouse"
9+
MCP_SERVER_NAME = "mcp-timeplus"
1010

1111
# Configure logging
1212
logging.basicConfig(
@@ -17,7 +17,7 @@
1717
load_dotenv()
1818

1919
deps = [
20-
"clickhouse-connect",
20+
"timeplus-connect",
2121
"python-dotenv",
2222
"uvicorn",
2323
]
@@ -28,7 +28,7 @@
2828
@mcp.tool()
2929
def list_databases():
3030
logger.info("Listing all databases")
31-
client = create_clickhouse_client()
31+
client = create_timeplus_client()
3232
result = client.command("SHOW DATABASES")
3333
logger.info(f"Found {len(result) if isinstance(result, list) else 1} databases")
3434
return result
@@ -37,15 +37,15 @@ def list_databases():
3737
@mcp.tool()
3838
def list_tables(database: str, like: str = None):
3939
logger.info(f"Listing tables in database '{database}'")
40-
client = create_clickhouse_client()
41-
query = f"SHOW TABLES FROM {database}"
40+
client = create_timeplus_client()
41+
query = f"SHOW STREAMS FROM {database}"
4242
if like:
4343
query += f" LIKE '{like}'"
4444
result = client.command(query)
4545

4646
def get_table_info(table):
4747
logger.info(f"Getting schema info for table {database}.{table}")
48-
schema_query = f"DESCRIBE TABLE {database}.`{table}`"
48+
schema_query = f"DESCRIBE STREAM {database}.`{table}`"
4949
schema_result = client.query(schema_query)
5050

5151
columns = []
@@ -56,7 +56,7 @@ def get_table_info(table):
5656
column_dict[col_name] = row[i]
5757
columns.append(column_dict)
5858

59-
create_table_query = f"SHOW CREATE TABLE {database}.`{table}`"
59+
create_table_query = f"SHOW CREATE STREAM {database}.`{table}`"
6060
create_table_result = client.command(create_table_query)
6161

6262
return {
@@ -84,7 +84,7 @@ def get_table_info(table):
8484
@mcp.tool()
8585
def run_select_query(query: str):
8686
logger.info(f"Executing SELECT query: {query}")
87-
client = create_clickhouse_client()
87+
client = create_timeplus_client()
8888
try:
8989
res = client.query(query, settings={"readonly": 1})
9090
column_names = res.column_names
@@ -101,14 +101,14 @@ def run_select_query(query: str):
101101
return f"error running query: {err}"
102102

103103

104-
def create_clickhouse_client():
105-
host = os.getenv("CLICKHOUSE_HOST")
106-
port = os.getenv("CLICKHOUSE_PORT")
107-
username = os.getenv("CLICKHOUSE_USER")
108-
logger.info(f"Creating ClickHouse client connection to {host}:{port} as {username}")
109-
return clickhouse_connect.get_client(
104+
def create_timeplus_client():
105+
host = os.getenv("TIMEPLUS_HOST")
106+
port = os.getenv("TIMEPLUS_PORT")
107+
username = os.getenv("TIMEPLUS_USER")
108+
logger.info(f"Creating Timeplus client connection to {host}:{port} as {username}")
109+
return timeplus_connect.get_client(
110110
host=host,
111111
port=port,
112112
username=username,
113-
password=os.getenv("CLICKHOUSE_PASSWORD"),
113+
password=os.getenv("TIMEPLUS_PASSWORD"),
114114
)

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
2-
name = "mcp-clickhouse"
2+
name = "mcp-timeplus"
33
version = "0.1.0"
4-
description = "An MCP server for ClickHouse."
4+
description = "An MCP server for Timeplus."
55
readme = "README.md"
66
license = "Apache-2.0"
77
license-files = ["LICENSE"]
@@ -11,14 +11,14 @@ dependencies = [
1111
"python-dotenv>=1.0.1",
1212
"fastmcp>=0.4.0",
1313
"uvicorn>=0.34.0",
14-
"clickhouse-connect>=0.8.0",
14+
"timeplus-connect>=0.8.14",
1515
]
1616

1717
[project.scripts]
18-
mcp-clickhouse = "mcp_clickhouse.main:main"
18+
mcp-timeplus = "mcp_timeplus.main:main"
1919

2020
[project.urls]
21-
Home = "https://github.com/iskakaushik/mcp-clickhouse"
21+
Home = "https://github.com/jovezhong/mcp-timeplus"
2222

2323
[project.optional-dependencies]
2424
dev = [
@@ -27,7 +27,7 @@ dev = [
2727
]
2828

2929
[tool.hatch.build.targets.wheel]
30-
packages = ["mcp_clickhouse"]
30+
packages = ["mcp_timeplus"]
3131

3232
[tool.ruff]
3333
line-length = 100

test-services/docker-compose.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
services:
2-
clickhouse:
3-
image: clickhouse/clickhouse-server:latest
2+
timeplus:
3+
image: d.timeplus.com/timeplus-io/proton:latest
44
ports:
55
- "8123:8123"
6-
- "9000:9000"
6+
- "8463:8463"
77
volumes:
8-
- clickhouse-data:/var/lib/clickhouse
8+
- timeplus-data:/var/lib/timeplusd
99
environment:
10-
- CLICKHOUSE_USER=default
11-
- CLICKHOUSE_PASSWORD=clickhouse
12-
- CLICKHOUSE_DB=default
10+
- TIMEPLUS_USER=default
11+
- TIMEPLUS_PASSWORD=
12+
- TIMEPLUS_DB=default
1313

1414
volumes:
15-
clickhouse-data:
15+
timeplus-data:

0 commit comments

Comments
 (0)