66"""
77
88import json
9+ import logging
910import os
1011import subprocess
1112import sys
1213from pathlib import Path
1314
15+ logger = logging .getLogger (__name__ )
16+
17+
18+ def setup_logger ():
19+ """Configure logger for CLI usage with colored output."""
20+ if not logger .handlers :
21+ handler = logging .StreamHandler (sys .stdout )
22+ formatter = logging .Formatter ("%(message)s" )
23+ handler .setFormatter (formatter )
24+ logger .addHandler (handler )
25+ logger .setLevel (logging .INFO )
26+
1427
1528class Colors :
1629 """ANSI color codes for terminal output."""
@@ -22,19 +35,19 @@ class Colors:
2235 NC = "\033 [0m" # No Color
2336
2437
25- def print_step (message : str , color : str = Colors . YELLOW ):
26- """Print a colored step message."""
27- print (f"{ color } { message } { Colors .NC } " )
38+ def log_step (message : str ):
39+ """Log a colored step message."""
40+ logger . info (f"{ Colors . YELLOW } { message } { Colors .NC } " )
2841
2942
30- def print_success (message : str ):
31- """Print a success message."""
32- print (f"{ Colors .GREEN } ✓ { message } { Colors .NC } " )
43+ def log_success (message : str ):
44+ """Log a success message."""
45+ logger . info (f"{ Colors .GREEN } ✓ { message } { Colors .NC } " )
3346
3447
35- def print_error (message : str ):
36- """Print an error message."""
37- print (f"{ Colors .RED } ✗ { message } { Colors .NC } " , file = sys . stderr )
48+ def log_error (message : str ):
49+ """Log an error message."""
50+ logger . error (f"{ Colors .RED } ✗ { message } { Colors .NC } " )
3851
3952
4053def run_command (cmd : list , error_msg : str ) -> bool :
@@ -43,52 +56,53 @@ def run_command(cmd: list, error_msg: str) -> bool:
4356 subprocess .run (cmd , check = True , capture_output = True , text = True )
4457 return True
4558 except subprocess .CalledProcessError as e :
46- print_error (error_msg )
47- print (f"Error output: { e .stderr } " , file = sys . stderr )
59+ log_error (error_msg )
60+ logger . error (f"Error output: { e .stderr } " )
4861 return False
4962
5063
5164def main ():
5265 """Main setup function."""
53- print ("=== Aden Hive Framework MCP Server Setup ===" )
54- print ()
66+ setup_logger ()
67+ logger .info ("=== Aden Hive Framework MCP Server Setup ===" )
68+ logger .info ("" )
5569
5670 # Get script directory
5771 script_dir = Path (__file__ ).parent .absolute ()
5872 os .chdir (script_dir )
5973
6074 # Step 1: Install framework package
61- print_step ("Step 1: Installing framework package..." )
75+ log_step ("Step 1: Installing framework package..." )
6276 if not run_command (
6377 [sys .executable , "-m" , "pip" , "install" , "-e" , "." ], "Failed to install framework package"
6478 ):
6579 sys .exit (1 )
66- print_success ("Framework package installed" )
67- print ( )
80+ log_success ("Framework package installed" )
81+ logger . info ( "" )
6882
6983 # Step 2: Install MCP dependencies
70- print_step ("Step 2: Installing MCP dependencies..." )
84+ log_step ("Step 2: Installing MCP dependencies..." )
7185 if not run_command (
7286 [sys .executable , "-m" , "pip" , "install" , "mcp" , "fastmcp" ],
7387 "Failed to install MCP dependencies" ,
7488 ):
7589 sys .exit (1 )
76- print_success ("MCP dependencies installed" )
77- print ( )
90+ log_success ("MCP dependencies installed" )
91+ logger . info ( "" )
7892
7993 # Step 3: Verify/create MCP configuration
80- print_step ("Step 3: Verifying MCP server configuration..." )
94+ log_step ("Step 3: Verifying MCP server configuration..." )
8195 mcp_config_path = script_dir / ".mcp.json"
8296
8397 if mcp_config_path .exists ():
84- print_success ("MCP configuration found at .mcp.json" )
85- print ("Configuration:" )
98+ log_success ("MCP configuration found at .mcp.json" )
99+ logger . info ("Configuration:" )
86100 with open (mcp_config_path ) as f :
87101 config = json .load (f )
88- print (json .dumps (config , indent = 2 ))
102+ logger . info (json .dumps (config , indent = 2 ))
89103 else :
90- print_error ("No .mcp.json found" )
91- print ("Creating default MCP configuration..." )
104+ log_error ("No .mcp.json found" )
105+ logger . info ("Creating default MCP configuration..." )
92106
93107 config = {
94108 "mcpServers" : {
@@ -103,11 +117,11 @@ def main():
103117 with open (mcp_config_path , "w" ) as f :
104118 json .dump (config , f , indent = 2 )
105119
106- print_success ("Created .mcp.json" )
107- print ( )
120+ log_success ("Created .mcp.json" )
121+ logger . info ( "" )
108122
109123 # Step 4: Test MCP server
110- print_step ("Step 4: Testing MCP server..." )
124+ log_step ("Step 4: Testing MCP server..." )
111125 try :
112126 # Try importing the MCP server module
113127 subprocess .run (
@@ -116,27 +130,27 @@ def main():
116130 capture_output = True ,
117131 text = True ,
118132 )
119- print_success ("MCP server module verified" )
133+ log_success ("MCP server module verified" )
120134 except subprocess .CalledProcessError as e :
121- print_error ("Failed to import MCP server module" )
122- print (f"Error: { e .stderr } " , file = sys . stderr )
135+ log_error ("Failed to import MCP server module" )
136+ logger . error (f"Error: { e .stderr } " )
123137 sys .exit (1 )
124- print ( )
138+ logger . info ( "" )
125139
126140 # Success summary
127- print (f"{ Colors .GREEN } === Setup Complete ==={ Colors .NC } " )
128- print ( )
129- print ("The MCP server is now ready to use!" )
130- print ( )
131- print (f"{ Colors .BLUE } To start the MCP server manually:{ Colors .NC } " )
132- print (" python -m framework.mcp.agent_builder_server" )
133- print ( )
134- print (f"{ Colors .BLUE } MCP Configuration location:{ Colors .NC } " )
135- print (f" { mcp_config_path } " )
136- print ( )
137- print (f"{ Colors .BLUE } To use with Claude Desktop or other MCP clients,{ Colors .NC } " )
138- print (f"{ Colors .BLUE } add the following to your MCP client configuration:{ Colors .NC } " )
139- print ( )
141+ logger . info (f"{ Colors .GREEN } === Setup Complete ==={ Colors .NC } " )
142+ logger . info ( "" )
143+ logger . info ("The MCP server is now ready to use!" )
144+ logger . info ( "" )
145+ logger . info (f"{ Colors .BLUE } To start the MCP server manually:{ Colors .NC } " )
146+ logger . info (" python -m framework.mcp.agent_builder_server" )
147+ logger . info ( "" )
148+ logger . info (f"{ Colors .BLUE } MCP Configuration location:{ Colors .NC } " )
149+ logger . info (f" { mcp_config_path } " )
150+ logger . info ( "" )
151+ logger . info (f"{ Colors .BLUE } To use with Claude Desktop or other MCP clients,{ Colors .NC } " )
152+ logger . info (f"{ Colors .BLUE } add the following to your MCP client configuration:{ Colors .NC } " )
153+ logger . info ( "" )
140154
141155 example_config = {
142156 "mcpServers" : {
@@ -147,8 +161,8 @@ def main():
147161 }
148162 }
149163 }
150- print (json .dumps (example_config , indent = 2 ))
151- print ( )
164+ logger . info (json .dumps (example_config , indent = 2 ))
165+ logger . info ( "" )
152166
153167
154168if __name__ == "__main__" :
0 commit comments