MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / mcp_tools_cursor_offset

Function mcp_tools_cursor_offset

src/mcp/mcp.c:1206–1242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1204}
1205
1206static 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
1244static char *cbm_mcp_tools_list_page(cbm_mcp_tool_profile_t profile, const char *params_json) {
1245 bool has_cursor = false;

Callers 1

cbm_mcp_tools_list_pageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected