@@ -95,6 +95,7 @@ Each tool file should contain a function decorated with @mcp.tool().
9595"""
9696
9797import sys
98+ import logging
9899from pathlib import Path
99100
100101# Add src to Python path
@@ -105,6 +106,15 @@ from core.server import DynamicMCPServer
105106
106107def main() -> None:
107108 """Main entry point for the MCP server."""
109+ # Configure logging
110+ logging.basicConfig(
111+ level=logging.INFO,
112+ format='%(asctime)s - %(levelname)s - %(message)s',
113+ handlers=[
114+ logging.StreamHandler(sys.stderr)
115+ ]
116+ )
117+
108118 try:
109119 # Create server with dynamic tool loading
110120 server = DynamicMCPServer(
@@ -152,6 +162,7 @@ Each tool file should contain a function decorated with @mcp.tool().
152162
153163import os
154164import sys
165+ import logging
155166import importlib.util
156167from pathlib import Path
157168from typing import Dict, Any, List, Callable
@@ -203,7 +214,7 @@ class DynamicMCPServer:
203214 tool_files = [f for f in tool_files if f.name != "__init__.py"]
204215
205216 if not tool_files:
206- print (f"No tool files found in {self.tools_dir}")
217+ logging.warning (f"No tool files found in {self.tools_dir}")
207218 return
208219
209220 loaded_count = 0
@@ -215,19 +226,19 @@ class DynamicMCPServer:
215226 if self._import_tool_module(tool_file, tool_name):
216227 self.loaded_tools.append(tool_name)
217228 loaded_count += 1
218- print (f"✅ Loaded tool module: {tool_name}")
229+ logging.info (f"Loaded tool module: {tool_name}")
219230 else:
220- print (f"❌ Failed to load tool module: {tool_name}")
231+ logging.warning (f"Failed to load tool module: {tool_name}")
221232
222233 except Exception as e:
223- print (f"❌ Error loading tool {tool_file.name}: {e}")
234+ logging.warning (f"Error loading tool {tool_file.name}: {e}")
224235 # Fail fast - if any tool fails to load, stop the server
225236 sys.exit(1)
226237
227- print (f"📦 Successfully loaded {loaded_count} tools")
238+ logging.info (f"📦 Successfully loaded {loaded_count} tools")
228239
229240 if loaded_count == 0:
230- print("⚠️ No tools loaded. Server starting without tools.")
241+ logging.warning(" No tools loaded. Server starting without tools.")
231242
232243 def _import_tool_module(self, tool_file: Path, tool_name: str) -> bool:
233244 """Import a tool module, which auto-registers tools via decorators.
0 commit comments