Skip to content

Validate accountId in get_calendar_events, with auto-resolution from calendarId#47

Merged
rockfordlhotka merged 3 commits into
mainfrom
copilot/add-validation-error-for-get-calendar-events
Apr 22, 2026
Merged

Validate accountId in get_calendar_events, with auto-resolution from calendarId#47
rockfordlhotka merged 3 commits into
mainfrom
copilot/add-validation-error-for-get-calendar-events

Conversation

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

get_calendar_events silently accepted a missing accountId and fell through to a "query all accounts" path, producing confusing empty or ambiguous results rather than a clear error. accountId is now validated on every call. When accountId is omitted but calendarId is provided, the tool attempts to auto-resolve the account by searching all enabled accounts' calendars for a unique match.

Changes

  • GetCalendarEventsTool

    • When both accountId and calendarId are omitted: returns { "error": "accountId is required" }, consistent with the pattern already used in GetCalendarEventDetailsTool
    • When accountId is omitted but calendarId is provided: searches all enabled accounts in parallel for a calendar with that ID
      • Exactly one match → account is auto-resolved and the call proceeds normally
      • No match → { "error": "No calendar found with id '...'. Provide accountId to specify which account to query." }
      • Multiple matches → { "error": "calendarId '...' exists in multiple accounts; provide accountId to specify which account to query." }
    • Removed the now-dead "query all accounts" branch (GetEnabledAccounts()) and its conditional error message
    • Updated tool and parameter descriptions to reflect the new behavior
  • GetCalendarEventsToolTests

    • Added validation tests for null and empty accountId (no calendarId)
    • Added test for single-match auto-resolution via calendarId
    • Added test for no-match error when calendarId is not found in any account
    • Added test for ambiguous error when calendarId exists in multiple accounts

Error responses

{ "error": "accountId is required" }
{ "error": "No calendar found with id '<calendarId>'. Provide accountId to specify which account to query." }
{ "error": "calendarId '<calendarId>' exists in multiple accounts; provide accountId to specify which account to query." }

… accountId

Agent-Logs-Url: https://github.com/MarimerLLC/calendar-mcp/sessions/db8cffbd-bbfb-48fc-bb8d-67301641ab83

Co-authored-by: rockfordlhotka <2333134+rockfordlhotka@users.noreply.github.com>
Copilot AI changed the title [WIP] Add validation error for missing accountId in get_calendar_events Require accountId in get_calendar_events, return structured validation error when missing Apr 22, 2026
Copilot AI requested a review from rockfordlhotka April 22, 2026 03:26
@rockfordlhotka
rockfordlhotka marked this pull request as ready for review April 22, 2026 03:32
@rockfordlhotka

Copy link
Copy Markdown
Member

@copilot
Is it possible, if the caller does omit the accountId, to use the calendarId value to find the matching calendar if there are no other matches? In other words, if there's only one calendar with that id, we could just use the id value right?

… identifies an account

Agent-Logs-Url: https://github.com/MarimerLLC/calendar-mcp/sessions/32d8eb33-ca2d-4394-a875-d31098200681

Co-authored-by: rockfordlhotka <2333134+rockfordlhotka@users.noreply.github.com>

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot
Is it possible, if the caller does omit the accountId, to use the calendarId value to find the matching calendar if there are no other matches? In other words, if there's only one calendar...

Yes, implemented in commit 1897f0a. When accountId is omitted but calendarId is provided, the tool now searches all enabled accounts' calendars in parallel. If exactly one account owns a calendar with that ID, it's used automatically. If zero match, it returns "No calendar found with id '...'". If more than one match, it returns "calendarId '...' exists in multiple accounts; provide accountId to specify which account to query."

Copilot AI changed the title Require accountId in get_calendar_events, return structured validation error when missing Validate accountId in get_calendar_events, with auto-resolution from calendarId Apr 22, 2026
@rockfordlhotka
rockfordlhotka merged commit 903dd14 into main Apr 22, 2026
@rockfordlhotka
rockfordlhotka deleted the copilot/add-validation-error-for-get-calendar-events branch April 22, 2026 15:04
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.

Return validation error when get_calendar_events is called without accountId

2 participants