Skip to content

Commit 20a19f8

Browse files
committed
Add tools/list request
1 parent b67a04c commit 20a19f8

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

common/toolcall/mcp_messages.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,23 @@ mcp::initialize_response mcp::initialize_response::fromJson(const nlohmann::json
179179

180180
return initialize_response(j["id"], name, version, protoVersion, caps);
181181
}
182+
183+
mcp::tools_list_request::tools_list_request(std::optional<nlohmann::json> id, std::string cursor)
184+
: request(id, "tools/list"),
185+
cursor_(std::move(cursor))
186+
{
187+
refreshParams();
188+
}
189+
190+
void mcp::tools_list_request::cursor(std::string cursor) {
191+
cursor_ = std::move(cursor);
192+
refreshParams();
193+
}
194+
195+
void mcp::tools_list_request::refreshParams() {
196+
if (! cursor_.empty()) {
197+
json params;
198+
params["cursor"] = cursor_;
199+
this->params(params);
200+
}
201+
}

common/toolcall/mcp_messages.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ namespace mcp
165165

166166
class initialized_notification : public notification {
167167
public:
168-
initialized_notification() : notification("notifications/initialized") {}
168+
initialized_notification()
169+
: notification("notifications/initialized") {}
170+
};
171+
172+
class tools_list_request : public request {
173+
public:
174+
tools_list_request(std::optional<nlohmann::json> id, std::string cursor = "");
175+
176+
void cursor(std::string cursor);
177+
const std::string & cursor() { return cursor_; }
178+
179+
private:
180+
void refreshParams();
181+
std::string cursor_;
169182
};
170183
}

0 commit comments

Comments
 (0)