Agents 1.6.9
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::MCPTool Class Reference

Interface for tools that an agent can use. More...

#include <tool.h>

Inheritance diagram for agents::MCPTool:
agents::Tool

Public Member Functions

 MCPTool (const std::string &name, const std::string &description, const mcpConfig &config)
 Construct a new MCPTool object.
 MCPTool (const std::string &name, const std::string &description, const JsonObject &parameters, const std::shared_ptr< mcp::client > &client)
 Construct a new MCPTool object.
 MCPTool (const std::string &name, const std::string &description, const JsonObject &parameters, const mcpConfig &config)
 Construct a new MCPTool object.
ToolResult execute (const JsonObject &params) const override
 Execute the MCP tool with the given parameters.
const std::string & getName () const
 Get the name of the tool.
const std::string & getDescription () const
 Get the description of the tool.
const ParameterMap & getParameters () const
 Get the parameters of the tool.
const JsonObject & getSchema () const
 Get the schema of the tool.
void addParameter (const Parameter &param)
 Add a parameter to the tool.
void addParametersFromJson (const JsonObject &params)
 Add tool parameters from json definition.
void setCallback (ToolCallback callback)
 Set the execution callback.
virtual double scoreRelevance (const std::string &query) const
 Score the relevance of this tool to a given query.
bool validateParameters (const JsonObject &params) const
 Validate parameters against schema.

Static Public Member Functions

static std::shared_ptr< mcp::client > createClient (const mcpConfig &config)
 Create an MCP client object.

Detailed Description

Interface for tools that an agent can use.

Constructor & Destructor Documentation

◆ MCPTool() [1/3]

agents::MCPTool::MCPTool ( const std::string & name,
const std::string & description,
const mcpConfig & config )

Construct a new MCPTool object.

Parameters
nameThe name of the tool
descriptionThe description of the tool
configThe mcp client config

◆ MCPTool() [2/3]

agents::MCPTool::MCPTool ( const std::string & name,
const std::string & description,
const JsonObject & parameters,
const std::shared_ptr< mcp::client > & client )

Construct a new MCPTool object.

Parameters
nameThe name of the tool
descriptionThe description of the tool
parametersThe json parameters of the tool
clientThe mcp client

◆ MCPTool() [3/3]

agents::MCPTool::MCPTool ( const std::string & name,
const std::string & description,
const JsonObject & parameters,
const mcpConfig & config )

Construct a new MCPTool object.

Parameters
nameThe name of the tool
descriptionThe description of the tool
parametersThe json parameters of the tool
configThe mcp client config

Member Function Documentation

◆ addParameter()

void agents::Tool::addParameter ( const Parameter & param)
inherited

Add a parameter to the tool.

Parameters
paramThe parameter to add

◆ addParametersFromJson()

void agents::Tool::addParametersFromJson ( const JsonObject & params)
inherited

Add tool parameters from json definition.

Parameters
paramsThe parameters to add

◆ createClient()

std::shared_ptr< mcp::client > agents::MCPTool::createClient ( const mcpConfig & config)
static

Create an MCP client object.

Parameters
server_namemcp client name
configmcp client config
Returns
std::shared_ptr<mcp::client> Pointer to mcp client

◆ execute()

ToolResult agents::MCPTool::execute ( const JsonObject & params) const
overridevirtual

Execute the MCP tool with the given parameters.

Parameters
paramsThe parameters to execute the tool with
Returns
The result of the tool execution

Reimplemented from agents::Tool.

◆ getDescription()

const std::string & agents::Tool::getDescription ( ) const
inherited

Get the description of the tool.

Returns
The description of the tool

◆ getName()

const std::string & agents::Tool::getName ( ) const
inherited

Get the name of the tool.

Returns
The name of the tool

◆ getParameters()

const ParameterMap & agents::Tool::getParameters ( ) const
inherited

Get the parameters of the tool.

Returns
The parameters of the tool

◆ getSchema()

const JsonObject & agents::Tool::getSchema ( ) const
inherited

Get the schema of the tool.

Returns
The schema of the tool

◆ scoreRelevance()

virtual double agents::Tool::scoreRelevance ( const std::string & query) const
virtualinherited

Score the relevance of this tool to a given query.

Parameters
queryThe query to score against
Returns
double Relevance score (0.0 to 1.0)

Reimplemented in agents::skills::MarkdownSkillTool.

◆ setCallback()

void agents::Tool::setCallback ( ToolCallback callback)
inherited

Set the execution callback.

Parameters
callbackThe callback to set

◆ validateParameters()

bool agents::Tool::validateParameters ( const JsonObject & params) const
inherited

Validate parameters against schema.

Parameters
paramsThe parameters to validate
Returns
true of valid, otherwise false