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

Function count_in_response

tests/test_incremental.c:148–165  ·  view source on GitHub ↗

Parse integer from a tool response (handles the nested MCP envelope). * Matches the JSON forms "key":N / \"key\":N and the TOON scalar `key: N` * (search_graph default output since the compact-output change). */

Source from the content-addressed store, hash-verified

146 * Matches the JSON forms "key":N / \"key\":N and the TOON scalar `key: N`
147 * (search_graph default output since the compact-output change). */
148static int count_in_response(const char *resp, const char *key) {
149 if (!resp)
150 return -1;
151 char pattern[64];
152 snprintf(pattern, sizeof(pattern), "\"%s\":", key);
153 const char *p = strstr(resp, pattern);
154 if (p)
155 return atoi(p + strlen(pattern));
156 snprintf(pattern, sizeof(pattern), "\\\"%s\\\":", key);
157 p = strstr(resp, pattern);
158 if (p)
159 return atoi(p + strlen(pattern));
160 snprintf(pattern, sizeof(pattern), "%s: ", key);
161 p = strstr(resp, pattern);
162 if (p)
163 return atoi(p + strlen(pattern));
164 return -1;
165}
166
167/* ── Direct store queries (more reliable than MCP for tests) ────── */
168

Callers 3

has_functionFunction · 0.85
count_by_labelFunction · 0.85
test_incremental.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected