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

Method load_from_file

crates/chat-cli/src/cli/agent/mcp_config.rs:21–32  ·  view source on GitHub ↗
(os: &Os, path: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

19
20impl McpServerConfig {
21 pub async fn load_from_file(os: &Os, path: impl AsRef<Path>) -> eyre::Result<Self> {
22 let contents = os.fs.read(path.as_ref()).await?;
23 let value = serde_json::from_slice::<serde_json::Value>(&contents)?;
24 // We need to extract mcp_servers field from the value because we have annotated
25 // [McpServerConfig] with transparent. Transparent was added because we want to preserve
26 // the type in agent.
27 let config = value
28 .get("mcpServers")
29 .cloned()
30 .ok_or(eyre::eyre!("No mcp servers found in config"))?;
31 Ok(serde_json::from_value(config)?)
32 }
33
34 pub async fn save_to_file(&self, os: &Os, path: impl AsRef<Path>) -> eyre::Result<()> {
35 let json = self.to_non_transparent_json_pretty()?;

Callers

nothing calls this directly

Calls 3

readMethod · 0.80
as_refMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected