MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / thaw

Method thaw

crates/chat-cli/src/cli/agent/mod.rs:227–269  ·  view source on GitHub ↗

This function mutates the agent to a state that is usable for runtime. Practically this means to convert some of the fields value to their usable counterpart. For example, converting the mcp array to actual mcp config and populate the agent file path.

(
        &mut self,
        path: &Path,
        legacy_mcp_config: Option<&McpServerConfig>,
        output: &mut impl Write,
    )

Source from the content-addressed store, hash-verified

225 /// Practically this means to convert some of the fields value to their usable counterpart.
226 /// For example, converting the mcp array to actual mcp config and populate the agent file path.
227 fn thaw(
228 &mut self,
229 path: &Path,
230 legacy_mcp_config: Option<&McpServerConfig>,
231 output: &mut impl Write,
232 ) -> Result<(), AgentConfigError> {
233 self.path = Some(path.to_path_buf());
234
235 // Resolve file:// URIs in the prompt field
236 if let Some(resolved_prompt) = self.resolve_prompt()? {
237 self.prompt = Some(resolved_prompt);
238 }
239
240 let Self { mcp_servers, .. } = self;
241
242 if let (true, Some(legacy_mcp_config)) = (self.use_legacy_mcp_json, legacy_mcp_config) {
243 for (name, legacy_server) in &legacy_mcp_config.mcp_servers {
244 if mcp_servers.mcp_servers.contains_key(name) {
245 let _ = queue!(
246 output,
247 StyledText::warning_fg(),
248 style::Print("WARNING: "),
249 StyledText::reset(),
250 style::Print("MCP server '"),
251 StyledText::success_fg(),
252 style::Print(name),
253 StyledText::reset(),
254 style::Print(
255 "' is already configured in agent config. Skipping duplicate from legacy mcp.json.\n"
256 )
257 );
258 continue;
259 }
260 let mut server_clone = legacy_server.clone();
261 server_clone.is_from_legacy_mcp_json = true;
262 mcp_servers.mcp_servers.insert(name.clone(), server_clone);
263 }
264 }
265
266 output.flush()?;
267
268 Ok(())
269 }
270
271 pub fn print_overridden_permissions(&self, output: &mut impl Write) -> Result<(), AgentConfigError> {
272 let execute_name = if cfg!(windows) { "execute_cmd" } else { "execute_bash" };

Callers 2

get_agent_by_nameMethod · 0.80
loadMethod · 0.80

Calls 4

resolve_promptMethod · 0.80
insertMethod · 0.80
cloneMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected