feat: add worklog analytics tools and harden auth/error handling#25
Merged
Conversation
New tools: - getMissingWorklogDays — find working days where logged time is below the user's expected schedule. Uses Tempo's user-schedule API so holidays, non-working days, and part-time schedules are honoured automatically. Per-issue breakdown for partially-logged days. - getWorklogAnalytics — aggregate worklogs by issue, account, day, week (ISO 8601), or month. Returns hours, percentage, worklog count per group sorted by hours descending. Bug fixes (surfaced while wiring up the new tools): - getCurrentUserAccountId now prefers /rest/api/3/myself for all auth types, with email-search as basic-auth fallback. Avoids empty results when Atlassian privacy or scoped-token limits hide email visibility. - All 7 tool wrappers now propagate isError correctly. bulkCreateWorklogs was especially affected — full-batch failures were silently reported as successes because the wrapper dropped its explicit isError flag. - Pagination MAX_PAGES now throws instead of silent truncation. Returning incomplete data was worse than failing loudly. - 403 from /user-schedule surfaces a clear scope-guidance message instead of an opaque axios error. Polish & optimisation: - limit=1000 on Tempo paginated requests — typical month-long queries now fit in a single round trip. - formatHours/formatPercent helpers drop trailing zeros (7.5h, 50%). - validateDateRange rejects startDate > endDate with a clear message. - Cleaner output: single text block per response, no leading dashes (which clashed with em-dashes in issue titles), two-line layout for issue grouping in analytics (key+title above, stats indented below). - Consolidated getIssueInfoMap helper resolves key + summary in one pass; removed dead getIssueKeysMap / getIssueKeyById. Docs: - README clarifies classic vs scoped Jira API tokens and the OAuth fallback for orgs that disable classic tokens. - .env.example notes the Schemes scope requirement for Tempo. - Tool descriptions added in index.ts including the account groupBy caveat. Bumps to 1.6.0.
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
Adds two new MCP tools for worklog insights, plus several bug fixes that surfaced while wiring them up.
New tools
getMissingWorklogDays— finds working days where logged time is below the user's expected schedule. Uses Tempo's user-schedule API so holidays, non-working days, and part-time schedules are honoured automatically. Per-issue breakdown for partially-logged days.getWorklogAnalytics— aggregates worklogs byissue/account/day/week(ISO 8601) /month. Returns hours, percentage, worklog count per group sorted by hours desc.Bug fixes (surfaced during integration)
getCurrentUserAccountIdnow prefers/rest/api/3/myselffor all auth types, with the email-search retained as a basic-auth fallback. Avoids empty results when Atlassian privacy or scoped-token restrictions hide email visibility.isErrorcorrectly.bulkCreateWorklogswas especially affected — full-batch failures were silently reported as successes because the wrapper was dropping its explicitisErrorflag.MAX_PAGESlimit now throws instead of silent truncation. Returning incomplete data was worse than failing loudly./user-schedulesurfaces a clear scope-guidance message instead of an opaque axios error.Polish & optimisation
limit=1000on Tempo paginated requests — typical month-long queries now fit in a single round trip.formatHours/formatPercenthelpers drop trailing zeros (7.5h,50%).validateDateRangerejectsstartDate > endDatewith a clear MCP error.getIssueInfoMaphelper (resolves key + summary in one pass); removed deadgetIssueKeysMap/getIssueKeyById.Docs
.env.examplenotes the Schemes scope requirement for Tempo.index.tsincluding theaccountgroupBy caveat.Bumps to 1.6.0.
Test plan
npm run buildcleannpm run lint— 0 errorsnpm run format:checkcleangetMissingWorklogDaystested against live Tempo: zero-logged days, partially-logged days with breakdown, full week with no missinggetWorklogAnalyticstested withgroupBy: issue(returns key + Jira summary, percentages sum to 100%)startDate > endDate) verified to short-circuit with the new guardbulkCreateWorklogsfull-batch failure — verifyisErrornow reaches the MCP client (existing behaviour was silentlysuccess)Notes for reviewers
api.atlassian.com/ex/jira/{cloudId}gateway). README now calls this out and points to OAuth as the workaround. A follow-up PR could add native scoped-token support via aJIRA_CLOUD_IDenv var.accountgroupBy ingetWorklogAnalyticsonly makes sense if your team uses Tempo accounts (_Account_work attribute on worklogs). Documented in the tool description.