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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for McpConfig
impl<'de> Deserialize<'de> for McpConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for McpConfig
impl RefUnwindSafe for McpConfig
impl Send for McpConfig
impl Sync for McpConfig
impl Unpin for McpConfig
impl UnwindSafe for McpConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more