| 1204 | } |
| 1205 | |
| 1206 | static int mcp_tools_cursor_offset(const char *params_json, bool *has_cursor_out) { |
| 1207 | if (has_cursor_out) { |
| 1208 | *has_cursor_out = false; |
| 1209 | } |
| 1210 | if (!params_json) { |
| 1211 | return 0; |
| 1212 | } |
| 1213 | |
| 1214 | yyjson_doc *doc = yyjson_read(params_json, strlen(params_json), 0); |
| 1215 | if (!doc) { |
| 1216 | return 0; |
| 1217 | } |
| 1218 | |
| 1219 | int offset = 0; |
| 1220 | yyjson_val *root = yyjson_doc_get_root(doc); |
| 1221 | yyjson_val *cursor = root ? yyjson_obj_get(root, "cursor") : NULL; |
| 1222 | if (cursor) { |
| 1223 | if (has_cursor_out) { |
| 1224 | *has_cursor_out = true; |
| 1225 | } |
| 1226 | offset = TOOL_COUNT; |
| 1227 | if (yyjson_is_str(cursor)) { |
| 1228 | const char *cursor_str = yyjson_get_str(cursor); |
| 1229 | if (cursor_str && *cursor_str != '\0') { |
| 1230 | char *endptr = NULL; |
| 1231 | errno = 0; |
| 1232 | long parsed = strtol(cursor_str, &endptr, 10); |
| 1233 | if (endptr && *endptr == '\0' && errno == 0 && parsed >= 0) { |
| 1234 | offset = parsed > TOOL_COUNT ? TOOL_COUNT : (int)parsed; |
| 1235 | } |
| 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | yyjson_doc_free(doc); |
| 1241 | return offset; |
| 1242 | } |
| 1243 | |
| 1244 | static char *cbm_mcp_tools_list_page(cbm_mcp_tool_profile_t profile, const char *params_json) { |
| 1245 | bool has_cursor = false; |
no outgoing calls
no test coverage detected