pub struct A2aAgentConfig {
pub name: String,
pub url: String,
pub headers: BTreeMap<String, SecretString>,
pub allow_plaintext_credentials: bool,
pub limits: A2aLimits,
}Expand description
Configuration for one remote agent reached over A2A.
§Which URL
url names the agent in one of two ways, told apart by its path alone:
- A base URL — path
/(or none) and no query, such ashttps://nous.example.com. The card is fetched fromWELL_KNOWN_AGENT_CARD_PATHon that origin, where the specification says an agent publishes it. - A card URL — anything else, such as
https://example.com/agents/nous/card.json, is fetched as given.
Well-known paths only exist at an origin’s root, so a URL with a path is never a base for one; there is no third case to guess at.
§Example
use mentra::a2a::A2aAgentConfig;
let config = A2aAgentConfig::new("nous", "https://nous.example.com")
.with_bearer_token("<token>");
assert_eq!(
config.card_url().unwrap().as_str(),
"https://nous.example.com/.well-known/agent-card.json",
);§Security
Header values are stored as SecretString and never appear in Debug
output, error messages, or logs. They are sent on the card fetch and on
every call. Configuring a header on a plaintext http:// URL is
rejected unless the host is loopback — the same rule, with the same
override, as the MCP HTTP transports — and the rule is applied again to
the interface URL the card names, because that URL is chosen by the
remote side rather than by the operator.
Fields§
§name: StringThe agent’s local name, which names its tool a2a__{name}.
url: StringThe agent’s base URL or card URL; see Which URL.
headers: BTreeMap<String, SecretString>Headers sent on every request to the agent.
allow_plaintext_credentials: boolPermits sending configured headers over plaintext http:// to a
non-loopback host.
This exists so the refusal is overridable but never accidental.
limits: A2aLimitsTimeouts and size limits, defaulted rather than deserialized.
Implementations§
Source§impl A2aAgentConfig
impl A2aAgentConfig
Sourcepub fn new(name: impl Into<String>, url: impl Into<String>) -> A2aAgentConfig
pub fn new(name: impl Into<String>, url: impl Into<String>) -> A2aAgentConfig
Creates a configuration with default timeouts and limits.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<SecretString>,
) -> A2aAgentConfig
pub fn with_header( self, name: impl Into<String>, value: impl Into<SecretString>, ) -> A2aAgentConfig
Adds a header sent on every request to the agent.
Sourcepub fn with_bearer_token(self, token: impl Into<String>) -> A2aAgentConfig
pub fn with_bearer_token(self, token: impl Into<String>) -> A2aAgentConfig
Adds a bearer Authorization header.
Sourcepub fn with_limits(self, limits: A2aLimits) -> A2aAgentConfig
pub fn with_limits(self, limits: A2aLimits) -> A2aAgentConfig
Replaces the timeouts and size limits.
Sourcepub fn allowing_plaintext_credentials(self) -> A2aAgentConfig
pub fn allowing_plaintext_credentials(self) -> A2aAgentConfig
Permits sending configured headers over plaintext http://.
Sourcepub fn card_url(&self) -> Result<Url, A2aConfigError>
pub fn card_url(&self) -> Result<Url, A2aConfigError>
The URL the Agent Card is fetched from; see Which URL.
Sourcepub fn validate(&self) -> Result<Url, A2aConfigError>
pub fn validate(&self) -> Result<Url, A2aConfigError>
Validates the configuration and returns the card URL.
Checks the name, URL, header names and values, credential handling and limits without connecting, so a host can reject a bad configuration at its own boundary rather than discovering it on the first request.
Trait Implementations§
Source§impl Clone for A2aAgentConfig
impl Clone for A2aAgentConfig
Source§fn clone(&self) -> A2aAgentConfig
fn clone(&self) -> A2aAgentConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for A2aAgentConfig
Hand-written so no {:?} of a config prints a credential. Header values
are SecretStrings and redact themselves; url is a plain String, and
its userinfo and query string are where a credential would sit, so both
are replaced. String surgery rather than a URL parser: Debug must never
fail, and an unparseable URL is exactly what someone will debug-print.
impl Debug for A2aAgentConfig
Hand-written so no {:?} of a config prints a credential. Header values
are SecretStrings and redact themselves; url is a plain String, and
its userinfo and query string are where a credential would sit, so both
are replaced. String surgery rather than a URL parser: Debug must never
fail, and an unparseable URL is exactly what someone will debug-print.