cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
mcp::server::SessionContext Struct Reference

Per-message connection metadata supplied to server handlers. More...

#include <transport.hpp>

Inheritance diagram for mcp::server::SessionContext:
mcp::server::CompletionContext mcp::server::PromptContext mcp::server::ResourceContext mcp::server::ToolContext

Public Member Functions

SessionClient client () const noexcept
 Return a non-owning handle for the client on this session.
 

Public Attributes

std::string session_id
 Logical MCP session id when the transport has one.
 
std::string remote_address
 Best-effort remote endpoint description such as "stdio" or an address.
 
std::unordered_map< std::string, std::string > headers
 Transport-supplied request headers or metadata for this message.
 
std::optional< std::string > http_method
 HTTP request method for HTTP-based transports.
 
std::optional< std::string > http_url
 Absolute HTTP request URL for HTTP-based transports.
 
std::optional< AuthIdentityauth_identity
 Authenticated principal produced by the configured AuthProvider.
 
Transporttransport = nullptr
 Borrowed transport used to create a ClientPeer for outbound messages.
 
std::weak_ptr< void > transport_lifetime
 Weak lifetime token supplied by the transport.
 

Detailed Description

Per-message connection metadata supplied to server handlers.

The context is passed by value or const reference for the duration of a handler invocation. It does not own the transport; transport is a borrowed pointer that remains valid only while the underlying transport instance is alive and the session is active.

Member Function Documentation

◆ client()

SessionClient mcp::server::SessionContext::client ( ) const
inlinenoexcept

Return a non-owning handle for the client on this session.

Returns
A SessionClient bound to transport, or an unavailable handle when no transport is associated with the context.

Member Data Documentation

◆ transport_lifetime

std::weak_ptr<void> mcp::server::SessionContext::transport_lifetime

Weak lifetime token supplied by the transport.

ClientPeer checks this before using the borrowed transport pointer so stored contexts fail closed after the transport has been destroyed.


The documentation for this struct was generated from the following files: