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

Function handle_atlas_why

src/ui/http_server.c:2843–2864  ·  view source on GitHub ↗

GET /api/why?project=X&id=N|qn=Q&dir=up|down — the trigger tree. */

Source from the content-addressed store, hash-verified

2841
2842/* GET /api/why?project=X&id=N|qn=Q&dir=up|down — the trigger tree. */
2843static void handle_atlas_why(cbm_http_conn_t *c, const cbm_http_req_t *req) {
2844 char project[256] = {0};
2845 cbm_store_t *store = atlas_open_project(c, req, project, sizeof(project));
2846 if (!store)
2847 return;
2848 char idbuf[32] = {0};
2849 char qn[1024] = {0};
2850 char dir[8] = {0};
2851 cbm_http_query_param(req->query, "id", idbuf, (int)sizeof(idbuf));
2852 cbm_http_query_param(req->query, "qn", qn, (int)sizeof(qn));
2853 cbm_http_query_param(req->query, "dir", dir, (int)sizeof(dir));
2854 if (!idbuf[0] && !qn[0]) {
2855 cbm_store_close(store);
2856 cbm_http_replyf(c, 400, g_cors_json, "{\"error\":\"missing id or qn parameter\"}");
2857 return;
2858 }
2859 int64_t id = idbuf[0] ? strtoll(idbuf, NULL, 10) : -1;
2860 bool upward = strcmp(dir, "down") != 0;
2861 char *json = cbm_atlas_why_json(store, project, id, qn[0] ? qn : NULL, upward);
2862 cbm_store_close(store);
2863 atlas_reply_json(c, json, 404, "{\"error\":\"symbol not found\"}");
2864}
2865
2866/* GET /api/handout?project=X — the self-contained newcomer document. */
2867static void handle_atlas_handout(cbm_http_conn_t *c, const cbm_http_req_t *req) {

Callers 1

dispatch_requestFunction · 0.85

Calls 6

atlas_open_projectFunction · 0.85
cbm_http_query_paramFunction · 0.85
cbm_store_closeFunction · 0.85
cbm_http_replyfFunction · 0.85
cbm_atlas_why_jsonFunction · 0.85
atlas_reply_jsonFunction · 0.85

Tested by

no test coverage detected