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

Function application_tool_request

src/daemon/application.c:3164–3200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3162}
3163
3164static cbm_daemon_runtime_application_status_t application_tool_request(
3165 cbm_daemon_application_session_t *session, const uint8_t *request, uint32_t request_length,
3166 uint8_t **response_out, uint32_t *response_length_out) {
3167 if (!session->context_set || request_length <= APPLICATION_TOOL_HEADER_SIZE) {
3168 return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED;
3169 }
3170 uint32_t tool_length = application_get_u32(request + 1);
3171 if (tool_length == 0 || tool_length >= request_length - APPLICATION_TOOL_HEADER_SIZE) {
3172 return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED;
3173 }
3174 char *tool = application_text_copy(request + APPLICATION_TOOL_HEADER_SIZE, tool_length);
3175 uint32_t args_length = request_length - APPLICATION_TOOL_HEADER_SIZE - tool_length;
3176 char *args =
3177 application_text_copy(request + APPLICATION_TOOL_HEADER_SIZE + tool_length, args_length);
3178 if (!tool || !args) {
3179 free(tool);
3180 free(args);
3181 return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED;
3182 }
3183 session->one_shot_request = true; /* only this request thread reads it */
3184 char *response = cbm_mcp_handle_tool(session->mcp, tool, args);
3185 session->one_shot_request = false;
3186 free(tool);
3187 free(args);
3188 if (!response) {
3189 return CBM_DAEMON_RUNTIME_APPLICATION_HANDLER_ERROR;
3190 }
3191 size_t response_length = strlen(response);
3192 if (response_length > UINT32_MAX) {
3193 free(response);
3194 return CBM_DAEMON_RUNTIME_APPLICATION_HANDLER_ERROR;
3195 }
3196 *response_out = (uint8_t *)response;
3197 *response_length_out = (uint32_t)response_length;
3198 application_refresh_watch(session);
3199 return CBM_DAEMON_RUNTIME_APPLICATION_OK;
3200}
3201
3202static cbm_daemon_runtime_application_status_t application_set_ui_config(
3203 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