diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-06-29 21:43:54 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-06-30 01:23:51 +0900 |
| commit | 4bc721c3bf7589b519c5730d093f704ce56e3f09 (patch) | |
| tree | 38da055ab15fd70f5c92584560ea73486e5ddce0 /src/mcp/tools/get_system_health.c | |
| parent | 4c6a831aa2a57e2bcc20aa3fc2f1b7172f5be285 (diff) | |
refactor: MCP層をmcpc APIベースに刷新
- 独自JSON-RPC処理をmcpcへ置き換え
- 各MCPツールを個別ソースへ分離
- 共通コンテキストと登録処理を整理
- mcpc互換修正と統合テストを更新
Diffstat (limited to 'src/mcp/tools/get_system_health.c')
| -rw-r--r-- | src/mcp/tools/get_system_health.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/mcp/tools/get_system_health.c b/src/mcp/tools/get_system_health.c new file mode 100644 index 0000000..eb02090 --- /dev/null +++ b/src/mcp/tools/get_system_health.c @@ -0,0 +1,49 @@ +#include "mcp/tools/common/registry.h" + +#include "mcp/tools/common/common.h" +#include "mcp/tools/common/context.h" + +static void +call_get_system_health(const mcpc_tool_t *tool, mcpc_ucbr_t *result) +{ + tiny_mcp_tools_context_t *context = tiny_mcp_tools_context_current(); + tiny_store_health_t health; + tiny_json_buffer_t json; + (void)tool; + if (!context) + { + tiny_mcp_tool_add_error(result, "INTERNAL_ERROR", "tool context is unavailable"); + return; + } + tiny_store_health(context->store, &health); + tiny_json_init(&json); + tiny_json_raw(&json, "{\"status\":"); + tiny_json_string(&json, health.last_error[0] ? "DEGRADED" : "OK"); + tiny_json_raw(&json, ",\"format_version\":1,\"log_size\":"); + tiny_json_u64(&json, health.log_size); + tiny_json_raw(&json, ",\"snapshot_size\":"); + tiny_json_u64(&json, health.snapshot_size); + tiny_json_raw(&json, ",\"active_messages\":"); + tiny_json_u64(&json, health.active_messages); + tiny_json_raw(&json, ",\"deleted_messages\":"); + tiny_json_u64(&json, health.deleted_messages); + tiny_json_raw(&json, ",\"last_sequence\":"); + tiny_json_u64(&json, health.last_sequence); + tiny_json_raw(&json, ",\"recovered_tail\":"); + tiny_json_raw(&json, health.recovered_tail ? "true" : "false"); + tiny_json_raw(&json, ",\"snapshot_valid\":"); + tiny_json_raw(&json, health.snapshot_valid ? "true" : "false"); + tiny_json_raw(&json, ",\"last_error\":"); + tiny_json_string(&json, health.last_error); + tiny_json_raw(&json, "}"); + tiny_mcp_tool_add_json(result, &json); + tiny_json_free(&json); +} + +bool +tiny_mcp_register_get_system_health(mcpc_server_t *server) +{ + mcpc_tool_t *tool + = tiny_mcp_tool_new("get_system_health", "Report storage health", call_get_system_health); + return tool && mcpc_server_add_tool(server, tool) == MCPC_EC_0; +} |
