File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -138,5 +138,17 @@ def _validate_required_vars(self) -> None:
138
138
)
139
139
140
140
141
- # Global instance for easy access
142
- config = ClickHouseConfig ()
141
+ # Global instance placeholder for the singleton pattern
142
+ _CONFIG_INSTANCE = None
143
+
144
+
145
+ def get_config ():
146
+ """
147
+ Gets the singleton instance of ClickHouseConfig.
148
+ Instantiates it on the first call.
149
+ """
150
+ global _CONFIG_INSTANCE
151
+ if _CONFIG_INSTANCE is None :
152
+ # Instantiate the config object here, ensuring load_dotenv() has likely run
153
+ _CONFIG_INSTANCE = ClickHouseConfig ()
154
+ return _CONFIG_INSTANCE
Original file line number Diff line number Diff line change 8
8
from dotenv import load_dotenv
9
9
from mcp .server .fastmcp import FastMCP
10
10
11
- from mcp_clickhouse .mcp_env import config
11
+ from mcp_clickhouse .mcp_env import get_config
12
12
13
13
MCP_SERVER_NAME = "mcp-clickhouse"
14
14
@@ -161,7 +161,7 @@ def run_select_query(query: str):
161
161
162
162
163
163
def create_clickhouse_client ():
164
- client_config = config .get_client_config ()
164
+ client_config = get_config () .get_client_config ()
165
165
logger .info (
166
166
f"Creating ClickHouse client connection to { client_config ['host' ]} :{ client_config ['port' ]} "
167
167
f"as { client_config ['username' ]} "
You can’t perform that action at this time.
0 commit comments