/** * @file custom_agent.h * @brief Example of a custom MCP agent */ #ifndef CUSTOM_AGENT_H #define CUSTOM_AGENT_H #include "mcp_tools.h" #include #include #include namespace examples { /** * @class echo_agent * @brief A simple agent that echoes back input with optional processing */ class echo_agent : public mcp::agent { public: /** * @brief Constructor * @param name The name of the agent */ explicit echo_agent(const std::string& name = "EchoAgent"); /** * @brief Initialize the agent * @param config Configuration parameters */ void initialize(const mcp::json& config) override; /** * @brief Process a request * @param input The input data * @return The processed output */ mcp::json process(const mcp::json& input) override; /** * @brief Enable or disable uppercase mode * @param enable If true, text will be converted to uppercase */ void set_uppercase(bool enable); /** * @brief Enable or disable prefixing * @param enable If true, text will be prefixed * @param prefix The prefix to add */ void set_prefix(bool enable, const std::string& prefix = "Echo: "); private: bool uppercase_enabled_ = false; bool prefix_enabled_ = false; std::string prefix_ = "Echo: "; int request_count_ = 0; }; /** * @class workflow_agent * @brief An agent that executes pre-defined workflows */ class workflow_agent : public mcp::agent { public: /** * @brief Constructor * @param name The name of the agent */ explicit workflow_agent(const std::string& name = "WorkflowAgent"); /** * @brief Initialize the agent * @param config Configuration parameters */ void initialize(const mcp::json& config) override; /** * @brief Process a request * @param input The input data * @return The processed output */ mcp::json process(const mcp::json& input) override; /** * @brief Register a workflow * @param workflow The workflow to register */ void register_workflow(const mcp::workflow& workflow); private: std::map workflows_; }; /** * @class chain_agent * @brief An agent that chains multiple tools together */ class chain_agent : public mcp::agent { public: /** * @brief Constructor * @param name The name of the agent */ explicit chain_agent(const std::string& name = "ChainAgent"); /** * @brief Initialize the agent * @param config Configuration parameters */ void initialize(const mcp::json& config) override; /** * @brief Process a request * @param input The input data * @return The processed output */ mcp::json process(const mcp::json& input) override; /** * @brief Add a tool to the chain * @param tool_name The name of the tool to add * @param output_to_input_map Map of output paths to input paths for next tool */ void add_tool(const std::string& tool_name, const std::map& output_to_input_map = {}); /** * @brief Clear the chain */ void clear_chain(); private: struct chain_step { std::string tool_name; std::map output_to_input_map; }; std::vector chain_; }; } // namespace examples #endif // CUSTOM_AGENT_H