@@ -58,7 +58,6 @@ def get_or_init_db_manager():
5858 return db_manager
5959
6060
61- @mcp .tool ()
6261def show_database_config () -> ToolResult :
6362 """List all configured databases and their settings.
6463 This tool also gives you the full path to the config file
@@ -72,7 +71,6 @@ def show_database_config() -> ToolResult:
7271 )
7372
7473
75- @mcp .tool ()
7674async def execute_query (
7775 database : str ,
7876 query : str ,
@@ -98,7 +96,6 @@ async def execute_query(
9896 )
9997
10098
101- @mcp .tool ()
10299async def table_summary (
103100 database : str ,
104101 table_name : str ,
@@ -124,7 +121,6 @@ async def table_summary(
124121 )
125122
126123
127- @mcp .tool ()
128124async def search (
129125 database : str ,
130126 search_term : str ,
@@ -147,7 +143,6 @@ async def search(
147143 )
148144
149145
150- @mcp .tool ()
151146async def test_connection (database : str ) -> ToolResult :
152147 """Test database connection, useful for debugging issues"""
153148 result = await tools .test_connection (get_or_init_db_manager (), database )
@@ -157,7 +152,6 @@ async def test_connection(database: str) -> ToolResult:
157152 )
158153
159154
160- @mcp .tool ()
161155def reload_config () -> ToolResult :
162156 """Reload configuration file and report what changed"""
163157 config_path = find_config_file ()
@@ -168,8 +162,29 @@ def reload_config() -> ToolResult:
168162 )
169163
170164
165+ def register_tools ():
166+ available_tools = get_or_init_db_manager ().get_available_tools ()
167+
168+ mcp .tool ()(show_database_config )
169+
170+ if available_tools is None or "execute_query" in available_tools :
171+ mcp .tool ()(execute_query )
172+
173+ if available_tools is None or "table_summary" in available_tools :
174+ mcp .tool ()(table_summary )
175+
176+ if available_tools is None or "search" in available_tools :
177+ mcp .tool ()(search )
178+
179+ if available_tools is None or "test_connection" in available_tools :
180+ mcp .tool ()(test_connection )
181+
182+ if available_tools is None or "reload_config" in available_tools :
183+ mcp .tool ()(reload_config )
184+
185+
171186def main ():
172- get_or_init_db_manager ()
187+ register_tools ()
173188 mcp .run ()
174189
175190
0 commit comments