Skip to content

Commit fd24441

Browse files
authored
fix(agent): in memory default not reading from legacy mcp json (#2356)
* fixes in memory default not reading from legacy mcp json * fixes typo
1 parent 4348527 commit fd24441

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

crates/chat-cli/src/cli/agent/mod.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,31 @@ impl Agents {
549549
);
550550
}
551551

552-
local_agents.push(Agent::default());
552+
local_agents.push({
553+
let mut agent = Agent::default();
554+
'load_legacy_mcp_json: {
555+
if global_mcp_config.is_none() {
556+
let Ok(global_mcp_path) = directories::chat_legacy_mcp_config(os) else {
557+
tracing::error!("Error obtaining legacy mcp json path. Skipping");
558+
break 'load_legacy_mcp_json;
559+
};
560+
let legacy_mcp_config = match McpServerConfig::load_from_file(os, global_mcp_path).await {
561+
Ok(config) => config,
562+
Err(e) => {
563+
tracing::error!("Error loading global mcp json path: {e}. Skipping");
564+
break 'load_legacy_mcp_json;
565+
},
566+
};
567+
global_mcp_config.replace(legacy_mcp_config);
568+
}
569+
}
570+
571+
if let Some(config) = &global_mcp_config {
572+
agent.mcp_servers = config.clone();
573+
}
574+
575+
agent
576+
});
553577
"default".to_string()
554578
};
555579

docs/the-agent-format.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Resources are data and content that your agent has access to. As of today, only
148148

149149
### The `hooks` field
150150

151-
The `hooks` field invokes functions at specific trigger points. The output of these functions is persisted into context according to the lifetime rules of the trigger. Hooks that run once, on `agentSpawn` for example, will be added to persistant context while shorter lived hooks like `userPromptSubmit` exist inside of the rolling context window.
151+
The `hooks` field invokes functions at specific trigger points. The output of these functions is persisted into context according to the lifetime rules of the trigger. Hooks that run once, on `agentSpawn` for example, will be added to persistent context while shorter lived hooks like `userPromptSubmit` exist inside of the rolling context window.
152152

153153
```json
154154
{

0 commit comments

Comments
 (0)