MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / bind_agent_identity

Function bind_agent_identity

atomic-cli/src/commands/identity/mod.rs:500–529  ·  view source on GitHub ↗

Record an agent identity on a server profile so hooks use it by default. Writes `agent_identity` on the named profile, or on the active one when no name is given. The human binding (`identity`) is left alone: enrollment and revocation still authenticate as the human.

(
    server_override: Option<&str>,
    agent_name: &str,
)

Source from the content-addressed store, hash-verified

498/// name is given. The human binding (`identity`) is left alone: enrollment and
499/// revocation still authenticate as the human.
500pub fn bind_agent_identity(
501 server_override: Option<&str>,
502 agent_name: &str,
503) -> crate::error::CliResult<()> {
504 use crate::error::CliError;
505
506 let mut config = GlobalConfig::load()
507 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load config: {e}")))?;
508
509 let profile = server_override
510 .map(str::to_string)
511 .or_else(|| config.default_server.clone());
512
513 match profile {
514 Some(name) => match config.servers.get_mut(&name) {
515 Some(server) => server.agent_identity = Some(agent_name.to_string()),
516 None => {
517 return Err(CliError::InvalidArgument {
518 message: format!("No server profile named '{name}'"),
519 })
520 }
521 },
522 // No named profiles yet — the legacy [server] block is the active one.
523 None => config.server.agent_identity = Some(agent_name.to_string()),
524 }
525
526 config
527 .save()
528 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save config: {e}")))
529}
530
531/// Format an identity type for display.
532pub fn format_identity_type(identity_type: &atomic_identity::IdentityType) -> &'static str {

Callers 1

bind_agent_in_configFunction · 0.85

Calls 3

get_mutMethod · 0.80
cloneMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected