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

Function application_tool_request

src/daemon/application.c:2472–2506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2470}
2471
2472static cbm_daemon_runtime_application_status_t application_tool_request(
2473 cbm_daemon_application_session_t *session, const uint8_t *request, uint32_t request_length,
2474 uint8_t **response_out, uint32_t *response_length_out) {
2475 if (!session->context_set || request_length <= APPLICATION_TOOL_HEADER_SIZE) {
2476 return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED;
2477 }
2478 uint32_t tool_length = application_get_u32(request + 1);
2479 if (tool_length == 0 || tool_length >= request_length - APPLICATION_TOOL_HEADER_SIZE) {
2480 return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED;
2481 }
2482 char *tool = application_text_copy(request + APPLICATION_TOOL_HEADER_SIZE, tool_length);
2483 uint32_t args_length = request_length - APPLICATION_TOOL_HEADER_SIZE - tool_length;
2484 char *args =
2485 application_text_copy(request + APPLICATION_TOOL_HEADER_SIZE + tool_length, args_length);
2486 if (!tool || !args) {
2487 free(tool);
2488 free(args);
2489 return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED;
2490 }
2491 char *response = cbm_mcp_handle_tool(session->mcp, tool, args);
2492 free(tool);
2493 free(args);
2494 if (!response) {
2495 return CBM_DAEMON_RUNTIME_APPLICATION_HANDLER_ERROR;
2496 }
2497 size_t response_length = strlen(response);
2498 if (response_length > UINT32_MAX) {
2499 free(response);
2500 return CBM_DAEMON_RUNTIME_APPLICATION_HANDLER_ERROR;
2501 }
2502 *response_out = (uint8_t *)response;
2503 *response_length_out = (uint32_t)response_length;
2504 application_refresh_watch(session);
2505 return CBM_DAEMON_RUNTIME_APPLICATION_OK;
2506}
2507
2508static cbm_daemon_runtime_application_status_t application_set_ui_config(
2509 cbm_daemon_application_t *application, cbm_daemon_application_session_t *session,

Callers 1

Calls 4

application_get_u32Function · 0.85
application_text_copyFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85

Tested by

no test coverage detected