Module adcp.config
Functions
def ensure_config_dir() ‑> None-
Expand source code
def ensure_config_dir() -> None: """Ensure config directory exists.""" CONFIG_DIR.mkdir(parents=True, exist_ok=True)Ensure config directory exists.
def get_agent(alias: str) ‑> dict[str, typing.Any] | None-
Expand source code
def get_agent(alias: str) -> dict[str, Any] | None: """Get agent configuration by alias.""" config = load_config() result = config.get("agents", {}).get(alias) return cast(dict[str, Any], result) if result is not None else NoneGet agent configuration by alias.
def list_agents() ‑> dict[str, typing.Any]-
Expand source code
def list_agents() -> dict[str, Any]: """List all saved agents.""" config = load_config() return cast(dict[str, Any], config.get("agents", {}))List all saved agents.
def load_config() ‑> dict[str, typing.Any]-
Expand source code
def load_config() -> dict[str, Any]: """Load configuration file.""" if not CONFIG_FILE.exists(): return {"agents": {}} with open(CONFIG_FILE) as f: return cast(dict[str, Any], json.load(f))Load configuration file.
def remove_agent(alias: str) ‑> bool-
Expand source code
def remove_agent(alias: str) -> bool: """Remove agent configuration.""" config = load_config() if alias in config.get("agents", {}): del config["agents"][alias] save_config(config) return True return FalseRemove agent configuration.
def save_agent(alias: str, url: str, protocol: str | None = None, auth_token: str | None = None) ‑> None-
Expand source code
def save_agent( alias: str, url: str, protocol: str | None = None, auth_token: str | None = None ) -> None: """Save agent configuration.""" config = load_config() if "agents" not in config: config["agents"] = {} config["agents"][alias] = { "agent_uri": url, "protocol": protocol or "mcp", } if auth_token: config["agents"][alias]["auth_token"] = auth_token save_config(config)Save agent configuration.
def save_config(config: dict[str, Any]) ‑> None-
Expand source code
def save_config(config: dict[str, Any]) -> None: """Save configuration file with atomic write.""" ensure_config_dir() # Write to temporary file first temp_file = CONFIG_FILE.with_suffix(".tmp") with open(temp_file, "w") as f: json.dump(config, f, indent=2) # Atomic rename temp_file.replace(CONFIG_FILE)Save configuration file with atomic write.