Add optional completion tracking tools for idempotent session-start checks#14
Open
partymola wants to merge 2 commits into
Open
Add optional completion tracking tools for idempotent session-start checks#14partymola wants to merge 2 commits into
partymola wants to merge 2 commits into
Conversation
Adds two new MCP tools backed by a local SQLite store to solve the
problem of agents re-processing already-handled completed tasks on
every session start.
ticktick_get_unprocessed_completions(project_id, days=30)
- Fetches completed tasks in the given window via the TickTick API
- Filters out task IDs already in the local DB
- Returns only the delta (new completions not yet seen)
ticktick_mark_completion_processed(task_id, project_id, ...)
- Records a task as processed in the SQLite store
- Subsequent calls to get_unprocessed_completions will skip it
- Stores optional title, completion timestamp, and notes for audit
DB location: --dotenv-dir / completion_tracking.db (alongside .env)
Schema: completion_tracking(task_id PK, project_id, title,
completed_time, processed_at, notes)
Also fixes filter_tools.py: get_completed() API takes start=/end=
not from_date=/to_date=.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two optional MCP tools and a SQLite-backed local store that let agents track which completed TickTick tasks they have already processed — without reading or writing growing log files at session start.
This feature is entirely opt-in. Nothing in the existing codebase changes behaviour. If you never call the new tools, nothing happens. No database file is created unless the tools are actually called.
Problem
Agents often need to react to newly completed tasks (e.g. log outcomes, trigger follow-up work). The naive approach is to read a completion log file at the start of each session and diff it against the current API response. This has two problems:
Solution
Two new tools backed by a local SQLite database (
<dotenv-dir>/completion_tracking.db):ticktick_get_unprocessed_completions(project_id, days=30)ticktick_mark_completion_processed(task_id, project_id, title?, completed_time?, notes?)ticktick_get_unprocessed_completionswill skip it{"status": "already_processed"}idempotently if called twice for the same taskDB schema
DB is stored alongside the
.envfile in--dotenv-dir(defaults to~/.config/ticktick-mcp/completion_tracking.db).Usage pattern
Could be called at the beginning of each conversation to check for new completions:
Also included
filter_tools.pybug fix:get_completed()was called withfrom_date=/to_date=keyword arguments, but the underlying ticktick-py API usesstart=/end=. This fix is required forticktick_get_unprocessed_completionsto work correctly.init_db,is_processed,mark_processed,get_processed_ids_for_project) and theticktick_mark_completion_processedMCP tool, including idempotency and isolation via temp DB paths.What this does NOT change
filter_tools.pybugfix)