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

Function check_tool_output

tests/test_mcp.c:4131–4161  ·  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

4129 * an absolute byte ceiling, and require a semantic-floor marker so trimming
4130 * can never hollow the response out either. */
4131static const char *check_tool_output(cbm_mcp_server_t *srv, const char *req, int ceiling,
4132 const char *floor_marker) {
4133 char *resp = cbm_mcp_server_handle(srv, req);
4134 if (!resp) {
4135 return "no response";
4136 }
4137 char *inner = extract_text_content(resp);
4138 free(resp);
4139 if (!inner) {
4140 return "no text content";
4141 }
4142 static char why[256];
4143 const char *smell = output_explosion_smell(inner);
4144 if (smell) {
4145 snprintf(why, sizeof(why), "%s", smell);
4146 free(inner);
4147 return why;
4148 }
4149 if ((int)strlen(inner) >= ceiling) {
4150 snprintf(why, sizeof(why), "output %d B >= ceiling %d B", (int)strlen(inner), ceiling);
4151 free(inner);
4152 return why;
4153 }
4154 if (floor_marker && !strstr(inner, floor_marker)) {
4155 snprintf(why, sizeof(why), "semantic floor missing: %s", floor_marker);
4156 free(inner);
4157 return why;
4158 }
4159 free(inner);
4160 return NULL;
4161}
4162
4163TEST(tool_output_regression_gate) {
4164 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