cxxmcp 1.2.4
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::Json> meta;
39 std::optional<protocol::TaskRequestParameters> task;
42
44 std::optional<protocol::ProgressToken> progress_token() const {
45 if (!meta.has_value()) {
46 return std::nullopt;
47 }
48 return protocol::meta_progress_token(*meta);
49 }
50
52 bool cancelled() const noexcept { return cancellation.cancelled(); }
53};
54
58 SessionClient client() const noexcept { return session_client(*this); }
59
61 protocol::Json arguments = protocol::Json::object();
64
66 bool cancelled() const noexcept { return cancellation.cancelled(); }
67};
68
72 SessionClient client() const noexcept { return session_client(*this); }
73
75 std::string uri;
77 protocol::Json params = protocol::Json::object();
80
82 bool cancelled() const noexcept { return cancellation.cancelled(); }
83};
84
95
96} // 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:86
protocol::CompleteParams params
Parsed completion/complete request parameters.
Definition context.hpp:88
CancellationToken cancellation
Cooperative cancellation token for this request.
Definition context.hpp:90
bool cancelled() const noexcept
Convenience check for cancellation-aware completion handlers.
Definition context.hpp:93
Invocation context passed to prompt handlers.
Definition context.hpp:56
SessionClient client() const noexcept
Return a non-owning peer handle for this invocation's client.
Definition context.hpp:58
bool cancelled() const noexcept
Convenience check for cancellation-aware handlers.
Definition context.hpp:66
protocol::Json arguments
JSON arguments supplied with the prompt request.
Definition context.hpp:61
CancellationToken cancellation
Cooperative cancellation token for this request.
Definition context.hpp:63
Invocation context passed to resource read handlers.
Definition context.hpp:70
CancellationToken cancellation
Cooperative cancellation token for this request.
Definition context.hpp:79
std::string uri
Requested resource URI.
Definition context.hpp:75
protocol::Json params
Raw resource read parameters supplied by the client.
Definition context.hpp:77
bool cancelled() const noexcept
Convenience check for cancellation-aware handlers.
Definition context.hpp:82
SessionClient client() const noexcept
Return a non-owning peer handle for this invocation's client.
Definition context.hpp:72
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:52
std::optional< protocol::ProgressToken > progress_token() const
Return the tools/call._meta.progressToken, when present.
Definition context.hpp:44
SessionClient client() const noexcept
Return a non-owning peer handle for this invocation's client.
Definition context.hpp:32
std::optional< protocol::Json > meta
Optional tools/call._meta metadata supplied with the tool call.
Definition context.hpp:37
std::optional< protocol::TaskRequestParameters > task
Optional task request metadata supplied with the tool call.
Definition context.hpp:39
CancellationToken cancellation
Cooperative cancellation token for task-aware executions.
Definition context.hpp:41
Asynchronous task status and task-management payloads.
Tool definition, call, and result payloads.