cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
authoring.hpp File Reference

High-level server authoring helpers and typed App builder adapters. More...

#include <cstdint>
#include <memory>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include "cxxmcp/config.hpp"
#include "cxxmcp/server/detail/handler_dispatch.hpp"
#include "cxxmcp/server/server.hpp"

Go to the source code of this file.

Classes

struct  mcp::server::TypedToolRegistration< Args, Result, Handler >
 Typed tool registration produced by mcp::server::tool(). More...
 
class  mcp::server::TypedToolBuilder< Args, Result >
 Fluent typed tool builder for low-boilerplate server authoring. More...
 
struct  mcp::server::TypedPromptRegistration< Args, Handler >
 Typed prompt registration produced by mcp::server::prompt(). More...
 
class  mcp::server::TypedPromptBuilder< Args >
 Fluent typed prompt builder for low-boilerplate server authoring. More...
 
struct  mcp::server::TypedResourceRegistration< Args, Handler >
 Typed resource registration produced by mcp::server::resource(). More...
 
class  mcp::server::TypedResourceBuilder< Args >
 Fluent typed resource builder for low-boilerplate server authoring. More...
 

Functions

template<class Args , class Result >
TypedToolBuilder< Args, Result > mcp::server::tool (std::string name)
 Starts a typed tool registration builder.
 
template<class Args >
TypedPromptBuilder< Args > mcp::server::prompt (std::string name)
 
template<class Args >
TypedPromptBuilder< Args > mcp::server::prompt (protocol::Prompt prompt)
 
template<class Args >
TypedResourceBuilder< Args > mcp::server::resource (std::string uri, std::string name)
 
template<class Args >
TypedResourceBuilder< Args > mcp::server::resource (protocol::Resource resource)
 
protocol::ResourceTemplateBuilder mcp::server::resource_template (std::string uri_template, std::string name)
 
class mcp::server::CXXMCP_DEPRECATED ("App is a compatibility entry point; use ServerPeer::builder() with " "cxxmcp/run.hpp instead") App
 Convenience entry point for compact server applications.
 

Detailed Description

High-level server authoring helpers and typed App builder adapters.

Function Documentation

◆ CXXMCP_DEPRECATED()

class mcp::server::CXXMCP_DEPRECATED ( "App is a compatibility entry point; use ServerPeer::builder() with " "cxxmcp/run.hpp instead"  )

Convenience entry point for compact server applications.

App::builder() exposes a higher-level builder that can create common transports and adapt simple C++ callables into MCP handlers.

Higher-level server builder with callable adapters.

Sets the advertised server name.

Sets the advertised server version.

Sets the advertised server instructions.

Adds a stdio server transport.

Adds a caller-supplied transport.

Parameters
valueTransport owned by the built server.

Enables server-side task processing for task-aware tools.

Installs an optional JSON Schema validator.

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.

Registers a typed callable using an explicit tool definition.

Registers a typed tool registration built by mcp::server::tool().

Registers a fully described tool and low-level 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.

Registers a fully described prompt and low-level 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.

Registers a fully described resource and low-level read 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.

Registers a fully described resource template.

Registers a completion request handler adapter.

Registers a sampling request handler adapter.

Registers a logging notification handler adapter.

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.

Builds the configured server.

Builds, starts, and runs the configured server application.

Creates a new convenience server builder.