Skip to content

fix: add "custom" to MCP time summary period enum#1672

Open
pib wants to merge 2 commits intocallumalpass:mainfrom
pib:fix/mcp-custom-period-enum
Open

fix: add "custom" to MCP time summary period enum#1672
pib wants to merge 2 commits intocallumalpass:mainfrom
pib:fix/mcp-custom-period-enum

Conversation

@pib
Copy link

@pib pib commented Mar 5, 2026

Summary

The tasknotes_get_time_summary MCP tool declares from and to parameters for custom date ranges, but they never work because the Zod enum for period only allows today|week|month|all. The HTTP API (/api/time/summary) works fine with period=custom&from=...&to=... because it has no enum validation.

Root cause

src/services/MCPService.ts line 529 — Zod enum validation prevents any period value other than today/week/month/all from reaching the default case in computeDateRange(), which is where fromDate/toDate are used.

Fix

Add "custom" to the Zod enum. The default case in computeDateRange already handles the rest correctly.

Test plan

  • MCP call with period=custom, from, to returns data scoped to custom range
  • New unit test for computeTimeSummary with custom period and date range filtering
  • All 21 time tracking tests pass (20 existing + 1 new)
  • Existing period values (today, week, month, all) unaffected
  • Custom period without from/to falls back to today (no error)
  • Invalid period value correctly rejected by Zod validation
  • Local plugin build + install verified in live Obsidian vault

pib and others added 2 commits March 5, 2026 09:44
The tasknotes_get_time_summary MCP tool declares `from` and `to`
parameters for custom date ranges, but Zod enum validation rejects
any period value not in [today, week, month, all]. The underlying
computeDateRange() already handles custom ranges in its default
case — this just lets the value through.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that period="custom" with fromDate/toDate correctly filters
time entries to only those within the specified range.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant