pub struct McpSpecBuilder { /* private fields */ }Expand description
Builder for McpSpec.
Implementations§
Source§impl McpSpecBuilder
impl McpSpecBuilder
Sourcepub fn owner(self, tag: impl Into<String>) -> Self
pub fn owner(self, tag: impl Into<String>) -> Self
Set the consumer’s owner tag (recorded in the sidecar ownership ledger).
Sourcepub fn adopt_unowned(self, adopt: bool) -> Self
pub fn adopt_unowned(self, adopt: bool) -> Self
Adopt a config entry that exists on disk but has no recorded owner.
Use this to recover from a crash between an earlier install’s config
write and ledger record. With false (default) such entries are
refused with AgentConfigError::NotOwnedByCaller (actual: None)
to avoid silently taking over a hand-installed entry.
Sourcepub fn stdio<I, S>(self, command: impl Into<String>, args: I) -> Self
pub fn stdio<I, S>(self, command: impl Into<String>, args: I) -> Self
Configure a stdio launcher.
Sourcepub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set or replace one environment variable on a stdio transport.
Calling this before configuring stdio, or after configuring a non-stdio
transport, records a builder error returned by
try_build.
Sourcepub fn env_from_host(self, key: impl Into<String>) -> Self
pub fn env_from_host(self, key: impl Into<String>) -> Self
Set an env variable to a placeholder that references the host
environment, e.g. GITHUB_TOKEN=${GITHUB_TOKEN}.
Placeholders are not treated as inline secrets by the local-scope secret policy because the actual secret value is not written.
Sourcepub fn env_placeholder(
self,
key: impl Into<String>,
placeholder: impl Into<String>,
) -> Self
pub fn env_placeholder( self, key: impl Into<String>, placeholder: impl Into<String>, ) -> Self
Set an env variable to a caller-provided placeholder.
This is useful when a harness supports its own placeholder syntax. The value is still validated as a normal MCP env value.
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set or replace one header on an HTTP/SSE transport.
Calling this before configuring HTTP/SSE, or after configuring stdio,
records a builder error returned by try_build.
Sourcepub fn friendly_name(self, name: impl Into<String>) -> Self
pub fn friendly_name(self, name: impl Into<String>) -> Self
Set a human-friendly display name.
Sourcepub fn allow_local_inline_secrets(self) -> Self
pub fn allow_local_inline_secrets(self) -> Self
Explicitly allow likely secret env values in project-local MCP configs.
The default policy refuses this because local project config files are easy to commit, sync, or share accidentally.
Sourcepub fn build(self) -> McpSpec
pub fn build(self) -> McpSpec
Finalize the spec, panicking on missing or invalid fields.
Convenience wrapper around try_build() for tests
and examples. Production code should prefer try_build()
to propagate errors instead of panicking.
§Panics
Panics if required fields are missing or validation fails.
Sourcepub fn try_build(self) -> Result<McpSpec, AgentConfigError>
pub fn try_build(self) -> Result<McpSpec, AgentConfigError>
Finalize the spec, returning Result on missing or invalid fields.
This is the recommended way to build a spec in production code. See crate-level documentation for a full example.
§Errors
AgentConfigError::Otherwhen an earlier builder method recorded a deferred error (e.g. invalid env var name).AgentConfigError::MissingSpecFieldwithfield = "owner"orfield = "transport"when those calls were skipped.AgentConfigError::InvalidTagwhenname,owner_tag, or any transport field (command path, env var, header value) fails identifier or transport validation.
Trait Implementations§
Source§impl Clone for McpSpecBuilder
impl Clone for McpSpecBuilder
Source§fn clone(&self) -> McpSpecBuilder
fn clone(&self) -> McpSpecBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more