agent: Rework context server settings (#32793)

This changes the way context servers are organised. We now store a
`source` which indicates if the MCP server is configured manually or
managed by an extension.

Release Notes:

- N/A

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
Bennet Bo Fenner 2025-06-16 17:31:31 +02:00 committed by GitHub
parent c35f22dde0
commit d7db4d4e0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 639 additions and 197 deletions

View file

@ -938,24 +938,33 @@ impl ExtensionImports for WasmState {
})?)
}
"context_servers" => {
let configuration = key
let settings = key
.and_then(|key| {
ProjectSettings::get(location, cx)
.context_servers
.get(key.as_str())
})
.cloned()
.unwrap_or_default();
Ok(serde_json::to_string(&settings::ContextServerSettings {
command: configuration.command.map(|command| {
settings::CommandSettings {
.context("Failed to get context server configuration")?;
match settings {
project::project_settings::ContextServerSettings::Custom {
command,
} => Ok(serde_json::to_string(&settings::ContextServerSettings {
command: Some(settings::CommandSettings {
path: Some(command.path),
arguments: Some(command.args),
env: command.env.map(|env| env.into_iter().collect()),
}
}),
settings: configuration.settings,
})?)
}),
settings: None,
})?),
project::project_settings::ContextServerSettings::Extension {
settings,
} => Ok(serde_json::to_string(&settings::ContextServerSettings {
command: None,
settings: Some(settings),
})?),
}
}
_ => {
bail!("Unknown settings category: {}", category);