diff options
Diffstat (limited to 'src/mcp/tools/common/context.c')
| -rw-r--r-- | src/mcp/tools/common/context.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/mcp/tools/common/context.c b/src/mcp/tools/common/context.c index 1a469e0..d79b5de 100644 --- a/src/mcp/tools/common/context.c +++ b/src/mcp/tools/common/context.c @@ -42,8 +42,11 @@ tiny_mcp_tools_context_new(tiny_store_t *store) } context->store = store; context->search_index = tiny_mcp_tools_build_search_index(store); - if (!context->search_index) + context->history_index = tiny_history_index_build(store); + if (!context->search_index || !context->history_index) { + tiny_search_index_free(context->search_index); + tiny_history_index_free(context->history_index); free(context); return NULL; } @@ -58,6 +61,7 @@ tiny_mcp_tools_context_free(tiny_mcp_tools_context_t *context) return; } tiny_search_index_free(context->search_index); + tiny_history_index_free(context->history_index); free(context); } @@ -86,3 +90,17 @@ tiny_mcp_tools_context_current(void) { return active_context; } + +bool +tiny_mcp_tools_ensure_history_index(tiny_mcp_tools_context_t *context) +{ + if (!context) + { + return false; + } + if (!context->history_index) + { + context->history_index = tiny_history_index_build(context->store); + } + return context->history_index != NULL; +} |
