pub struct Upstream { /* private fields */ }Expand description
An upstream MCP server (Streamable HTTP).
Implementations§
Source§impl Upstream
impl Upstream
Sourcepub fn new(prefix: impl Into<String>, url: impl Into<String>) -> Self
pub fn new(prefix: impl Into<String>, url: impl Into<String>) -> Self
The server at url (its MCP endpoint, e.g. https://mcp.example.com/mcp),
whose tools appear as <prefix>__<tool>. prefix is letters, digits,
- and single _s.
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Send this header to the upstream on every request — its credentials,
e.g. .header("Authorization", "Bearer <upstream token>").
Sourcepub fn header_for<F>(self, name: impl Into<String>, value: F) -> Self
pub fn header_for<F>(self, name: impl Into<String>, value: F) -> Self
Send header name on each tool call with a value computed from the
caller’s verified claims (the JSON of
McpContext::auth_claims, None
for a caller without one) — e.g. each user’s own upstream token,
looked up by sub, so the upstream acts as that user. None from
value sends no header. Only tools/call carries a caller; listing
and prompts/resources use the static Self::headers.
Sourcepub fn timeout_ms(self, timeout_ms: u64) -> Self
pub fn timeout_ms(self, timeout_ms: u64) -> Self
Give up on an upstream request after this long (default 30 s).