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

Function count_in_response

tests/test_incremental.c:134–151  ·  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

132 * Matches the JSON forms "key":N / \"key\":N and the TOON scalar `key: N`
133 * (search_graph default output since the compact-output change). */
134static int count_in_response(const char *resp, const char *key) {
135 if (!resp)
136 return -1;
137 char pattern[64];
138 snprintf(pattern, sizeof(pattern), "\"%s\":", key);
139 const char *p = strstr(resp, pattern);
140 if (p)
141 return atoi(p + strlen(pattern));
142 snprintf(pattern, sizeof(pattern), "\\\"%s\\\":", key);
143 p = strstr(resp, pattern);
144 if (p)
145 return atoi(p + strlen(pattern));
146 snprintf(pattern, sizeof(pattern), "%s: ", key);
147 p = strstr(resp, pattern);
148 if (p)
149 return atoi(p + strlen(pattern));
150 return -1;
151}
152
153/* ── Direct store queries (more reliable than MCP for tests) ────── */
154

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