MCPcopy Create free account
hub / github.com/IBM/mcp-cli / process_options

Function process_options

src/mcp_cli/config/cli_options.py:104–213  ·  view source on GitHub ↗

Process CLI options. Sets up environment, triggers discovery, and parses config. ENHANCED: Now validates server configuration and provides better error messages.

(
    server: str | None,
    disable_filesystem: bool,
    provider: str,
    model: str | None,
    config_file: str = "server_config.json",
    quiet: bool = False,
)

Source from the content-addressed store, hash-verified

102
103
104def process_options(
105 server: str | None,
106 disable_filesystem: bool,
107 provider: str,
108 model: str | None,
109 config_file: str = "server_config.json",
110 quiet: bool = False,
111) -> tuple[list[str], list[str], dict[int, str]]:
112 """
113 Process CLI options. Sets up environment, triggers discovery, and parses config.
114 ENHANCED: Now validates server configuration and provides better error messages.
115 """
116
117 # STEP 1: Set up ChukLLM environment first
118 setup_chuk_llm_environment()
119
120 # STEP 2: Trigger discovery immediately after setup
121 discovery_count = trigger_discovery_after_setup()
122
123 if discovery_count > 0:
124 logger.debug(f"Discovery found {discovery_count} new functions")
125
126 # STEP 3: Set model environment for downstream use
127 os.environ["LLM_PROVIDER"] = provider
128 if model:
129 os.environ["LLM_MODEL"] = model
130
131 # STEP 4: Set filesystem environment if needed
132 if not disable_filesystem:
133 os.environ["SOURCE_FILESYSTEMS"] = json.dumps([os.getcwd()])
134
135 # STEP 5: Parse server configuration
136 user_specified = []
137 if server:
138 user_specified = [s.strip() for s in server.split(",")]
139
140 cfg = load_config(config_file)
141
142 if not cfg:
143 logger.warning(f"Could not load config file: {config_file}")
144 # Return empty configuration
145 return [], user_specified, {}
146
147 # STEP 6: Validate configuration and filter disabled servers
148 # Get preference manager to check disabled servers
149 from mcp_cli.utils.preferences import get_preference_manager
150
151 pref_manager = get_preference_manager()
152
153 # Filter out disabled servers
154 if user_specified:
155 # If user explicitly requested servers, check if they're disabled
156 enabled_from_requested = []
157 for server in user_specified:
158 if pref_manager.is_server_disabled(server):
159 logger.warning(
160 "Server '%s' is disabled. To enable: mcp-cli chat then /servers %s enable",
161 server,

Callers 15

main_callbackFunction · 0.90
_chat_commandFunction · 0.90
_interactive_commandFunction · 0.90
tools_commandFunction · 0.90
servers_commandFunction · 0.90
resources_commandFunction · 0.90
prompts_commandFunction · 0.90
cmd_commandFunction · 0.90
ping_commandFunction · 0.90

Calls 8

get_preference_managerFunction · 0.90
validate_server_configFunction · 0.90
detect_server_typesFunction · 0.90
load_configFunction · 0.85
extract_server_namesFunction · 0.85
is_server_disabledMethod · 0.80