1010
1111logging .basicConfig (level = logging .INFO )
1212
13+ def find_input_tokens (data ):
14+ tokens = set ()
15+ if isinstance (data , list ):
16+ for item in data :
17+ tokens .update (find_input_tokens (item ))
18+ elif isinstance (data , dict ):
19+ for value in data .values ():
20+ tokens .update (find_input_tokens (value ))
21+ elif isinstance (data , str ) and data .startswith ("${input:" ):
22+ tokens .add (data [8 :- 1 ].strip ())
23+ return tokens
24+
1325
1426# New mcp group
1527@click .group ()
@@ -33,10 +45,18 @@ def create_mcp_proxy():
3345 inputs = {}
3446 mcp_config = config .get ("mcp" , {})
3547
36- # Process inputs first
37- for input_def in mcp_config .get ("inputs" , []):
38- input_id = input_def ["id" ]
39- inputs [input_id ] = click .prompt (input_def .get ("description" , input_id ), hide_input = input_def .get ("password" , False ))
48+ # Collect all input IDs from config and server templates
49+ input_ids = set ()
50+ input_ids .update (find_input_tokens (mcp_config .get ("servers" , {})))
51+ input_ids .update (input_def ["id" ] for input_def in mcp_config .get ("inputs" , []))
52+
53+ # Create prompt definitions merging config and discovered inputs
54+ for input_id in input_ids :
55+ input_def = next ((d for d in mcp_config .get ("inputs" , []) if d ["id" ] == input_id ), {})
56+ inputs [input_id ] = click .prompt (
57+ input_def .get ("description" , input_id ),
58+ hide_input = input_def .get ("password" , False )
59+ )
4060
4161 # Process servers
4262 servers = mcp_config .get ("servers" , {})
0 commit comments