66"""
77
88import json
9+ import logging
910import os
1011import subprocess
1112import sys
1213from pathlib import Path
1314
15+ # Configure logger
16+ logger = logging .getLogger (__name__ )
17+
18+
19+ def setup_logger ():
20+ """Configure logger for CLI usage with colored output."""
21+ if not logger .handlers :
22+ handler = logging .StreamHandler (sys .stdout )
23+ formatter = logging .Formatter ('%(message)s' )
24+ handler .setFormatter (formatter )
25+ logger .addHandler (handler )
26+ logger .setLevel (logging .INFO )
27+
1428
1529class Colors :
1630 """ANSI color codes for terminal output."""
@@ -21,19 +35,19 @@ class Colors:
2135 NC = '\033 [0m' # No Color
2236
2337
24- def print_step (message : str , color : str = Colors . YELLOW ):
25- """Print a colored step message."""
26- 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 } " )
2741
2842
29- def print_success (message : str ):
30- """Print a success message."""
31- 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 } " )
3246
3347
34- def print_error (message : str ):
35- """Print an error message."""
36- 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 } " )
3751
3852
3953def run_command (cmd : list , error_msg : str ) -> bool :
@@ -42,53 +56,54 @@ def run_command(cmd: list, error_msg: str) -> bool:
4256 subprocess .run (cmd , check = True , capture_output = True , text = True )
4357 return True
4458 except subprocess .CalledProcessError as e :
45- print_error (error_msg )
46- print (f"Error output: { e .stderr } " , file = sys . stderr )
59+ log_error (error_msg )
60+ logger . error (f"Error output: { e .stderr } " )
4761 return False
4862
4963
5064def main ():
5165 """Main setup function."""
52- print ("=== Aden Hive Framework MCP Server Setup ===" )
53- print ()
66+ setup_logger ()
67+ logger .info ("=== Aden Hive Framework MCP Server Setup ===" )
68+ logger .info ("" )
5469
5570 # Get script directory
5671 script_dir = Path (__file__ ).parent .absolute ()
5772 os .chdir (script_dir )
5873
5974 # Step 1: Install framework package
60- print_step ("Step 1: Installing framework package..." )
75+ log_step ("Step 1: Installing framework package..." )
6176 if not run_command (
6277 [sys .executable , "-m" , "pip" , "install" , "-e" , "." ],
6378 "Failed to install framework package"
6479 ):
6580 sys .exit (1 )
66- print_success ("Framework package installed" )
67- print ( )
81+ log_success ("Framework package installed" )
82+ logger . info ( "" )
6883
6984 # Step 2: Install MCP dependencies
70- print_step ("Step 2: Installing MCP dependencies..." )
85+ log_step ("Step 2: Installing MCP dependencies..." )
7186 if not run_command (
7287 [sys .executable , "-m" , "pip" , "install" , "mcp" , "fastmcp" ],
7388 "Failed to install MCP dependencies"
7489 ):
7590 sys .exit (1 )
76- print_success ("MCP dependencies installed" )
77- print ( )
91+ log_success ("MCP dependencies installed" )
92+ logger . info ( "" )
7893
7994 # Step 3: Verify/create MCP configuration
80- print_step ("Step 3: Verifying MCP server configuration..." )
95+ log_step ("Step 3: Verifying MCP server configuration..." )
8196 mcp_config_path = script_dir / ".mcp.json"
8297
8398 if mcp_config_path .exists ():
84- print_success ("MCP configuration found at .mcp.json" )
85- print ("Configuration:" )
99+ log_success ("MCP configuration found at .mcp.json" )
100+ logger . info ("Configuration:" )
86101 with open (mcp_config_path ) as f :
87102 config = json .load (f )
88- print (json .dumps (config , indent = 2 ))
103+ logger . info (json .dumps (config , indent = 2 ))
89104 else :
90- print_error ("No .mcp.json found" )
91- print ("Creating default MCP configuration..." )
105+ log_error ("No .mcp.json found" )
106+ logger . info ("Creating default MCP configuration..." )
92107
93108 config = {
94109 "mcpServers" : {
@@ -103,11 +118,11 @@ def main():
103118 with open (mcp_config_path , 'w' ) as f :
104119 json .dump (config , f , indent = 2 )
105120
106- print_success ("Created .mcp.json" )
107- print ( )
121+ log_success ("Created .mcp.json" )
122+ logger . info ( "" )
108123
109124 # Step 4: Test MCP server
110- print_step ("Step 4: Testing MCP server..." )
125+ log_step ("Step 4: Testing MCP server..." )
111126 try :
112127 # Try importing the MCP server module
113128 subprocess .run (
@@ -116,27 +131,27 @@ def main():
116131 capture_output = True ,
117132 text = True
118133 )
119- print_success ("MCP server module verified" )
134+ log_success ("MCP server module verified" )
120135 except subprocess .CalledProcessError as e :
121- print_error ("Failed to import MCP server module" )
122- print (f"Error: { e .stderr } " , file = sys . stderr )
136+ log_error ("Failed to import MCP server module" )
137+ logger . error (f"Error: { e .stderr } " )
123138 sys .exit (1 )
124- print ( )
139+ logger . info ( "" )
125140
126141 # 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 ( )
142+ logger . info (f"{ Colors .GREEN } === Setup Complete ==={ Colors .NC } " )
143+ logger . info ( "" )
144+ logger . info ("The MCP server is now ready to use!" )
145+ logger . info ( "" )
146+ logger . info (f"{ Colors .BLUE } To start the MCP server manually:{ Colors .NC } " )
147+ logger . info (" python -m framework.mcp.agent_builder_server" )
148+ logger . info ( "" )
149+ logger . info (f"{ Colors .BLUE } MCP Configuration location:{ Colors .NC } " )
150+ logger . info (f" { mcp_config_path } " )
151+ logger . info ( "" )
152+ logger . info (f"{ Colors .BLUE } To use with Claude Desktop or other MCP clients,{ Colors .NC } " )
153+ logger . info (f"{ Colors .BLUE } add the following to your MCP client configuration:{ Colors .NC } " )
154+ logger . info ( "" )
140155
141156 example_config = {
142157 "mcpServers" : {
@@ -147,8 +162,8 @@ def main():
147162 }
148163 }
149164 }
150- print (json .dumps (example_config , indent = 2 ))
151- print ( )
165+ logger . info (json .dumps (example_config , indent = 2 ))
166+ logger . info ( "" )
152167
153168
154169if __name__ == "__main__" :
0 commit comments