pub struct BearerAuthContext {
pub client_addr: SocketAddr,
pub route: String,
pub action: String,
pub payload: Option<Value>,
}Expand description
Per-request context passed to a dynamic bearer-token authorizer.
The MCP runtime builds this value before dispatching a request to the protocol implementation. Servers can inspect it to make authorization decisions that depend on more than the raw token string.
§Payload shape
payload is deliberately transport-shaped:
- streamable HTTP JSON-RPC requests receive the
paramsobject, such as{ "name": "tool_name", "arguments": { ... } }fortools/call. - legacy
/tools/executerequests receive the full request body, usually{ "tool": "tool_name", "parameters": { ... } }. - metadata-style routes such as
/tools/listand/resources/listreceiveNonewhen there is no useful body to authorize.
Server crates keep ownership of policy. For example, a memory server can
inspect tool arguments inside payload and allow a token for one chain while
denying the same token for another.
Fields§
§client_addr: SocketAddrClient socket address reported by the HTTP framework.
route: StringHTTP route that received the request.
action: StringMCP method or legacy action being authorized.
payload: Option<Value>Parsed request payload or JSON-RPC params, when available.
This value is cloned from the already-parsed request body so authorizers do not need to parse JSON a second time.
Trait Implementations§
Source§impl Clone for BearerAuthContext
impl Clone for BearerAuthContext
Source§fn clone(&self) -> BearerAuthContext
fn clone(&self) -> BearerAuthContext
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 BearerAuthContext
impl Debug for BearerAuthContext
Source§impl PartialEq for BearerAuthContext
impl PartialEq for BearerAuthContext
Source§fn eq(&self, other: &BearerAuthContext) -> bool
fn eq(&self, other: &BearerAuthContext) -> bool
self and other values to be equal, and is used by ==.impl Eq for BearerAuthContext
impl StructuralPartialEq for BearerAuthContext
Auto Trait Implementations§
impl Freeze for BearerAuthContext
impl RefUnwindSafe for BearerAuthContext
impl Send for BearerAuthContext
impl Sync for BearerAuthContext
impl Unpin for BearerAuthContext
impl UnsafeUnpin for BearerAuthContext
impl UnwindSafe for BearerAuthContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.