#include <Pt/Mcp/ToolDeclaration.h>

One MCP tool in a server declaration. More...

Inherits NonCopyable.

Public Member Functions

 Tool (const std::string &name, const std::string &description)
 Creates a tool named name with description.
 ~Tool ()
 Destroys the tool.
TooladdParam (const std::string &name, const Type &type, const std::string &description="")
 Adds a required parameter named name of type.
ToolsetOptional (const std::string &paramName)
 Marks the parameter named paramName as optional.
ToolsetContent (const ContentType &content)
 Sets the content type used to format the tool result.
const std::string & name () const
 Returns the tool name.
const std::string & description () const
 Returns the tool description.
const std::vector< Property > & params () const
 Returns the parameters of this tool.
std::size_t paramCount () const
 Returns the number of parameters.
int getParamIndex (const std::string &name) const
 Returns the index of the parameter named name, or -1.
const ContentTypecontent () const
 Returns the content type of the tool result.

Detailed Description

Tool is one callable in the catalog ToolDeclaration owns. The name is the MCP tool name and must match a procedure on the Pt::Remoting::ServiceDefinition. The description is what tools/list shows. addParam() appends a parameter whose name is the JSON member the client sends. Parameters are required until setOptional() is called with that name; a name that is not present is ignored.

setContent() selects the ContentType for the result. The default is textContent(). The content type and every parameter Type must outlive this tool. getParamIndex() maps a parameter name to its position, or -1 when the name is unknown. The tool is not copyable. Application code does not construct a Tool; it comes from ToolDeclaration::addTool().

Member Function Documentation

◆ addParam()

Tool & addParam ( const std::string & name,
const Type & type,
const std::string & description = "" )

description is the schema description of the parameter.