cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
context.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 [caomengxuan666]
2
3#pragma once
4
7
8#include <optional>
9#include <string>
10
18
19namespace mcp::server {
20
23
32 SessionClient client() const noexcept { return session_client(*this); }
33
35 protocol::Json arguments = protocol::Json::object();
37 std::optional<protocol::TaskRequestParameters> task;
40
42 bool cancelled() const noexcept { return cancellation.cancelled(); }
43};
44
48 SessionClient client() const noexcept { return session_client(*this); }
49
51 protocol::Json arguments = protocol::Json::object();
54
56 bool cancelled() const noexcept { return cancellation.cancelled(); }
57};
58
62 SessionClient client() const noexcept { return session_client(*this); }
63
65 std::string uri;
67 protocol::Json params = protocol::Json::object();
70
72 bool cancelled() const noexcept { return cancellation.cancelled(); }
73};
74
85
86} // namespace mcp::server
Cooperative cancellation primitives shared by SDK lifecycle APIs.
Copyable token observed by cancellation-aware SDK operations.
Definition cancellation.hpp:104
bool cancelled() const noexcept
Returns true after the associated source has requested cancellation.
Definition cancellation.hpp:117
Non-owning handle for the client associated with a server session.
Definition peer.hpp:46
Completion request and result payloads.
Prompt discovery and rendering payloads.
nlohmann::json Json
JSON value type used by all protocol DTOs.
Definition types.hpp:28
Resource listing, template, subscription, and read payloads.
Server-side handle for sending requests and notifications to a client peer.
SessionClient session_client(const SessionContext &context) noexcept
Create a SessionClient handle from a session context.
Definition peer.hpp:870
Parameters for completion/complete.
Definition completion.hpp:98
Completion request context passed to typed completion handlers.
Definition context.hpp:76
protocol::CompleteParams params
Parsed completion/complete request parameters.
Definition context.hpp:78
CancellationToken cancellation
Cooperative cancellation token for this request.
Definition context.hpp:80
bool cancelled() const noexcept
Convenience check for cancellation-aware completion handlers.
Definition context.hpp:83
Invocation context passed to prompt handlers.
Definition context.hpp:46
SessionClient client() const noexcept
Return a non-owning peer handle for this invocation's client.
Definition context.hpp:48
bool cancelled() const noexcept
Convenience check for cancellation-aware handlers.
Definition context.hpp:56
protocol::Json arguments
JSON arguments supplied with the prompt request.
Definition context.hpp:51
CancellationToken cancellation
Cooperative cancellation token for this request.
Definition context.hpp:53
Invocation context passed to resource read handlers.
Definition context.hpp:60
CancellationToken cancellation
Cooperative cancellation token for this request.
Definition context.hpp:69
std::string uri
Requested resource URI.
Definition context.hpp:65
protocol::Json params
Raw resource read parameters supplied by the client.
Definition context.hpp:67
bool cancelled() const noexcept
Convenience check for cancellation-aware handlers.
Definition context.hpp:72
SessionClient client() const noexcept
Return a non-owning peer handle for this invocation's client.
Definition context.hpp:62
Per-message connection metadata supplied to server handlers.
Definition transport.hpp:42
Invocation context passed to tool handlers.
Definition context.hpp:30
protocol::Json arguments
JSON arguments supplied with the tool call.
Definition context.hpp:35
bool cancelled() const noexcept
Convenience check for cancellation-aware handlers.
Definition context.hpp:42
SessionClient client() const noexcept
Return a non-owning peer handle for this invocation's client.
Definition context.hpp:32
std::optional< protocol::TaskRequestParameters > task
Optional task request metadata supplied with the tool call.
Definition context.hpp:37
CancellationToken cancellation
Cooperative cancellation token for task-aware executions.
Definition context.hpp:39
Asynchronous task status and task-management payloads.
Tool definition, call, and result payloads.