diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-07-04 16:22:35 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-07-04 16:22:35 +0900 |
| commit | eb5e9d9f37bda7d78f69614da70402357794168a (patch) | |
| tree | 608dd61d8b4ca989df505e9777a8b95f4f17b06d /src/mcp/tools/read_messages.c | |
| parent | 1a6a2e7f8572415d435c056dc9947d6d08eb1862 (diff) | |
feat(P1-002): add offline JSONL import via import_messages MCP tool
- implement `import_messages` MCP tool parsing manifest + PUT/DEL JSONL
- atomic store replacement under lock with overwrite/reject conflict policies
- add `include_deleted` to read_messages export view for full round-trip
- register new tool in MCP registry and update protocol test expectations
- update docs/development-plan.md and docs/implementation-status.md
Debug/Release/ASan 15/15 CTest pass
Diffstat (limited to 'src/mcp/tools/read_messages.c')
| -rw-r--r-- | src/mcp/tools/read_messages.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mcp/tools/read_messages.c b/src/mcp/tools/read_messages.c index 079e6eb..647e6f3 100644 --- a/src/mcp/tools/read_messages.c +++ b/src/mcp/tools/read_messages.c @@ -734,6 +734,8 @@ call_export_view(tiny_mcp_tools_context_t *context, const mcpc_tool_t *tool, mcp char *session = tiny_mcp_tool_get_string(tool, "session_id", TINY_SESSION_ID_MAX); char *cursor = tiny_mcp_tool_get_string(tool, "cursor", CURSOR_TEXT_MAX); int32_t limit = 500; + char *include_deleted_text = tiny_mcp_tool_get_string(tool, "include_deleted", 8); + bool include_deleted = include_deleted_text && strcmp(include_deleted_text, "true") == 0; bool valid; size_t index = simple_cursor(cursor, &valid), emitted = 0, start_index; tiny_json_buffer_t json, lines; @@ -759,13 +761,22 @@ call_export_view(tiny_mcp_tools_context_t *context, const mcpc_tool_t *tool, mcp const tiny_store_entry_t *entry = tiny_store_entry(context->store, index); tiny_json_buffer_t item; size_t line_overhead; - if (!entry || entry->deleted + if (!entry || (entry->deleted && !include_deleted) || (session && session[0] && strcmp(session, entry->message.session_id) != 0)) { continue; } tiny_json_init(&item); - tiny_mcp_tool_append_message(&item, &entry->message); + if (entry->deleted) + { + tiny_json_raw(&item, "{\"type\":\"DEL\",\"message_id\":"); + tiny_json_string(&item, entry->message.message_id); + tiny_json_raw(&item, "}"); + } + else + { + tiny_mcp_tool_append_message(&item, &entry->message); + } line_overhead = item.length + 1; if (item.failed || outer_size + lines.length + line_overhead + 2 > READ_RESPONSE_BUDGET) { @@ -1011,5 +1022,11 @@ tiny_mcp_register_read_messages(mcpc_server_t *server) "omit for the first page.", MCPC_U8STR, false) + && tiny_mcp_tool_add_property(tool, + "include_deleted", + "When true, export view includes deleted records as DEL " + "lines; other views ignore this option.", + MCPC_U8STR, + false) && mcpc_server_add_tool(server, tool) == MCPC_EC_0; } |
