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

Method load

crates/chat-cli/src/cli/agent/mod.rs:376–403  ·  view source on GitHub ↗
(
        os: &Os,
        agent_path: impl AsRef<Path>,
        legacy_mcp_config: &mut Option<McpServerConfig>,
        mcp_enabled: bool,
        output: &mut impl Write,
    )

Source from the content-addressed store, hash-verified

374 }
375
376 pub async fn load(
377 os: &Os,
378 agent_path: impl AsRef<Path>,
379 legacy_mcp_config: &mut Option<McpServerConfig>,
380 mcp_enabled: bool,
381 output: &mut impl Write,
382 ) -> Result<Agent, AgentConfigError> {
383 let content = os.fs.read(&agent_path).await?;
384 let mut agent = serde_json::from_slice::<Agent>(&content).map_err(|e| AgentConfigError::InvalidJson {
385 error: e,
386 path: agent_path.as_ref().to_path_buf(),
387 })?;
388
389 if mcp_enabled {
390 if agent.use_legacy_mcp_json && legacy_mcp_config.is_none() {
391 let config = load_legacy_mcp_config(os).await.unwrap_or_default();
392 if let Some(config) = config {
393 legacy_mcp_config.replace(config);
394 }
395 }
396 agent.thaw(agent_path.as_ref(), legacy_mcp_config.as_ref(), output)?;
397 } else {
398 agent.clear_mcp_configs();
399 // Thaw the agent with empty MCP config to finalize normalization.
400 agent.thaw(agent_path.as_ref(), None, output)?;
401 }
402 Ok(agent)
403 }
404
405 /// Clear all MCP configurations while preserving built-in tools
406 pub fn clear_mcp_configs(&mut self) {

Callers

nothing calls this directly

Calls 15

load_legacy_mcp_configFunction · 0.85
migrateFunction · 0.85
load_agents_from_entriesFunction · 0.85
readMethod · 0.80
thawMethod · 0.80
clear_mcp_configsMethod · 0.80
agents_dirMethod · 0.80
read_dirMethod · 0.80
globalMethod · 0.80
create_dir_allMethod · 0.80
joinMethod · 0.80
create_newMethod · 0.80

Tested by

no test coverage detected