diff --git a/src/main.c b/src/main.c index a58acdbb..100e32da 100644 --- a/src/main.c +++ b/src/main.c @@ -521,6 +521,7 @@ int main(int argc, char **argv) { * below opens sqlite early), else sqlite3_config returns SQLITE_MISUSE and * the bind is silently ignored. No-op in the test build. */ cbm_alloc_init(); + cbm_cli_set_version(CBM_VERSION); cbm_profile_init(); /* reads CBM_PROFILE env var, gates all prof macros */ /* CBM_LOG_LEVEL support — distilled from #414 (closes #413). Apply before * the first log statement so the configured level governs all output. */ diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c index 034e2e59..b6cd0075 100644 --- a/src/mcp/mcp.c +++ b/src/mcp/mcp.c @@ -657,7 +657,7 @@ char *cbm_mcp_initialize_response(const char *params_json) { yyjson_mut_val *impl = yyjson_mut_obj(doc); yyjson_mut_obj_add_str(doc, impl, "name", "codebase-memory-mcp"); - yyjson_mut_obj_add_str(doc, impl, "version", "0.10.0"); + yyjson_mut_obj_add_str(doc, impl, "version", cbm_cli_get_version()); yyjson_mut_obj_add_val(doc, root, "serverInfo", impl); yyjson_mut_val *caps = yyjson_mut_obj(doc); diff --git a/tests/test_mcp.c b/tests/test_mcp.c index d3bfbe65..056eb44d 100644 --- a/tests/test_mcp.c +++ b/tests/test_mcp.c @@ -7,6 +7,7 @@ #include "../src/foundation/compat_fs.h" /* cbm_unlink / cbm_rmdir */ #include "../src/foundation/log.h" #include "test_framework.h" +#include #include #include #include @@ -146,10 +147,13 @@ TEST(jsonrpc_format_error) { * ══════════════════════════════════════════════════════════════════ */ TEST(mcp_initialize_response) { + cbm_cli_set_version("9.8.7-test"); + /* Default (no params): returns latest supported version */ char *json = cbm_mcp_initialize_response(NULL); ASSERT_NOT_NULL(json); ASSERT_NOT_NULL(strstr(json, "codebase-memory-mcp")); + ASSERT_NOT_NULL(strstr(json, "\"version\":\"9.8.7-test\"")); ASSERT_NOT_NULL(strstr(json, "capabilities")); ASSERT_NOT_NULL(strstr(json, "tools")); ASSERT_NOT_NULL(strstr(json, "\"listChanged\":false")); @@ -172,6 +176,7 @@ TEST(mcp_initialize_response) { ASSERT_NOT_NULL(json); ASSERT_NOT_NULL(strstr(json, "2025-11-25")); free(json); + cbm_cli_set_version("dev"); PASS(); }