|
cxxmcp 1.1.6
C++ MCP SDK
|
Fluent builder for constructing a configured Server. More...
#include <server.hpp>
Public Member Functions | |
| ServerBuilder & | name (std::string value) |
| Sets the advertised server name. | |
| ServerBuilder & | version (std::string value) |
| Sets the advertised server version. | |
| ServerBuilder & | instructions (std::string value) |
| Sets the advertised server instructions. | |
| ServerBuilder & | with_capabilities (protocol::ServerCapabilities capabilities) |
| Replaces the capabilities advertised during initialization. | |
| ServerBuilder & | with_transport (std::unique_ptr< Transport > transport) |
| Adds a transport to be owned by the built server. | |
| ServerBuilder & | with_auth_provider (std::unique_ptr< AuthProvider > auth_provider) |
| Sets the authentication provider owned by the built server. | |
| ServerBuilder & | with_rate_limiter (std::unique_ptr< RateLimiter > rate_limiter) |
| Sets the rate limiter owned by the built server. | |
| ServerBuilder & | with_schema_validator (std::shared_ptr< const JsonSchemaValidator > validator) |
| Sets the optional JSON Schema validator used by the built server. | |
| ServerBuilder & | with_task_manager (TaskOperationProcessorOptions options={}) |
| Enables the built-in SDK task processor on the built server. | |
| ServerBuilder & | with_task_manager (std::shared_ptr< TaskOperationProcessor > processor) |
| Uses an explicit task processor on the built server. | |
| ServerBuilder & | add_tool (protocol::ToolDefinition definition, ToolHandler handler) |
| Registers a tool definition and handler. | |
| ServerBuilder & | add_prompt (protocol::Prompt prompt, PromptHandler handler) |
| Registers a prompt and handler. | |
| ServerBuilder & | add_resource (protocol::Resource resource, ResourceReadHandler handler) |
| Registers a resource and read handler. | |
| ServerBuilder & | add_resource_template (protocol::ResourceTemplate resource_template) |
| Registers a resource template. | |
| template<class Router > | |
| ServerBuilder & | with_router (const Router &router) |
| Applies a composable router object to this builder. | |
| ServerBuilder & | on_completion (Server::JsonHandler handler) |
| Sets the completion request handler. | |
| ServerBuilder & | on_completion (Server::JsonContextHandler handler) |
| ServerBuilder & | on_completion (Server::JsonRequestContextHandler handler) |
| ServerBuilder & | on_sampling (Server::JsonHandler handler) |
| Sets the sampling request handler. | |
| ServerBuilder & | on_sampling (Server::JsonContextHandler handler) |
| ServerBuilder & | on_sampling (Server::JsonRequestContextHandler handler) |
| ServerBuilder & | on_logging (Server::LoggingHandler handler) |
| Sets the logging notification handler. | |
| ServerBuilder & | on_raw_request (Server::RawRequestHandler handler) |
| Sets the raw request hook. | |
| ServerBuilder & | on_raw_notification (Server::RawNotificationHandler handler) |
| Sets the raw notification hook. | |
| ServerBuilder & | on_custom_request (Server::RawRequestHandler handler) |
| Sets the custom request handler. | |
| ServerBuilder & | on_custom_notification (Server::RawNotificationHandler handler) |
| Sets the custom notification handler. | |
| ServerBuilder & | on_task_list (Server::TaskListHandler handler) |
| Sets the task list handler. | |
| ServerBuilder & | on_tools_list (Server::ToolsListHandler handler) |
| Sets the tools/list handler. | |
| ServerBuilder & | on_prompts_list (Server::PromptsListHandler handler) |
| Sets the prompts/list handler. | |
| ServerBuilder & | on_resources_list (Server::ResourcesListHandler handler) |
| Sets the resources/list handler. | |
| ServerBuilder & | on_resource_templates_list (Server::ResourceTemplatesListHandler handler) |
| Sets the resources/templates/list handler. | |
| ServerBuilder & | on_task_get (Server::TaskGetHandler handler) |
| Sets the task get handler. | |
| ServerBuilder & | on_task_cancel (Server::TaskCancelHandler handler) |
| Sets the task cancel handler. | |
| ServerBuilder & | on_task_result (Server::TaskResultHandler handler) |
| Sets the task result handler. | |
| ServerBuilder & | on_progress (Server::ProgressHandler handler) |
| Sets the progress notification handler. | |
| ServerBuilder & | on_roots_list_changed (Server::RootsListChangedHandler handler) |
| Sets the roots-list-changed notification handler. | |
| ServerBuilder & | on_tool_list_changed (Server::ListChangedHandler handler) |
| Sets the tool-list-changed notification handler. | |
| ServerBuilder & | on_prompt_list_changed (Server::ListChangedHandler handler) |
| Sets the prompt-list-changed notification handler. | |
| ServerBuilder & | on_resource_list_changed (Server::ListChangedHandler handler) |
| Sets the resource-list-changed notification handler. | |
| ServerBuilder & | on_resource_updated (Server::ResourceUpdatedHandler handler) |
| Sets the resource-updated notification handler. | |
| ServerBuilder & | with_handler (ServerHandler handler) |
| Installs every non-empty callback from a handler aggregate. | |
| ServerBuilder & | with_handler (const ServerHandlerInterface &handler) |
| Installs callbacks from a borrowed contract-style handler. | |
| ServerBuilder & | with_handler (std::shared_ptr< const ServerHandlerInterface > handler) |
| Installs callbacks from an owned contract-style handler. | |
| core::Result< std::unique_ptr< Server > > | build () |
| Builds a configured server. | |
Fluent builder for constructing a configured Server.
Registrations are accumulated until build(). build() creates a Server, transfers owned transports/providers, registers tools, prompts, resources, and templates, then applies configured handler overrides.
| ServerBuilder & mcp::server::ServerBuilder::add_prompt | ( | protocol::Prompt | prompt, |
| PromptHandler | handler | ||
| ) |
Registers a prompt and handler.
| prompt | Prompt metadata advertised by list_prompts(). |
| handler | Handler invoked when the prompt is requested. |
| ServerBuilder & mcp::server::ServerBuilder::add_resource | ( | protocol::Resource | resource, |
| ResourceReadHandler | handler | ||
| ) |
Registers a resource and read handler.
| resource | Resource metadata advertised by list_resources(). |
| handler | Handler invoked when the resource URI is read. |
| ServerBuilder & mcp::server::ServerBuilder::add_resource_template | ( | protocol::ResourceTemplate | resource_template | ) |
Registers a resource template.
| resource_template | Template metadata advertised by list_resource_templates(). |
| ServerBuilder & mcp::server::ServerBuilder::add_tool | ( | protocol::ToolDefinition | definition, |
| ToolHandler | handler | ||
| ) |
Registers a tool definition and handler.
| definition | Tool metadata advertised by list_tools(). |
| handler | Handler invoked when the tool is called. |
| core::Result< std::unique_ptr< Server > > mcp::server::ServerBuilder::build | ( | ) |
Builds a configured server.
| ServerBuilder & mcp::server::ServerBuilder::with_handler | ( | const ServerHandlerInterface & | handler | ) |
Installs callbacks from a borrowed contract-style handler.
The referenced handler must outlive the built server because installed callbacks delegate to it through a non-owning compatibility wrapper.
| ServerBuilder & mcp::server::ServerBuilder::with_handler | ( | std::shared_ptr< const ServerHandlerInterface > | handler | ) |
Installs callbacks from an owned contract-style handler.
The shared handler is retained by the built server callbacks.