cxxmcp 1.2.8
C++ MCP SDK
Loading...
Searching...
No Matches
mcp::server::App::Builder Class Reference

Higher-level server builder with callable adapters. More...

#include <authoring.hpp>

Public Member Functions

Buildername (std::string value)
 Sets the advertised server name.
 
Builderversion (std::string value)
 Sets the advertised server version.
 
Builderinstructions (std::string value)
 Sets the advertised server instructions.
 
Builderstdio ()
 Adds a stdio server transport.
 
Buildertransport (std::unique_ptr< Transport > value)
 Adds a caller-supplied transport.
 
Buildertasks (TaskOperationProcessorOptions options={})
 Enables server-side task processing for task-aware tools.
 
Builderschema_validator (std::shared_ptr< const JsonSchemaValidator > validator)
 Installs an optional JSON Schema validator.
 
template<class Args , class Result , class Handler >
Buildertool (std::string name, Handler handler)
 Registers a tool using a typed argument adapter.
 
template<class Args , class Result , class Handler >
Buildertool (protocol::ToolDefinition definition, Handler handler)
 Registers a typed callable using an explicit tool definition.
 
template<class Args , class Result , class Handler >
Buildertool (TypedToolRegistration< Args, Result, Handler > registration)
 Registers a typed tool registration built by mcp::server::tool().
 
Buildertool (protocol::ToolDefinition definition, ToolHandler handler)
 Registers a fully described tool and low-level handler.
 
template<class Args , class Handler >
Builderprompt (std::string name, Handler handler)
 Registers a prompt using a callable adapter.
 
template<class Handler >
Builderprompt (std::string name, Handler handler)
 
Builderprompt (protocol::Prompt prompt, PromptHandler handler)
 Registers a fully described prompt and low-level handler.
 
template<class Args , class Handler >
Builderresource (std::string name, Handler handler)
 Registers a resource using a callable adapter.
 
template<class Handler >
Builderresource (std::string name, Handler handler)
 
Builderresource (protocol::Resource resource, ResourceReadHandler handler)
 Registers a fully described resource and low-level read handler.
 
template<class Handler >
Builderresource_template (std::string name, Handler handler)
 Registers a resource template using a callable adapter.
 
Builderresource_template (protocol::ResourceTemplate resource_template)
 Registers a fully described resource template.
 
template<class Handler >
Buildercompletion (Handler handler)
 Registers a completion request handler adapter.
 
template<class Handler >
Buildersampling (Handler handler)
 Registers a sampling request handler adapter.
 
template<class Handler >
Builderlogging (Handler handler)
 Registers a logging notification handler adapter.
 
template<class Handler >
Builderraw_request (Handler handler)
 Registers a raw request hook adapter.
 
core::Result< std::unique_ptr< Server > > build ()
 Builds the configured server.
 
int run ()
 Builds, starts, and runs the configured server application.
 
template<class Args , class Result , class Handler >
App::Buildertool (std::string name, Handler handler)
 
template<class Args , class Result , class Handler >
App::Buildertool (protocol::ToolDefinition definition, Handler handler)
 
template<class Args , class Result , class Handler >
App::Buildertool (TypedToolRegistration< Args, Result, Handler > registration)
 
template<class Args , class Handler >
App::Builderprompt (std::string name, Handler handler)
 
template<class Handler >
App::Builderprompt (std::string name, Handler handler)
 
template<class Args , class Handler >
App::Builderresource (std::string name, Handler handler)
 
template<class Handler >
App::Builderresource (std::string name, Handler handler)
 
template<class Handler >
App::Builderresource_template (std::string name, Handler handler)
 
template<class Handler >
App::Buildercompletion (Handler handler)
 
template<class Handler >
App::Buildersampling (Handler handler)
 
template<class Handler >
App::Builderlogging (Handler handler)
 
template<class Handler >
App::Builderraw_request (Handler handler)
 

Detailed Description

Higher-level server builder with callable adapters.

Member Function Documentation

◆ prompt()

template<class Args , class Handler >
Builder & mcp::server::App::Builder::prompt ( std::string  name,
Handler  handler 
)

Registers a prompt using a callable adapter.

Parameters
namePrompt name advertised to clients.
handlerCallable accepting Json, string, PromptContext, one of the Json/string plus PromptContext combinations, or no argument. Returns prompt text/result or core::Result of either. CancellationToken may be accepted directly with Json/string where cooperative cancellation is useful.

◆ raw_request()

template<class Handler >
Builder & mcp::server::App::Builder::raw_request ( Handler  handler)

Registers a raw request hook adapter.

Note
A handler returning std::optional<JsonRpcResponse> or JsonRpcResponse controls dispatch; a void-returning handler only observes the request.

◆ resource()

template<class Args , class Handler >
Builder & mcp::server::App::Builder::resource ( std::string  name,
Handler  handler 
)

Registers a resource using a callable adapter.

Parameters
nameResource URI and default display name.
handlerCallable accepting Json params, requested URI string, ResourceContext, one of the Json/string plus ResourceContext combinations, or no argument. Returns resource text/contents/result, protocol::Resource metadata, or core::Result of these. CancellationToken may be accepted directly with Json/string where cooperative cancellation is useful.

◆ resource_template()

template<class Handler >
Builder & mcp::server::App::Builder::resource_template ( std::string  name,
Handler  handler 
)

Registers a resource template using a callable adapter.

Parameters
nameDefault resource-template name and URI template when the handler does not fill those fields.
handlerCallable returning a ResourceTemplate or core::Result<ResourceTemplate>.
Exceptions
std::runtime_errorif a Result-returning handler fails during registration.

◆ tool()

template<class Args , class Result , class Handler >
Builder & mcp::server::App::Builder::tool ( std::string  name,
Handler  handler 
)

Registers a tool using a typed argument adapter.

Template Parameters
ArgsType decoded from the JSON arguments object.
ResultExpected handler result type.
HandlerCallable invoked with Args.
Parameters
nameTool name advertised to clients.
handlerCallable returning Result or core::Result<Result>.
Returns
Reference to this builder for chaining.
Note
std::exception-derived errors thrown by argument decoding are caught and converted to InvalidParams results when the tool is invoked.

◆ transport()

Builder & mcp::server::App::Builder::transport ( std::unique_ptr< Transport value)

Adds a caller-supplied transport.

Parameters
valueTransport owned by the built server.

The documentation for this class was generated from the following file: