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

Function cbm_build_json_mcp_entry

src/cli/cli.c:1552–1582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1550static const char CBM_SCOUT_PROFILE_ARGUMENT[] = "--tool-profile=scout";
1551
1552static char *cbm_build_json_mcp_entry(const char *binary_path, cbm_json_mcp_schema_t schema,
1553 const char *argument) {
1554 yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL);
1555 if (!doc) {
1556 return NULL;
1557 }
1558 yyjson_mut_val *root = yyjson_mut_obj(doc);
1559 bool command_is_array = cbm_json_mcp_command_is_array(schema);
1560 yyjson_mut_val *command =
1561 command_is_array ? yyjson_mut_arr(doc) : yyjson_mut_strcpy(doc, binary_path);
1562 bool ok = root && command;
1563 if (ok && command_is_array) {
1564 ok = yyjson_mut_arr_add_strcpy(doc, command, binary_path);
1565 }
1566 if (ok) {
1567 yyjson_mut_doc_set_root(doc, root);
1568 ok = yyjson_mut_obj_add_val(doc, root, "command", command);
1569 }
1570 if (ok && !command_is_array) {
1571 yyjson_mut_val *args = yyjson_mut_arr(doc);
1572 ok = args && (!argument || yyjson_mut_arr_add_strcpy(doc, args, argument)) &&
1573 yyjson_mut_obj_add_val(doc, root, "args", args);
1574 }
1575 const char *type = cbm_json_mcp_required_type(schema);
1576 if (ok && type) {
1577 ok = yyjson_mut_obj_add_strcpy(doc, root, "type", type);
1578 }
1579 char *json = ok ? yyjson_mut_write(doc, YYJSON_WRITE_NOFLAG, NULL) : NULL;
1580 yyjson_mut_doc_free(doc);
1581 return json;
1582}
1583
1584static size_t cbm_json_mcp_ownership_fields(cbm_json_mcp_schema_t schema, const char *argument,
1585 cbm_json_like_object_field_t fields[3]) {

Callers 1

Calls 2

Tested by

no test coverage detected