Skip to main content

A2aAgentConfig

Struct A2aAgentConfig 

Source
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 as https://nous.example.com. The card is fetched from WELL_KNOWN_AGENT_CARD_PATH on 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: String

The agent’s local name, which names its tool a2a__{name}.

§url: String

The 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: bool

Permits sending configured headers over plaintext http:// to a non-loopback host.

This exists so the refusal is overridable but never accidental.

§limits: A2aLimits

Timeouts and size limits, defaulted rather than deserialized.

Implementations§

Source§

impl A2aAgentConfig

Source

pub fn new(name: impl Into<String>, url: impl Into<String>) -> A2aAgentConfig

Creates a configuration with default timeouts and limits.

Source

pub fn with_header( self, name: impl Into<String>, value: impl Into<SecretString>, ) -> A2aAgentConfig

Adds a header sent on every request to the agent.

Source

pub fn with_bearer_token(self, token: impl Into<String>) -> A2aAgentConfig

Adds a bearer Authorization header.

Source

pub fn with_limits(self, limits: A2aLimits) -> A2aAgentConfig

Replaces the timeouts and size limits.

Source

pub fn allowing_plaintext_credentials(self) -> A2aAgentConfig

Permits sending configured headers over plaintext http://.

Source

pub fn card_url(&self) -> Result<Url, A2aConfigError>

The URL the Agent Card is fetched from; see Which URL.

Source

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

Source§

fn clone(&self) -> A2aAgentConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for A2aAgentConfig

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<A2aAgentConfig, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<A2aAgentConfig> for A2aAgent

Source§

fn from(config: A2aAgentConfig) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more