pub struct McpConfig {
pub mcp_servers: HashMap<String, McpServerConfig>,
}Expand description
The main MCP configuration file structure for .mcp.json.
This represents the complete MCP configuration file that Claude Code reads to connect to MCP servers. The file may contain both AGPM-managed and user-managed server configurations.
Fields§
§mcp_servers: HashMap<String, McpServerConfig>Map of server names to their configurations
Implementations§
Source§impl McpConfig
impl McpConfig
Sourcepub fn load_or_default(path: &Path) -> Result<Self>
pub fn load_or_default(path: &Path) -> Result<Self>
Load an existing .mcp.json file or create a new empty configuration.
This method preserves all existing server configurations, including user-managed ones.
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Save the configuration to a .mcp.json file.
The file is written atomically to prevent corruption.
Sourcepub fn update_managed_servers(
&mut self,
updates: HashMap<String, McpServerConfig>,
) -> Result<()>
pub fn update_managed_servers( &mut self, updates: HashMap<String, McpServerConfig>, ) -> Result<()>
Update only AGPM-managed servers, preserving user configurations.
This method:
- Removes old AGPM-managed servers not in the update set
- Adds or updates AGPM-managed servers from the update set
- Preserves all user-managed servers (those without AGPM metadata)
Sourcepub fn check_conflicts(
&self,
new_servers: &HashMap<String, McpServerConfig>,
) -> Vec<String>
pub fn check_conflicts( &self, new_servers: &HashMap<String, McpServerConfig>, ) -> Vec<String>
Check for conflicts with user-managed servers.
Returns a list of server names that would conflict with existing user-managed servers.
Sourcepub fn remove_all_managed(&mut self)
pub fn remove_all_managed(&mut self)
Remove all AGPM-managed servers.
This is useful for cleanup operations.
Sourcepub fn get_managed_servers(&self) -> HashMap<String, &McpServerConfig>
pub fn get_managed_servers(&self) -> HashMap<String, &McpServerConfig>
Get all AGPM-managed servers.