cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
mcp::server::PromptRegistry Class Reference

Registry of named MCP prompts and their handlers. More...

#include <registry.hpp>

Public Member Functions

 PromptRegistry (const PromptRegistry &other)
 
PromptRegistryoperator= (const PromptRegistry &other)
 
 PromptRegistry (PromptRegistry &&other) noexcept
 
PromptRegistryoperator= (PromptRegistry &&other) noexcept
 
core::Result< core::Unitadd (protocol::Prompt prompt, PromptHandler handler)
 Register a prompt definition and handler.
 
core::Result< protocol::PromptsGetResultget (std::string_view name, protocol::Json arguments, const std::string &session_id) const
 Render a prompt with only a session id.
 
core::Result< protocol::PromptsGetResultget (std::string_view name, protocol::Json arguments, const SessionContext &session_context) const
 Render a prompt with full session metadata.
 
core::Result< protocol::PromptsGetResultget (std::string_view name, protocol::Json arguments, const SessionContext &session_context, CancellationToken cancellation) const
 
std::vector< protocol::Promptlist () const
 Return registered prompt definitions sorted by name.
 

Detailed Description

Registry of named MCP prompts and their handlers.

PromptRegistry owns prompt metadata and handler callables. Handler invocation is synchronous, copied under the registry lock, invoked outside the lock, and errors are returned to the caller without translation.

Member Function Documentation

◆ add()

core::Result< core::Unit > mcp::server::PromptRegistry::add ( protocol::Prompt  prompt,
PromptHandler  handler 
)

Register a prompt definition and handler.

Returns
core::Unit on success, or InvalidRequest for invalid name, duplicate name, or empty handler.

◆ get()

core::Result< protocol::PromptsGetResult > mcp::server::PromptRegistry::get ( std::string_view  name,
protocol::Json  arguments,
const SessionContext session_context 
) const

Render a prompt with full session metadata.

Returns
Handler result, an error when the prompt is not registered, or the handler's own error.

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