cxxmcp 1.2.4
C++ MCP SDK
Loading...
Searching...
No Matches
authoring.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 [caomengxuan666]
2
3#pragma once
4
7
8#include <cstdint>
9#include <memory>
10#include <stdexcept>
11#include <string>
12#include <string_view>
13#include <type_traits>
14#include <utility>
15
16#include "cxxmcp/config.hpp"
19
20namespace mcp::server {
21
22namespace detail {
23
24template <class T, class = void>
25struct has_tool_title : std::false_type {};
26
27template <class T>
28struct has_tool_title<T, std::void_t<decltype(T::title)>> : std::true_type {};
29
30template <class T, class = void>
31struct has_tool_description : std::false_type {};
32
33template <class T>
34struct has_tool_description<T, std::void_t<decltype(T::description)>>
35 : std::true_type {};
36
37template <class T, class = void>
38struct has_tool_definition : std::false_type {};
39
40template <class T>
42 T, std::void_t<decltype(std::declval<const T&>().definition())>>
43 : std::true_type {};
44
45template <class Tool, class Text>
46inline std::string static_tool_text(Text value) {
47 if constexpr (std::is_convertible_v<Text, std::string_view>) {
48 return std::string(std::string_view(value));
49 } else {
50 return std::string(value);
51 }
52}
53
54} // namespace detail
55
57template <class Args, class Result, class Handler>
59 protocol::ToolDefinition definition;
60 Handler handler;
61};
62
64template <class Args, class Result>
66 public:
67 explicit TypedToolBuilder(std::string name) {
68 definition_ = protocol::tool_definition(std::move(name))
69 .input_schema(protocol::tool_input_schema_for<Args>())
70 .build();
71 detail::apply_default_output_schema<Result>(definition_);
72 }
73
75 : definition_(std::move(definition)) {}
76
77 TypedToolBuilder& title(std::string value) {
78 definition_.title = std::move(value);
79 return *this;
80 }
81
82 TypedToolBuilder& description(std::string value) {
83 definition_.description = std::move(value);
84 return *this;
85 }
86
87 TypedToolBuilder& input_schema(protocol::Json schema) {
88 definition_.input_schema = std::move(schema);
89 return *this;
90 }
91
92 template <class T>
93 TypedToolBuilder& input() {
94 return input_schema(protocol::tool_input_schema_for<T>());
95 }
96
97 TypedToolBuilder& output_schema(protocol::Json schema) {
98 definition_.output_schema = std::move(schema);
99 definition_.output_schema_present = true;
100 return *this;
101 }
102
103 template <class T>
104 TypedToolBuilder& output() {
105 return output_schema(protocol::tool_output_schema_for<T>());
106 }
107
108 TypedToolBuilder& streaming(bool value = true) {
109 definition_.streaming = value;
110 return *this;
111 }
112
113 TypedToolBuilder& icon(protocol::Icon value) {
114 definition_.icons.push_back(std::move(value));
115 return *this;
116 }
117
118 TypedToolBuilder& task_support(protocol::TaskSupport value) {
119 if (!definition_.execution.has_value()) {
120 definition_.execution = protocol::ToolExecution{};
121 }
122 definition_.execution->task_support = value;
123 return *this;
124 }
125
126 TypedToolBuilder& execution(protocol::ToolExecution value) {
127 definition_.execution = std::move(value);
128 return *this;
129 }
130
131 TypedToolBuilder& annotations(protocol::Json value) {
132 definition_.annotations = std::move(value);
133 return *this;
134 }
135
136 TypedToolBuilder& meta(protocol::Json value) {
137 definition_.meta = std::move(value);
138 return *this;
139 }
140
141 template <class Handler>
142 TypedToolRegistration<Args, Result, Handler> handler(Handler value) {
143 detail::require_callable(value, "tool");
144 detail::require_unambiguous_tool_handler<Handler, Args>();
145 return TypedToolRegistration<Args, Result, Handler>{std::move(definition_),
146 std::move(value)};
147 }
148
149 private:
150 protocol::ToolDefinition definition_;
151};
152
154template <class Args, class Result>
155inline TypedToolBuilder<Args, Result> tool(std::string name) {
156 return TypedToolBuilder<Args, Result>(std::move(name));
157}
158
165template <class Tool>
166inline auto tool(Tool value) {
167 using Args = typename Tool::Args;
168 using Result = typename Tool::Result;
169 auto definition = [&]() {
171 return value.definition();
172 } else {
173 auto built =
174 protocol::tool_definition(detail::static_tool_text<Tool>(Tool::name))
175 .build();
177 built.title = detail::static_tool_text<Tool>(Tool::title);
178 }
180 built.description = detail::static_tool_text<Tool>(Tool::description);
181 }
182 return built;
183 }
184 }();
185 if (definition.input_schema.empty()) {
186 definition.input_schema = protocol::tool_input_schema_for<Args>();
187 }
188 detail::apply_default_output_schema<Result>(definition);
189 TypedToolBuilder<Args, Result> builder(std::move(definition));
190 return builder.handler(std::move(value));
191}
192
195template <class Tool>
196inline auto tool() {
197 return tool(Tool{});
198}
199
201template <class Args, class Handler>
203 protocol::Prompt prompt;
204 Handler handler;
205};
206
208template <class Args>
210 public:
211 explicit TypedPromptBuilder(protocol::Prompt prompt)
212 : prompt_(std::move(prompt)) {}
213
214 explicit TypedPromptBuilder(std::string name) {
215 prompt_ = protocol::prompt_definition(std::move(name)).build();
216 }
217
218 TypedPromptBuilder& title(std::string value) {
219 prompt_.title = std::move(value);
220 return *this;
221 }
222
223 TypedPromptBuilder& description(std::string value) {
224 prompt_.description = std::move(value);
225 return *this;
226 }
227
228 TypedPromptBuilder& argument(std::string name, bool required = false,
229 std::string description = {}) {
231 argument.name = std::move(name);
232 argument.required = required;
233 argument.required_present = true;
234 argument.description = std::move(description);
235 prompt_.arguments.push_back(std::move(argument));
236 return *this;
237 }
238
240 prompt_.icons.push_back(std::move(value));
241 return *this;
242 }
243
244 TypedPromptBuilder& annotations(protocol::Json value) {
245 prompt_.annotations = std::move(value);
246 return *this;
247 }
248
250 prompt_.meta = std::move(value);
251 return *this;
252 }
253
254 template <class Handler>
255 TypedPromptRegistration<Args, Handler> handler(Handler value) {
256 detail::require_callable(value, "prompt");
257 detail::require_unambiguous_typed_context_handler<Handler, Args,
258 PromptContext>("prompt");
259 return TypedPromptRegistration<Args, Handler>{std::move(prompt_),
260 std::move(value)};
261 }
262
263 private:
264 protocol::Prompt prompt_;
265};
266
267template <class Args>
268inline TypedPromptBuilder<Args> prompt(std::string name) {
269 return TypedPromptBuilder<Args>(std::move(name));
270}
271
272template <class Args>
273inline TypedPromptBuilder<Args> prompt(protocol::Prompt prompt) {
274 return TypedPromptBuilder<Args>(std::move(prompt));
275}
276
278template <class Args, class Handler>
280 protocol::Resource resource;
281 Handler handler;
282};
283
285template <class Args>
287 public:
289 : resource_(std::move(resource)) {}
290
291 TypedResourceBuilder(std::string uri, std::string name) {
292 resource_ =
293 protocol::resource_definition(std::move(uri), std::move(name)).build();
294 }
295
296 TypedResourceBuilder& title(std::string value) {
297 resource_.title = std::move(value);
298 return *this;
299 }
300
301 TypedResourceBuilder& description(std::string value) {
302 resource_.description = std::move(value);
303 return *this;
304 }
305
306 TypedResourceBuilder& mime_type(std::string value) {
307 resource_.mime_type = std::move(value);
308 return *this;
309 }
310
311 TypedResourceBuilder& size(std::int64_t value) {
312 resource_.size = value;
313 return *this;
314 }
315
317 resource_.icons.push_back(std::move(value));
318 return *this;
319 }
320
321 TypedResourceBuilder& annotations(protocol::Json value) {
322 resource_.annotations = std::move(value);
323 return *this;
324 }
325
327 resource_.meta = std::move(value);
328 return *this;
329 }
330
331 template <class Handler>
332 TypedResourceRegistration<Args, Handler> handler(Handler value) {
333 detail::require_callable(value, "resource");
334 detail::require_unambiguous_typed_context_handler<Handler, Args,
336 "resource");
337 return TypedResourceRegistration<Args, Handler>{std::move(resource_),
338 std::move(value)};
339 }
340
341 private:
342 protocol::Resource resource_;
343};
344
345template <class Args>
346inline TypedResourceBuilder<Args> resource(std::string uri, std::string name) {
347 return TypedResourceBuilder<Args>(std::move(uri), std::move(name));
348}
349
350template <class Args>
351inline TypedResourceBuilder<Args> resource(protocol::Resource resource) {
352 return TypedResourceBuilder<Args>(std::move(resource));
353}
354
355inline protocol::ResourceTemplateBuilder resource_template(
356 std::string uri_template, std::string name) {
357 return protocol::resource_template_definition(std::move(uri_template),
358 std::move(name));
359}
360
365class CXXMCP_DEPRECATED(
366 "App is a compatibility entry point; use ServerPeer::builder() with "
367 "cxxmcp/run.hpp instead") App {
368 public:
370 class Builder {
371 public:
373 Builder& name(std::string value);
374
376 Builder& version(std::string value);
377
379 Builder& instructions(std::string value);
380
382 Builder& stdio();
383
384#if defined(CXXMCP_ENABLE_HTTP)
389 Builder& streamable_http(std::string host, std::uint16_t port,
390 std::string path = "/mcp");
391
396 Builder& legacy_sse(std::string host, std::uint16_t port,
397 std::string path = "/mcp");
398#endif
399
402 Builder& transport(std::unique_ptr<Transport> value);
403
405 Builder& tasks(TaskOperationProcessorOptions options = {});
406
408 Builder& schema_validator(
409 std::shared_ptr<const JsonSchemaValidator> validator);
410
420 template <class Args, class Result, class Handler>
421 Builder& tool(std::string name, Handler handler);
422
424 template <class Args, class Result, class Handler>
425 Builder& tool(protocol::ToolDefinition definition, Handler handler);
426
428 template <class Args, class Result, class Handler>
429 Builder& tool(TypedToolRegistration<Args, Result, Handler> registration);
430
432 Builder& tool(protocol::ToolDefinition definition, ToolHandler handler);
433
441 template <class Args, class Handler>
442 Builder& prompt(std::string name, Handler handler);
443
444 template <class Handler>
445 Builder& prompt(std::string name, Handler handler);
446
448 Builder& prompt(protocol::Prompt prompt, PromptHandler handler);
449
458 template <class Args, class Handler>
459 Builder& resource(std::string name, Handler handler);
460
461 template <class Handler>
462 Builder& resource(std::string name, Handler handler);
463
465 Builder& resource(protocol::Resource resource, ResourceReadHandler handler);
466
474 template <class Handler>
475 Builder& resource_template(std::string name, Handler handler);
476
478 Builder& resource_template(protocol::ResourceTemplate resource_template);
479
481 template <class Handler>
482 Builder& completion(Handler handler);
483
485 template <class Handler>
486 Builder& sampling(Handler handler);
487
489 template <class Handler>
490 Builder& logging(Handler handler);
491
496 template <class Handler>
497 Builder& raw_request(Handler handler);
498
500 core::Result<std::unique_ptr<Server>> build();
501
503 int run();
504
505 private:
506 ServerBuilder builder_;
507 };
508
510 CXXMCP_DEPRECATED("use ServerPeer::builder() instead")
511 static Builder builder();
512};
513
514template <class Args, class Result, class Handler>
515App::Builder& App::Builder::tool(std::string name, Handler handler) {
516 detail::require_callable(handler, "tool");
517 detail::require_unambiguous_tool_handler<Handler, Args>();
518 auto definition = protocol::tool_definition(std::move(name))
519 .input_schema(protocol::tool_input_schema_for<Args>())
520 .build();
521 detail::apply_default_output_schema<Result>(definition);
522 return tool<Args, Result>(std::move(definition), std::move(handler));
523}
524
525template <class Args, class Result, class Handler>
526App::Builder& App::Builder::tool(protocol::ToolDefinition definition,
527 Handler handler) {
528 detail::require_callable(handler, "tool");
529 detail::require_unambiguous_tool_handler<Handler, Args>();
530 if (definition.input_schema.empty()) {
531 definition.input_schema = protocol::tool_input_schema_for<Args>();
532 }
533 detail::apply_default_output_schema<Result>(definition);
534 return tool(
535 std::move(definition),
536 [handler = std::move(handler)](
537 const ToolContext& context) -> core::Result<protocol::ToolResult> {
538 try {
539 auto args = detail::argument_from_json<Args>(context.arguments);
540 auto handled =
541 detail::invoke_tool_handler(handler, std::move(args), context);
542 if constexpr (detail::is_result<decltype(handled)>::value) {
543 if (!handled) {
544 return mcp::core::unexpected(handled.error());
545 }
546 return detail::value_to_tool_result(*handled);
547 } else {
548 return detail::value_to_tool_result(std::move(handled));
549 }
550 } catch (const std::exception& exception) {
551 return mcp::core::unexpected(core::Error{
552 static_cast<int>(protocol::ErrorCode::InvalidParams),
553 "failed to decode tool arguments",
554 exception.what(),
555 });
556 }
557 });
558}
559
560template <class Args, class Result, class Handler>
561App::Builder& App::Builder::tool(
562 TypedToolRegistration<Args, Result, Handler> registration) {
563 return tool<Args, Result>(std::move(registration.definition),
564 std::move(registration.handler));
565}
566
567template <class Args, class Handler>
568App::Builder& App::Builder::prompt(std::string name, Handler handler) {
569 detail::require_callable(handler, "prompt");
570 detail::require_unambiguous_typed_context_handler<Handler, Args,
571 PromptContext>("prompt");
572 protocol::Prompt prompt;
573 prompt.name = std::move(name);
574 return this->prompt(
575 std::move(prompt),
576 [handler = std::move(handler)](const PromptContext& context)
577 -> core::Result<protocol::PromptsGetResult> {
578 try {
579 auto args = context.arguments.get<Args>();
580 auto handled = detail::invoke_typed_context_handler(
581 handler, std::move(args), context);
582 if constexpr (detail::is_result<decltype(handled)>::value) {
583 if (!handled) {
584 return mcp::core::unexpected(handled.error());
585 }
586 return detail::value_to_prompt_result(*handled);
587 } else {
588 return detail::value_to_prompt_result(std::move(handled));
589 }
590 } catch (const std::exception& exception) {
591 return mcp::core::unexpected(core::Error{
592 static_cast<int>(protocol::ErrorCode::InvalidParams),
593 "failed to decode prompt arguments",
594 exception.what(),
595 });
596 }
597 });
598}
599
600template <class Handler>
601App::Builder& App::Builder::prompt(std::string name, Handler handler) {
602 detail::require_callable(handler, "prompt");
603 detail::require_unambiguous_prompt_handler<Handler>();
604 protocol::Prompt prompt;
605 prompt.name = std::move(name);
606 return this->prompt(
607 std::move(prompt),
608 [handler = std::move(handler)](const PromptContext& context)
609 -> core::Result<protocol::PromptsGetResult> {
610 try {
611 auto handled = detail::invoke_prompt_handler(handler, context);
612 if constexpr (detail::is_result<decltype(handled)>::value) {
613 if (!handled) {
614 return mcp::core::unexpected(handled.error());
615 }
616 return detail::value_to_prompt_result(*handled);
617 } else {
618 return detail::value_to_prompt_result(std::move(handled));
619 }
620 } catch (const std::exception& exception) {
621 return mcp::core::unexpected(core::Error{
622 static_cast<int>(protocol::ErrorCode::InvalidParams),
623 "failed to run prompt handler",
624 exception.what(),
625 });
626 }
627 });
628}
629
630template <class Args, class Handler>
631App::Builder& App::Builder::resource(std::string name, Handler handler) {
632 detail::require_callable(handler, "resource");
633 detail::require_unambiguous_typed_context_handler<Handler, Args,
634 ResourceContext>(
635 "resource");
636 protocol::Resource resource;
637 resource.uri = std::move(name);
638 resource.name = resource.uri;
639 return this->resource(
640 std::move(resource),
641 [handler = std::move(handler)](const ResourceContext& context)
642 -> core::Result<protocol::ResourcesReadResult> {
643 try {
644 auto args = context.params.get<Args>();
645 auto handled = detail::invoke_typed_context_handler(
646 handler, std::move(args), context);
647 if constexpr (detail::is_result<decltype(handled)>::value) {
648 if (!handled) {
649 return mcp::core::unexpected(handled.error());
650 }
651 return detail::value_to_resource_read_result(*handled, context.uri);
652 } else {
653 return detail::value_to_resource_read_result(std::move(handled),
654 context.uri);
655 }
656 } catch (const std::exception& exception) {
657 return mcp::core::unexpected(core::Error{
658 static_cast<int>(protocol::ErrorCode::InvalidParams),
659 "failed to decode resource parameters",
660 exception.what(),
661 });
662 }
663 });
664}
665
666template <class Handler>
667App::Builder& App::Builder::resource(std::string name, Handler handler) {
668 detail::require_callable(handler, "resource");
669 detail::require_unambiguous_resource_handler<Handler>();
670 protocol::Resource resource;
671 resource.uri = std::move(name);
672 resource.name = resource.uri;
673 if constexpr (std::is_invocable_v<Handler>) {
674 using Handled = decltype(handler());
675 if constexpr (std::is_same_v<std::decay_t<Handled>, protocol::Resource>) {
676 resource = handler();
677 }
678 }
679 return this->resource(
680 std::move(resource),
681 [handler = std::move(handler)](const ResourceContext& context)
682 -> core::Result<protocol::ResourcesReadResult> {
683 try {
684 auto handled = detail::invoke_resource_handler(handler, context);
685 if constexpr (std::is_same_v<std::decay_t<decltype(handled)>,
686 protocol::Resource>) {
687 return protocol::ResourcesReadResult{};
688 } else if constexpr (detail::is_result<decltype(handled)>::value) {
689 if (!handled) {
690 return mcp::core::unexpected(handled.error());
691 }
692 return detail::value_to_resource_read_result(*handled, context.uri);
693 } else {
694 return detail::value_to_resource_read_result(std::move(handled),
695 context.uri);
696 }
697 } catch (const std::exception& exception) {
698 return mcp::core::unexpected(core::Error{
699 static_cast<int>(protocol::ErrorCode::InvalidParams),
700 "failed to run resource handler",
701 exception.what(),
702 });
703 }
704 });
705}
706
707template <class Handler>
708App::Builder& App::Builder::resource_template(std::string name,
709 Handler handler) {
710 detail::require_callable(handler, "resource_template");
711 protocol::ResourceTemplate resource_template;
712 if constexpr (std::is_invocable_v<Handler>) {
713 auto handled = handler();
714 if constexpr (detail::is_result<decltype(handled)>::value) {
715 if (!handled) {
716 throw std::runtime_error(handled.error().message);
717 }
718 resource_template = *handled;
719 } else {
720 resource_template = std::move(handled);
721 }
722 } else if constexpr (std::is_invocable_v<Handler, std::string>) {
723 resource_template = handler({});
724 } else {
725 static_assert(
726 std::is_invocable_v<Handler>,
727 "resource_template handler must accept no arguments or string");
728 }
729 if (resource_template.name.empty()) {
730 resource_template.name = name;
731 }
732 if (resource_template.uri_template.empty()) {
733 resource_template.uri_template = std::move(name);
734 }
735 return this->resource_template(std::move(resource_template));
736}
737
738template <class Handler>
739App::Builder& App::Builder::completion(Handler handler) {
740 detail::require_callable(handler, "completion");
741 if constexpr (detail::is_typed_completion_handler_v<Handler>) {
742 detail::require_unambiguous_completion_handler<Handler>();
743 } else {
744 detail::require_unambiguous_json_extension_handler<Handler>();
745 }
746 builder_.on_completion(
747 [handler = std::move(handler)](const protocol::Json& request,
748 const SessionContext& context,
749 CancellationToken cancellation) mutable
750 -> core::Result<protocol::Json> {
751 if constexpr (detail::is_typed_completion_handler_v<Handler>) {
752 const auto params = protocol::complete_params_from_json(request);
753 if (!params) {
754 return mcp::core::unexpected(core::Error{
755 static_cast<int>(protocol::ErrorCode::InvalidParams),
756 params.error().message, params.error().detail, "protocol"});
757 }
758 CompletionContext completion_context;
759 static_cast<SessionContext&>(completion_context) = context;
760 completion_context.params = *params;
761 completion_context.cancellation = cancellation;
762 auto handled =
763 detail::invoke_completion_handler(handler, completion_context);
764 return detail::completion_response_to_json(std::move(handled));
765 } else {
766 auto handled = detail::invoke_json_extension_handler(
767 handler, request, context, cancellation);
768 if constexpr (detail::is_result<decltype(handled)>::value) {
769 return handled;
770 } else {
771 return detail::value_to_json(std::move(handled));
772 }
773 }
774 });
775 return *this;
776}
777
778template <class Handler>
779App::Builder& App::Builder::sampling(Handler handler) {
780 detail::require_callable(handler, "sampling");
781 detail::require_unambiguous_json_extension_handler<Handler>();
782 builder_.on_sampling(
783 [handler = std::move(handler)](const protocol::Json& request,
784 const SessionContext& context,
785 CancellationToken cancellation) mutable
786 -> core::Result<protocol::Json> {
787 auto handled = detail::invoke_json_extension_handler(
788 handler, request, context, cancellation);
789 if constexpr (detail::is_result<decltype(handled)>::value) {
790 return handled;
791 } else {
792 return detail::value_to_json(std::move(handled));
793 }
794 });
795 return *this;
796}
797
798template <class Handler>
799App::Builder& App::Builder::logging(Handler handler) {
800 detail::require_callable(handler, "logging");
801 builder_.on_logging([handler = std::move(handler)](std::string_view level,
802 std::string_view message) {
803 handler(level, message);
804 });
805 return *this;
806}
807
808template <class Handler>
809App::Builder& App::Builder::raw_request(Handler handler) {
810 detail::require_callable(handler, "raw_request");
811 builder_.on_raw_request([handler = std::move(handler)](
812 const protocol::JsonRpcRequest& request,
813 const SessionContext& context)
814 -> std::optional<protocol::JsonRpcResponse> {
815 (void)context;
816 if constexpr (std::is_same_v<std::decay_t<decltype(handler(request))>,
817 std::optional<protocol::JsonRpcResponse>>) {
818 return handler(request);
819 } else if constexpr (std::is_same_v<
820 std::decay_t<decltype(handler(request))>,
821 protocol::JsonRpcResponse>) {
822 return handler(request);
823 } else {
824 handler(request);
825 return std::nullopt;
826 }
827 });
828 return *this;
829}
830
831} // namespace mcp::server
TypedToolBuilder< Args, Result > tool(std::string name)
Starts a typed tool registration builder.
Definition authoring.hpp:155
Fluent builder for resource-template descriptors.
Definition resource.hpp:151
Fluent typed prompt builder for low-boilerplate server authoring.
Definition authoring.hpp:209
Fluent typed resource builder for low-boilerplate server authoring.
Definition authoring.hpp:286
Fluent typed tool builder for low-boilerplate server authoring.
Definition authoring.hpp:65
Public SDK configuration and compatibility markers.
Internal handler dispatch helpers for cxxmcp server authoring APIs.
nlohmann::json Json
JSON value type used by all protocol DTOs.
Definition types.hpp:28
constexpr auto unexpected(E &&value)
Creates an unexpected result value for the active expected backend.
Definition result.hpp:24
High-level server compatibility API, builder, and convenience app API.
Icon descriptor used by tools, resources, resource templates, and prompts.
Definition types.hpp:160
Argument accepted by a prompt template.
Definition prompt.hpp:63
std::string name
Stable argument name used as a key in prompts/get arguments.
Definition prompt.hpp:67
bool required
Whether the caller must provide this argument.
Definition prompt.hpp:71
bool required_present
Whether required was explicitly present on the wire or configured.
Definition prompt.hpp:73
std::string description
Optional human-readable description.
Definition prompt.hpp:69
Prompt descriptor returned by prompts/list.
Definition prompt.hpp:83
std::optional< Json > meta
Optional _meta extension object preserved on the wire.
Definition prompt.hpp:97
std::string description
Optional human-readable description.
Definition prompt.hpp:89
std::vector< Icon > icons
Optional icon descriptors for client presentation.
Definition prompt.hpp:93
std::vector< PromptArgument > arguments
Prompt arguments accepted by this prompt.
Definition prompt.hpp:91
std::string title
Optional human-readable display title.
Definition prompt.hpp:85
Json annotations
Optional annotations for model or client presentation.
Definition prompt.hpp:95
Concrete resource advertised by resources/list.
Definition resource.hpp:28
std::string title
Optional human-readable display title.
Definition resource.hpp:30
std::string mime_type
Optional MIME type for the resource contents.
Definition resource.hpp:38
std::string description
Optional human-readable description.
Definition resource.hpp:36
Json annotations
Optional annotations for model or client presentation.
Definition resource.hpp:44
std::optional< Json > meta
Optional _meta extension object preserved on the wire.
Definition resource.hpp:46
std::optional< std::int64_t > size
Optional size hint in bytes when known.
Definition resource.hpp:40
std::vector< Icon > icons
Optional icon descriptors for client presentation.
Definition resource.hpp:42
Metadata describing a callable MCP tool.
Definition tool.hpp:213
Json input_schema
JSON Schema object describing accepted arguments.
Definition tool.hpp:221
std::optional< ToolExecution > execution
Optional execution configuration including task support mode.
Definition tool.hpp:231
Json output_schema
Optional JSON Schema object describing structured result content.
Definition tool.hpp:223
std::string title
Optional human-readable display title.
Definition tool.hpp:215
Json annotations
Optional raw annotations preserved for forward-compatible round trips.
Definition tool.hpp:235
std::vector< Icon > icons
Optional icon descriptors for client presentation.
Definition tool.hpp:229
bool output_schema_present
Whether output_schema was explicitly present on the wire or configured.
Definition tool.hpp:225
std::string description
Human-readable tool description.
Definition tool.hpp:219
std::optional< Json > meta
Optional _meta extension object preserved on the wire.
Definition tool.hpp:237
bool streaming
Whether the tool may stream partial results outside a single response.
Definition tool.hpp:227
Execution configuration advertised with a tool definition.
Definition tool.hpp:44
Invocation context passed to prompt handlers.
Definition context.hpp:56
Invocation context passed to resource read handlers.
Definition context.hpp:70
Typed prompt registration produced by mcp::server::prompt().
Definition authoring.hpp:202
Typed resource registration produced by mcp::server::resource().
Definition authoring.hpp:279
Typed tool registration produced by mcp::server::tool().
Definition authoring.hpp:58
Definition authoring.hpp:38
Definition authoring.hpp:25
TaskSupport
Per-tool support mode for task-based invocation.
Definition tool.hpp:34