feat: add chat history MCP tools #1

Merged
warkanum merged 2 commits from feature/chat-history into main 2026-04-01 14:15:19 +00:00
Member

Summary

Adds four new MCP tools for saving and retrieving agent chat histories.

New tools

Tool Description
save_chat_history Save a session's messages with optional title, summary, channel, agent, project
get_chat_history Retrieve by UUID or session_id
list_chat_histories List with filters: project, channel, agent_id, session_id, days
delete_chat_history Hard-delete by UUID

Changes

  • migrations/018_chat_histories.sql — new chat_histories table with indexes on session_id, project_id, channel, agent_id, created_at, and FTS over title+summary
  • internal/types/extensions.goChatMessage and ChatHistory types
  • internal/store/chat_histories.go — store layer
  • internal/tools/chat_history.go — MCP tool handlers
  • internal/mcpserver/server.go — tool registration
  • internal/app/app.go — wiring

Usage example

save_chat_history(session_id="telegram:123", channel="telegram", agent_id="claude", messages=[...], summary="Discussed AMCS feature work")
get_chat_history(session_id="telegram:123")
list_chat_histories(channel="telegram", days=7)
## Summary Adds four new MCP tools for saving and retrieving agent chat histories. ## New tools | Tool | Description | |------|-------------| | `save_chat_history` | Save a session's messages with optional title, summary, channel, agent, project | | `get_chat_history` | Retrieve by UUID or session_id | | `list_chat_histories` | List with filters: project, channel, agent_id, session_id, days | | `delete_chat_history` | Hard-delete by UUID | ## Changes - `migrations/018_chat_histories.sql` — new `chat_histories` table with indexes on session_id, project_id, channel, agent_id, created_at, and FTS over title+summary - `internal/types/extensions.go` — `ChatMessage` and `ChatHistory` types - `internal/store/chat_histories.go` — store layer - `internal/tools/chat_history.go` — MCP tool handlers - `internal/mcpserver/server.go` — tool registration - `internal/app/app.go` — wiring ## Usage example ``` save_chat_history(session_id="telegram:123", channel="telegram", agent_id="claude", messages=[...], summary="Discussed AMCS feature work") get_chat_history(session_id="telegram:123") list_chat_histories(channel="telegram", days=7) ```
sam added 1 commit 2026-04-01 14:07:11 +00:00
Adds save/get/list/delete tools for persisting and retrieving agent
chat histories in AMCS.

Changes:
- migrations/018_chat_histories.sql: new chat_histories table with
  indexes on session_id, project_id, channel, agent_id, created_at,
  and FTS over title+summary
- internal/types/extensions.go: ChatMessage and ChatHistory types
- internal/store/chat_histories.go: SaveChatHistory, GetChatHistory,
  GetChatHistoryBySessionID, ListChatHistories, DeleteChatHistory
- internal/tools/chat_history.go: ChatHistoryTool with four handlers
  (save_chat_history, get_chat_history, list_chat_histories,
  delete_chat_history)
- internal/mcpserver/server.go: ChatHistory field in ToolSet,
  registerChatHistoryTools registration function
- internal/app/app.go: wire ChatHistoryTool into ToolSet
warkanum requested changes 2026-04-01 14:11:23 +00:00
warkanum left a comment
Owner

There are a few changes you need to do. Make sure to look at migrations/100_rls_and_grants.sql and add the permission for new tables there

There are a few changes you need to do. Make sure to look at migrations/100_rls_and_grants.sql and add the permission for new tables there
@@ -0,0 +23,4 @@
CREATE INDEX IF NOT EXISTS idx_chat_histories_fts
ON chat_histories
USING GIN (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(summary, '')));
Owner

You need to add

GRANT ALL ON TABLE public.chat_histories TO amcs;

You need to add GRANT ALL ON TABLE public.chat_histories TO amcs;
sam added 1 commit 2026-04-01 14:12:14 +00:00
Author
Member

Good catch — added GRANT ALL ON TABLE public.chat_histories TO amcs; to migrations/100_rls_and_grants.sql in the latest commit.

Good catch — added `GRANT ALL ON TABLE public.chat_histories TO amcs;` to `migrations/100_rls_and_grants.sql` in the latest commit.
warkanum merged commit 4fdd1411b2 into main 2026-04-01 14:15:19 +00:00
Sign in to join this conversation.