backlog-mcp-server 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.ja.md +89 -41
  2. package/README.md +102 -43
  3. package/package.json +16 -12
  4. package/build/backlog/backlogErrorHandler.js +0 -8
  5. package/build/backlog/customFields.js +0 -70
  6. package/build/backlog/parseBacklogAPIError.js +0 -38
  7. package/build/createTranslationHelper.js +0 -28
  8. package/build/handlers/builders/composeToolHandler.js +0 -26
  9. package/build/handlers/transformers/wrapWithErrorHandling.js +0 -4
  10. package/build/handlers/transformers/wrapWithFieldPicking.js +0 -55
  11. package/build/handlers/transformers/wrapWithTokenLimit.js +0 -21
  12. package/build/handlers/transformers/wrapWithToolResult.js +0 -39
  13. package/build/index.js +0 -100
  14. package/build/registerTools.js +0 -37
  15. package/build/tools/addIssue.js +0 -97
  16. package/build/tools/addIssueComment.js +0 -44
  17. package/build/tools/addProject.js +0 -39
  18. package/build/tools/addPullRequest.js +0 -65
  19. package/build/tools/addPullRequestComment.js +0 -52
  20. package/build/tools/addVersionMilestone.js +0 -51
  21. package/build/tools/addWatching.js +0 -25
  22. package/build/tools/addWiki.js +0 -29
  23. package/build/tools/countIssues.js +0 -105
  24. package/build/tools/deleteIssue.js +0 -29
  25. package/build/tools/deleteProject.js +0 -29
  26. package/build/tools/deleteVersion.js +0 -35
  27. package/build/tools/deleteWatching.js +0 -17
  28. package/build/tools/dynamicTools/toolsets.js +0 -103
  29. package/build/tools/getCategories.js +0 -30
  30. package/build/tools/getCustomFields.js +0 -37
  31. package/build/tools/getDocument.js +0 -20
  32. package/build/tools/getDocumentTree.js +0 -20
  33. package/build/tools/getDocuments.js +0 -25
  34. package/build/tools/getGitRepositories.js +0 -29
  35. package/build/tools/getGitRepository.js +0 -41
  36. package/build/tools/getIssue.js +0 -29
  37. package/build/tools/getIssueComments.js +0 -45
  38. package/build/tools/getIssueTypes.js +0 -30
  39. package/build/tools/getIssues.js +0 -149
  40. package/build/tools/getMyself.js +0 -14
  41. package/build/tools/getNotifications.js +0 -35
  42. package/build/tools/getNotificationsCount.js +0 -20
  43. package/build/tools/getPriorities.js +0 -13
  44. package/build/tools/getProject.js +0 -29
  45. package/build/tools/getProjectList.js +0 -23
  46. package/build/tools/getPullRequest.js +0 -44
  47. package/build/tools/getPullRequestComments.js +0 -60
  48. package/build/tools/getPullRequests.js +0 -65
  49. package/build/tools/getPullRequestsCount.js +0 -57
  50. package/build/tools/getResolutions.js +0 -13
  51. package/build/tools/getSpace.js +0 -14
  52. package/build/tools/getUsers.js +0 -14
  53. package/build/tools/getVersionMilestoneList.js +0 -37
  54. package/build/tools/getWatchingListCount.js +0 -17
  55. package/build/tools/getWatchingListItems.js +0 -17
  56. package/build/tools/getWiki.js +0 -21
  57. package/build/tools/getWikiPages.js +0 -37
  58. package/build/tools/getWikisCount.js +0 -29
  59. package/build/tools/markNotificationAsRead.js +0 -26
  60. package/build/tools/markWatchingAsRead.js +0 -26
  61. package/build/tools/resetUnreadNotificationCount.js +0 -13
  62. package/build/tools/shared/customFieldFiltersSchema.js +0 -78
  63. package/build/tools/tools.js +0 -161
  64. package/build/tools/updateIssue.js +0 -119
  65. package/build/tools/updateProject.js +0 -57
  66. package/build/tools/updatePullRequest.js +0 -68
  67. package/build/tools/updatePullRequestComment.js +0 -51
  68. package/build/tools/updateVersionMilestone.js +0 -57
  69. package/build/tools/updateWatching.js +0 -18
  70. package/build/tools/updateWiki.js +0 -37
  71. package/build/types/mcp.js +0 -1
  72. package/build/types/result.js +0 -3
  73. package/build/types/tool.js +0 -1
  74. package/build/types/toolsets.js +0 -1
  75. package/build/types/zod/backlogOutputDefinition.js +0 -468
  76. package/build/utils/generateFieldsDescription.js +0 -47
  77. package/build/utils/logger.js +0 -20
  78. package/build/utils/resolveIdOrKey.js +0 -25
  79. package/build/utils/runToolSafely.js +0 -18
  80. package/build/utils/tokenCounter.js +0 -11
  81. package/build/utils/toolRegistrar.js +0 -12
  82. package/build/utils/toolsetUtils.js +0 -48
  83. package/build/utils/wrapServerWithToolRegistry.js +0 -16
  84. package/build/version.js +0 -1
  85. package/build/version.template.js +0 -1
@@ -1,13 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { ResolutionSchema } from '../types/zod/backlogOutputDefinition.js';
4
- const getResolutionsSchema = buildToolSchema((_t) => ({}));
5
- export const getResolutionsTool = (backlog, { t }) => {
6
- return {
7
- name: 'get_resolutions',
8
- description: t('TOOL_GET_RESOLUTIONS_DESCRIPTION', 'Returns list of issue resolutions'),
9
- schema: z.object(getResolutionsSchema(t)),
10
- outputSchema: ResolutionSchema,
11
- handler: async () => backlog.getResolutions(),
12
- };
13
- };
@@ -1,14 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { SpaceSchema } from '../types/zod/backlogOutputDefinition.js';
4
- const getSpaceSchema = buildToolSchema((_t) => ({}));
5
- export const getSpaceTool = (backlog, { t }) => {
6
- return {
7
- name: 'get_space',
8
- description: t('TOOL_GET_SPACE_DESCRIPTION', 'Returns information about the Backlog space'),
9
- schema: z.object(getSpaceSchema(t)),
10
- outputSchema: SpaceSchema,
11
- importantFields: ['spaceKey', 'name', 'lang', 'timezone'],
12
- handler: async () => backlog.getSpace(),
13
- };
14
- };
@@ -1,14 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { UserSchema } from '../types/zod/backlogOutputDefinition.js';
4
- const getUsersSchema = buildToolSchema((_t) => ({}));
5
- export const getUsersTool = (backlog, { t }) => {
6
- return {
7
- name: 'get_users',
8
- description: t('TOOL_GET_USERS_DESCRIPTION', 'Returns list of users in the Backlog space'),
9
- schema: z.object(getUsersSchema(t)),
10
- outputSchema: UserSchema,
11
- importantFields: ['userId', 'name', 'roleType', 'lang'],
12
- handler: async () => backlog.getUsers(),
13
- };
14
- };
@@ -1,37 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { VersionSchema } from '../types/zod/backlogOutputDefinition.js';
4
- import { resolveIdOrKey } from '../utils/resolveIdOrKey.js';
5
- const getVersionMilestoneListSchema = buildToolSchema((t) => ({
6
- projectId: z
7
- .number()
8
- .optional()
9
- .describe(t('TOOL_GET_VERSION_MILESTONE_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
10
- projectKey: z
11
- .string()
12
- .optional()
13
- .describe(t('TOOL_GET_VERSION_MILESTONE_PROJECT_KEY', 'The key of the project (e.g., TEST_PROJECT)')),
14
- }));
15
- export const getVersionMilestoneListTool = (backlog, { t }) => {
16
- return {
17
- name: 'get_version_milestone_list',
18
- description: t('TOOL_GET_VERSION_MILESTONE_LIST_DESCRIPTION', 'Returns list of versions/milestones in the Backlog space'),
19
- schema: z.object(getVersionMilestoneListSchema(t)),
20
- outputSchema: VersionSchema,
21
- importantFields: [
22
- 'id',
23
- 'name',
24
- 'description',
25
- 'startDate',
26
- 'releaseDueDate',
27
- 'archived',
28
- ],
29
- handler: async ({ projectId, projectKey }) => {
30
- const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
31
- if (!result.ok) {
32
- throw result.error;
33
- }
34
- return backlog.getVersions(result.value);
35
- },
36
- };
37
- };
@@ -1,17 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { WatchingListCountSchema } from '../types/zod/backlogOutputDefinition.js';
4
- const getWatchingListCountSchema = buildToolSchema((t) => ({
5
- userId: z
6
- .number()
7
- .describe(t('TOOL_GET_WATCHING_LIST_COUNT_USER_ID', 'User ID')),
8
- }));
9
- export const getWatchingListCountTool = (backlog, { t }) => {
10
- return {
11
- name: 'get_watching_list_count',
12
- description: t('TOOL_GET_WATCHING_LIST_COUNT_DESCRIPTION', 'Returns count of watching items for a user'),
13
- schema: z.object(getWatchingListCountSchema(t)),
14
- outputSchema: WatchingListCountSchema,
15
- handler: async ({ userId }) => backlog.getWatchingListCount(userId),
16
- };
17
- };
@@ -1,17 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { WatchingListItemSchema } from '../types/zod/backlogOutputDefinition.js';
4
- const getWatchingListItemsSchema = buildToolSchema((t) => ({
5
- userId: z
6
- .number()
7
- .describe(t('TOOL_GET_WATCHING_LIST_ITEMS_USER_ID', 'User ID')),
8
- }));
9
- export const getWatchingListItemsTool = (backlog, { t }) => {
10
- return {
11
- name: 'get_watching_list_items',
12
- description: t('TOOL_GET_WATCHING_LIST_ITEMS_DESCRIPTION', 'Returns list of watching items for a user'),
13
- schema: z.object(getWatchingListItemsSchema(t)),
14
- outputSchema: WatchingListItemSchema,
15
- handler: async ({ userId }) => backlog.getWatchingListItems(userId),
16
- };
17
- };
@@ -1,21 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { WikiSchema } from '../types/zod/backlogOutputDefinition.js';
4
- const getWikiSchema = buildToolSchema((t) => ({
5
- wikiId: z
6
- .union([z.string(), z.number()])
7
- .describe(t('TOOL_GET_WIKI_ID', 'Wiki ID')),
8
- }));
9
- export const getWikiTool = (backlog, { t }) => {
10
- return {
11
- name: 'get_wiki',
12
- description: t('TOOL_GET_WIKI_DESCRIPTION', 'Returns information about a specific wiki page'),
13
- schema: z.object(getWikiSchema(t)),
14
- outputSchema: WikiSchema,
15
- importantFields: ['id', 'projectId', 'name', 'content'],
16
- handler: async ({ wikiId }) => {
17
- const wikiIdNumber = typeof wikiId === 'string' ? parseInt(wikiId, 10) : wikiId;
18
- return backlog.getWiki(wikiIdNumber);
19
- },
20
- };
21
- };
@@ -1,37 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { WikiListItemSchema } from '../types/zod/backlogOutputDefinition.js';
4
- import { resolveIdOrKey } from '../utils/resolveIdOrKey.js';
5
- const getWikiPagesSchema = buildToolSchema((t) => ({
6
- projectId: z
7
- .number()
8
- .optional()
9
- .describe(t('TOOL_GET_WIKI_PAGES_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
10
- projectKey: z
11
- .string()
12
- .optional()
13
- .describe(t('TOOL_GET_WIKI_PAGES_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
14
- keyword: z
15
- .string()
16
- .optional()
17
- .describe(t('TOOL_GET_WIKI_PAGES_KEYWORD', 'Keyword to search for in Wiki pages')),
18
- }));
19
- export const getWikiPagesTool = (backlog, { t }) => {
20
- return {
21
- name: 'get_wiki_pages',
22
- description: t('TOOL_GET_WIKI_PAGES_DESCRIPTION', 'Returns list of Wiki pages'),
23
- schema: z.object(getWikiPagesSchema(t)),
24
- outputSchema: WikiListItemSchema,
25
- importantFields: ['projectId', 'name', 'tags'],
26
- handler: async ({ projectId, projectKey, keyword }) => {
27
- const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
28
- if (!result.ok) {
29
- throw result.error;
30
- }
31
- return backlog.getWikis({
32
- projectIdOrKey: result.value,
33
- keyword,
34
- });
35
- },
36
- };
37
- };
@@ -1,29 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { WikiCountSchema } from '../types/zod/backlogOutputDefinition.js';
4
- import { resolveIdOrKey } from '../utils/resolveIdOrKey.js';
5
- const getWikisCountSchema = buildToolSchema((t) => ({
6
- projectId: z
7
- .number()
8
- .optional()
9
- .describe(t('TOOL_GET_WIKIS_COUNT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
10
- projectKey: z
11
- .string()
12
- .optional()
13
- .describe(t('TOOL_GET_WIKIS_COUNT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
14
- }));
15
- export const getWikisCountTool = (backlog, { t }) => {
16
- return {
17
- name: 'get_wikis_count',
18
- description: t('TOOL_GET_WIKIS_COUNT_DESCRIPTION', 'Returns count of wiki pages in a project'),
19
- schema: z.object(getWikisCountSchema(t)),
20
- outputSchema: WikiCountSchema,
21
- handler: async ({ projectId, projectKey }) => {
22
- const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
23
- if (!result.ok) {
24
- throw result.error;
25
- }
26
- return backlog.getWikisCount(result.value);
27
- },
28
- };
29
- };
@@ -1,26 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- const markNotificationAsReadSchema = buildToolSchema((t) => ({
4
- id: z
5
- .number()
6
- .describe(t('TOOL_MARK_NOTIFICATION_AS_READ_ID', 'Notification ID to mark as read')),
7
- }));
8
- export const MarkNotificationAsReadResultSchema = z.object({
9
- success: z.boolean(),
10
- message: z.string(),
11
- });
12
- export const markNotificationAsReadTool = (backlog, { t }) => {
13
- return {
14
- name: 'mark_notification_as_read',
15
- description: t('TOOL_MARK_NOTIFICATION_AS_READ_DESCRIPTION', 'Mark a notification as read'),
16
- schema: z.object(markNotificationAsReadSchema(t)),
17
- outputSchema: MarkNotificationAsReadResultSchema,
18
- handler: async ({ id }) => {
19
- await backlog.markAsReadNotification(id);
20
- return {
21
- success: true,
22
- message: `Notification ${id} marked as read`,
23
- };
24
- },
25
- };
26
- };
@@ -1,26 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- const markWatchingAsReadSchema = buildToolSchema((t) => ({
4
- watchId: z
5
- .number()
6
- .describe(t('TOOL_MARK_WATCHING_AS_READ_WATCH_ID', 'Watch ID to mark as read')),
7
- }));
8
- export const MarkWatchingAsReadResultSchema = z.object({
9
- success: z.boolean(),
10
- message: z.string(),
11
- });
12
- export const markWatchingAsReadTool = (backlog, { t }) => {
13
- return {
14
- name: 'mark_watching_as_read',
15
- description: t('TOOL_MARK_WATCHING_AS_READ_DESCRIPTION', 'Mark a watch as read'),
16
- schema: z.object(markWatchingAsReadSchema(t)),
17
- outputSchema: MarkWatchingAsReadResultSchema,
18
- handler: async ({ watchId }) => {
19
- await backlog.resetWatchingListItemAsRead(watchId);
20
- return {
21
- success: true,
22
- message: `Watch ${watchId} marked as read`,
23
- };
24
- },
25
- };
26
- };
@@ -1,13 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { NotificationCountSchema } from '../types/zod/backlogOutputDefinition.js';
4
- const resetUnreadNotificationCountSchema = buildToolSchema((_t) => ({}));
5
- export const resetUnreadNotificationCountTool = (backlog, { t }) => {
6
- return {
7
- name: 'reset_unread_notification_count',
8
- description: t('TOOL_RESET_UNREAD_NOTIFICATION_COUNT_DESCRIPTION', 'Reset unread notification count'),
9
- schema: z.object(resetUnreadNotificationCountSchema(t)),
10
- outputSchema: NotificationCountSchema,
11
- handler: async () => backlog.resetNotificationsMarkAsRead(),
12
- };
13
- };
@@ -1,78 +0,0 @@
1
- import { z, ZodIssueCode } from 'zod';
2
- export const buildCustomFieldFilterSchema = (t) => {
3
- const schema = z.discriminatedUnion('type', [
4
- z
5
- .object({
6
- type: z.literal('text'),
7
- id: z
8
- .number()
9
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_ID', 'Custom field ID (e.g., 12345)')),
10
- value: z
11
- .string()
12
- .min(1)
13
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_TEXT_VALUE', 'Keyword to match for the custom field')),
14
- })
15
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_TEXT', 'Text custom field filter')),
16
- z
17
- .object({
18
- type: z.literal('numeric'),
19
- id: z
20
- .number()
21
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_ID', 'Custom field ID (e.g., 12345)')),
22
- min: z
23
- .number()
24
- .optional()
25
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_NUMERIC_MIN', 'Minimum numeric value (inclusive)')),
26
- max: z
27
- .number()
28
- .optional()
29
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_NUMERIC_MAX', 'Maximum numeric value (inclusive)')),
30
- })
31
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_NUMERIC', 'Numeric custom field filter')),
32
- z
33
- .object({
34
- type: z.literal('date'),
35
- id: z
36
- .number()
37
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_ID', 'Custom field ID (e.g., 12345)')),
38
- min: z
39
- .string()
40
- .optional()
41
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_DATE_MIN', 'Start date (yyyy-MM-dd)')),
42
- max: z
43
- .string()
44
- .optional()
45
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_DATE_MAX', 'End date (yyyy-MM-dd)')),
46
- })
47
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_DATE', 'Date custom field filter')),
48
- z
49
- .object({
50
- type: z.literal('list'),
51
- id: z
52
- .number()
53
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_ID', 'Custom field ID (e.g., 12345)')),
54
- value: z
55
- .union([z.number(), z.array(z.number()).min(1)])
56
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_LIST_VALUE', 'Value ID(s) to match for list-type custom field')),
57
- })
58
- .describe(t('TOOL_CUSTOM_FIELD_FILTER_LIST', 'List custom field filter')),
59
- ]);
60
- return schema.superRefine((data, ctx) => {
61
- if (data.type === 'numeric' &&
62
- data.min === undefined &&
63
- data.max === undefined) {
64
- ctx.addIssue({
65
- code: ZodIssueCode.custom,
66
- message: t('TOOL_CUSTOM_FIELD_FILTER_NUMERIC_REQUIRED', 'Provide at least one of min or max for numeric filters'),
67
- path: ['min'],
68
- });
69
- }
70
- if (data.type === 'date' && !data.min && !data.max) {
71
- ctx.addIssue({
72
- code: ZodIssueCode.custom,
73
- message: t('TOOL_CUSTOM_FIELD_FILTER_DATE_REQUIRED', 'Provide at least one of min or max for date filters'),
74
- path: ['min'],
75
- });
76
- }
77
- });
78
- };
@@ -1,161 +0,0 @@
1
- import { addIssueTool } from './addIssue.js';
2
- import { addIssueCommentTool } from './addIssueComment.js';
3
- import { addProjectTool } from './addProject.js';
4
- import { addPullRequestTool } from './addPullRequest.js';
5
- import { addPullRequestCommentTool } from './addPullRequestComment.js';
6
- import { addWikiTool } from './addWiki.js';
7
- import { updateWikiTool } from './updateWiki.js';
8
- import { countIssuesTool } from './countIssues.js';
9
- import { deleteIssueTool } from './deleteIssue.js';
10
- import { deleteProjectTool } from './deleteProject.js';
11
- import { getCategoriesTool } from './getCategories.js';
12
- import { getCustomFieldsTool } from './getCustomFields.js';
13
- import { getGitRepositoriesTool } from './getGitRepositories.js';
14
- import { getGitRepositoryTool } from './getGitRepository.js';
15
- import { getIssueTool } from './getIssue.js';
16
- import { getIssueCommentsTool } from './getIssueComments.js';
17
- import { getIssuesTool } from './getIssues.js';
18
- import { getIssueTypesTool } from './getIssueTypes.js';
19
- import { getMyselfTool } from './getMyself.js';
20
- import { getNotificationsTool } from './getNotifications.js';
21
- import { getNotificationsCountTool } from './getNotificationsCount.js';
22
- import { getPrioritiesTool } from './getPriorities.js';
23
- import { getProjectTool } from './getProject.js';
24
- import { getProjectListTool } from './getProjectList.js';
25
- import { getPullRequestTool } from './getPullRequest.js';
26
- import { getPullRequestCommentsTool } from './getPullRequestComments.js';
27
- import { getPullRequestsTool } from './getPullRequests.js';
28
- import { getPullRequestsCountTool } from './getPullRequestsCount.js';
29
- import { getResolutionsTool } from './getResolutions.js';
30
- import { getSpaceTool } from './getSpace.js';
31
- import { getUsersTool } from './getUsers.js';
32
- import { getWatchingListCountTool } from './getWatchingListCount.js';
33
- import { getWatchingListItemsTool } from './getWatchingListItems.js';
34
- import { addWatchingTool } from './addWatching.js';
35
- import { updateWatchingTool } from './updateWatching.js';
36
- import { deleteWatchingTool } from './deleteWatching.js';
37
- import { markWatchingAsReadTool } from './markWatchingAsRead.js';
38
- import { getWikiTool } from './getWiki.js';
39
- import { getWikiPagesTool } from './getWikiPages.js';
40
- import { getWikisCountTool } from './getWikisCount.js';
41
- import { markNotificationAsReadTool } from './markNotificationAsRead.js';
42
- import { resetUnreadNotificationCountTool } from './resetUnreadNotificationCount.js';
43
- import { updateIssueTool } from './updateIssue.js';
44
- import { updateProjectTool } from './updateProject.js';
45
- import { updatePullRequestTool } from './updatePullRequest.js';
46
- import { updatePullRequestCommentTool } from './updatePullRequestComment.js';
47
- import { getDocumentTool } from './getDocument.js';
48
- import { getDocumentsTool } from './getDocuments.js';
49
- import { getDocumentTreeTool } from './getDocumentTree.js';
50
- import { getVersionMilestoneListTool } from './getVersionMilestoneList.js';
51
- import { addVersionMilestoneTool } from './addVersionMilestone.js';
52
- import { updateVersionMilestoneTool } from './updateVersionMilestone.js';
53
- import { deleteVersionTool } from './deleteVersion.js';
54
- export const allTools = (backlog, helper) => {
55
- return {
56
- toolsets: [
57
- {
58
- name: 'space',
59
- description: 'Tools for managing Backlog space settings and general information.',
60
- enabled: false,
61
- tools: [
62
- getSpaceTool(backlog, helper),
63
- getUsersTool(backlog, helper),
64
- getMyselfTool(backlog, helper),
65
- ],
66
- },
67
- {
68
- name: 'project',
69
- description: 'Tools for managing projects, categories, custom fields, and issue types.',
70
- enabled: false,
71
- tools: [
72
- getProjectListTool(backlog, helper),
73
- addProjectTool(backlog, helper),
74
- getProjectTool(backlog, helper),
75
- updateProjectTool(backlog, helper),
76
- deleteProjectTool(backlog, helper),
77
- ],
78
- },
79
- {
80
- name: 'issue',
81
- description: 'Tools for managing issues and their comments.',
82
- enabled: false,
83
- tools: [
84
- getIssueTool(backlog, helper),
85
- getIssuesTool(backlog, helper),
86
- countIssuesTool(backlog, helper),
87
- addIssueTool(backlog, helper),
88
- updateIssueTool(backlog, helper),
89
- deleteIssueTool(backlog, helper),
90
- getIssueCommentsTool(backlog, helper),
91
- addIssueCommentTool(backlog, helper),
92
- getPrioritiesTool(backlog, helper),
93
- getCategoriesTool(backlog, helper),
94
- getCustomFieldsTool(backlog, helper),
95
- getIssueTypesTool(backlog, helper),
96
- getResolutionsTool(backlog, helper),
97
- getWatchingListItemsTool(backlog, helper),
98
- getWatchingListCountTool(backlog, helper),
99
- addWatchingTool(backlog, helper),
100
- updateWatchingTool(backlog, helper),
101
- deleteWatchingTool(backlog, helper),
102
- markWatchingAsReadTool(backlog, helper),
103
- getVersionMilestoneListTool(backlog, helper),
104
- addVersionMilestoneTool(backlog, helper),
105
- updateVersionMilestoneTool(backlog, helper),
106
- deleteVersionTool(backlog, helper),
107
- ],
108
- },
109
- {
110
- name: 'wiki',
111
- description: 'Tools for managing wiki pages.',
112
- enabled: false,
113
- tools: [
114
- getWikiPagesTool(backlog, helper),
115
- getWikisCountTool(backlog, helper),
116
- getWikiTool(backlog, helper),
117
- addWikiTool(backlog, helper),
118
- updateWikiTool(backlog, helper),
119
- ],
120
- },
121
- {
122
- name: 'git',
123
- description: 'Tools for managing Git repositories and pull requests.',
124
- enabled: false,
125
- tools: [
126
- getGitRepositoriesTool(backlog, helper),
127
- getGitRepositoryTool(backlog, helper),
128
- getPullRequestsTool(backlog, helper),
129
- getPullRequestsCountTool(backlog, helper),
130
- getPullRequestTool(backlog, helper),
131
- addPullRequestTool(backlog, helper),
132
- updatePullRequestTool(backlog, helper),
133
- getPullRequestCommentsTool(backlog, helper),
134
- addPullRequestCommentTool(backlog, helper),
135
- updatePullRequestCommentTool(backlog, helper),
136
- ],
137
- },
138
- {
139
- name: 'document',
140
- description: 'Tools for managing documents.',
141
- enabled: false,
142
- tools: [
143
- getDocumentsTool(backlog, helper),
144
- getDocumentTreeTool(backlog, helper),
145
- getDocumentTool(backlog, helper),
146
- ],
147
- },
148
- {
149
- name: 'notifications',
150
- description: 'Tools for managing user notifications.',
151
- enabled: false,
152
- tools: [
153
- getNotificationsTool(backlog, helper),
154
- getNotificationsCountTool(backlog, helper),
155
- resetUnreadNotificationCountTool(backlog, helper),
156
- markNotificationAsReadTool(backlog, helper),
157
- ],
158
- },
159
- ],
160
- };
161
- };
@@ -1,119 +0,0 @@
1
- import { z } from 'zod';
2
- import { buildToolSchema } from '../types/tool.js';
3
- import { IssueSchema } from '../types/zod/backlogOutputDefinition.js';
4
- import { resolveIdOrKey } from '../utils/resolveIdOrKey.js';
5
- import { customFieldsToPayload } from '../backlog/customFields.js';
6
- const updateIssueSchema = buildToolSchema((t) => ({
7
- issueId: z
8
- .number()
9
- .optional()
10
- .describe(t('TOOL_UPDATE_ISSUE_ISSUE_ID', 'The numeric ID of the issue (e.g., 12345)')),
11
- issueKey: z
12
- .string()
13
- .optional()
14
- .describe(t('TOOL_UPDATE_ISSUE_ISSUE_KEY', "The key of the issue (e.g., 'PROJ-123')")),
15
- summary: z
16
- .string()
17
- .optional()
18
- .describe(t('TOOL_UPDATE_ISSUE_SUMMARY', 'Summary of the issue')),
19
- issueTypeId: z
20
- .number()
21
- .optional()
22
- .describe(t('TOOL_UPDATE_ISSUE_ISSUE_TYPE_ID', 'Issue type ID')),
23
- priorityId: z
24
- .number()
25
- .optional()
26
- .describe(t('TOOL_UPDATE_ISSUE_PRIORITY_ID', 'Priority ID')),
27
- description: z
28
- .string()
29
- .optional()
30
- .describe(t('TOOL_UPDATE_ISSUE_DESCRIPTION', 'Detailed description of the issue')),
31
- startDate: z
32
- .string()
33
- .optional()
34
- .describe(t('TOOL_UPDATE_ISSUE_START_DATE', 'Scheduled start date (yyyy-MM-dd)')),
35
- dueDate: z
36
- .string()
37
- .optional()
38
- .describe(t('TOOL_UPDATE_ISSUE_DUE_DATE', 'Scheduled due date (yyyy-MM-dd)')),
39
- estimatedHours: z
40
- .number()
41
- .optional()
42
- .describe(t('TOOL_UPDATE_ISSUE_ESTIMATED_HOURS', 'Estimated work hours')),
43
- actualHours: z
44
- .number()
45
- .optional()
46
- .describe(t('TOOL_UPDATE_ISSUE_ACTUAL_HOURS', 'Actual work hours')),
47
- categoryId: z
48
- .array(z.number())
49
- .optional()
50
- .describe(t('TOOL_UPDATE_ISSUE_CATEGORY_ID', 'Category IDs')),
51
- versionId: z
52
- .array(z.number())
53
- .optional()
54
- .describe(t('TOOL_UPDATE_ISSUE_VERSION_ID', 'Version IDs')),
55
- milestoneId: z
56
- .array(z.number())
57
- .optional()
58
- .describe(t('TOOL_UPDATE_ISSUE_MILESTONE_ID', 'Milestone IDs')),
59
- statusId: z
60
- .number()
61
- .optional()
62
- .describe(t('TOOL_UPDATE_ISSUE_STATUS_ID', 'Status ID')),
63
- resolutionId: z
64
- .number()
65
- .optional()
66
- .describe(t('TOOL_UPDATE_ISSUE_RESOLUTION_ID', 'Resolution ID')),
67
- assigneeId: z
68
- .number()
69
- .optional()
70
- .describe(t('TOOL_UPDATE_ISSUE_ASSIGNEE_ID', 'User ID of the assignee')),
71
- notifiedUserId: z
72
- .array(z.number())
73
- .optional()
74
- .describe(t('TOOL_UPDATE_ISSUE_NOTIFIED_USER_ID', 'User IDs to notify')),
75
- attachmentId: z
76
- .array(z.number())
77
- .optional()
78
- .describe(t('TOOL_UPDATE_ISSUE_ATTACHMENT_ID', 'Attachment IDs')),
79
- comment: z
80
- .string()
81
- .optional()
82
- .describe(t('TOOL_UPDATE_ISSUE_COMMENT', 'Comment to add when updating the issue')),
83
- customFields: z
84
- .array(z.object({
85
- id: z
86
- .number()
87
- .describe(t('TOOL_UPDATE_ISSUE_CUSTOM_FIELD_ID', 'The ID of the custom field (e.g., 12345)')),
88
- value: z
89
- .union([z.number(), z.array(z.number())])
90
- .optional()
91
- .describe('The ID(s) of the custom field item. For single-select fields, provide a number. For multi-select fields, provide an array of numbers representing the selected item IDs.'),
92
- otherValue: z
93
- .string()
94
- .optional()
95
- .describe(t('TOOL_UPDATE_ISSUE_CUSTOM_FIELD_OTHER_VALUE', 'Other value for list type fields')),
96
- }))
97
- .optional()
98
- .describe(t('TOOL_UPDATE_ISSUE_CUSTOM_FIELDS', 'List of custom fields to set on the issue')),
99
- }));
100
- export const updateIssueTool = (backlog, { t }) => {
101
- return {
102
- name: 'update_issue',
103
- description: t('TOOL_UPDATE_ISSUE_DESCRIPTION', 'Updates an existing issue'),
104
- schema: z.object(updateIssueSchema(t)),
105
- outputSchema: IssueSchema,
106
- handler: async ({ issueId, issueKey, customFields, ...params }) => {
107
- const result = resolveIdOrKey('issue', { id: issueId, key: issueKey }, t);
108
- if (!result.ok) {
109
- throw result.error;
110
- }
111
- const customFieldPayload = customFieldsToPayload(customFields);
112
- const finalPayload = {
113
- ...params,
114
- ...customFieldPayload,
115
- };
116
- return backlog.patchIssue(result.value, finalPayload);
117
- },
118
- };
119
- };