#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. | |
| Tool & | addParam (const std::string &name, const Type &type, const std::string &description="") |
| Adds a required parameter named name of type. | |
| Tool & | setOptional (const std::string ¶mName) |
| Marks the parameter named paramName as optional. | |
| Tool & | setContent (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 ContentType & | content () const |
| Returns the content type of the tool result. | |
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().