@@ -199,3 +199,60 @@ void mcp::tools_list_request::refreshParams() {
199199 this ->params (params);
200200 }
201201}
202+
203+ mcp::tools_list_response::tools_list_response (nlohmann::json id,
204+ mcp::tools_list tools,
205+ std::string next_cursor)
206+ : response(id),
207+ tools_(std::move(tools)),
208+ next_cursor_(std::move(next_cursor))
209+ {
210+ refreshResult ();
211+ }
212+
213+ void mcp::tools_list_response::tools (mcp::tools_list tools) {
214+ tools_ = std::move (tools);
215+ refreshResult ();
216+ }
217+
218+ void mcp::tools_list_response::next_cursor (std::string next_cursor) {
219+ next_cursor_ = std::move (next_cursor);
220+ refreshResult ();
221+ }
222+
223+ void mcp::tools_list_response::refreshResult () {
224+ json result;
225+
226+ json tools = json::array ();
227+ for (const auto & tool : tools_) {
228+ json t;
229+
230+ t[" name" ] = tool.tool_name ;
231+ t[" description" ] = tool.tool_description ;
232+ t[" inputSchema" ][" type" ] = " object" ;
233+
234+ json props;
235+ for (const auto & param : tool.params ) {
236+ props[param.name ] = {
237+ {" type" }, {param.type },
238+ {" description" }, {param.description }
239+ };
240+ }
241+ t[" inputSchema" ][" properties" ] = props;
242+
243+ json required = json::array ();
244+ for (const auto & req_param : tool.required_params ) {
245+ required.push_back (req_param);
246+ }
247+ t[" inputSchema" ][" required" ] = required;
248+
249+ tools.push_back (t);
250+ }
251+ result[" tools" ] = tools;
252+
253+ if (! next_cursor_.empty ()) {
254+ result[" nextCursor" ] = next_cursor_;
255+ }
256+
257+ this ->result (result);
258+ }
0 commit comments