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

Function check_tool_output

tests/test_mcp.c:2386–2416  ·  view source on GitHub ↗

Run one tool call on the fixture server, apply the explosion detector and * an absolute byte ceiling, and require a semantic-floor marker so trimming * can never hollow the response out either. */

Source from the content-addressed store, hash-verified

2384 * an absolute byte ceiling, and require a semantic-floor marker so trimming
2385 * can never hollow the response out either. */
2386static const char *check_tool_output(cbm_mcp_server_t *srv, const char *req, int ceiling,
2387 const char *floor_marker) {
2388 char *resp = cbm_mcp_server_handle(srv, req);
2389 if (!resp) {
2390 return "no response";
2391 }
2392 char *inner = extract_text_content(resp);
2393 free(resp);
2394 if (!inner) {
2395 return "no text content";
2396 }
2397 static char why[256];
2398 const char *smell = output_explosion_smell(inner);
2399 if (smell) {
2400 snprintf(why, sizeof(why), "%s", smell);
2401 free(inner);
2402 return why;
2403 }
2404 if ((int)strlen(inner) >= ceiling) {
2405 snprintf(why, sizeof(why), "output %d B >= ceiling %d B", (int)strlen(inner), ceiling);
2406 free(inner);
2407 return why;
2408 }
2409 if (floor_marker && !strstr(inner, floor_marker)) {
2410 snprintf(why, sizeof(why), "semantic floor missing: %s", floor_marker);
2411 free(inner);
2412 return why;
2413 }
2414 free(inner);
2415 return NULL;
2416}
2417
2418TEST(tool_output_regression_gate) {
2419 char tmp[256];

Callers 1

test_mcp.cFile · 0.85

Calls 3

cbm_mcp_server_handleFunction · 0.85
extract_text_contentFunction · 0.85
output_explosion_smellFunction · 0.85

Tested by

no test coverage detected