backlog-mcp-server 0.4.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.
- package/LICENSE +21 -0
- package/README.ja.md +440 -0
- package/README.md +501 -0
- package/build/backlog/backlogErrorHandler.js +8 -0
- package/build/backlog/customFields.js +16 -0
- package/build/backlog/parseBacklogAPIError.js +38 -0
- package/build/createTranslationHelper.js +28 -0
- package/build/handlers/builders/composeToolHandler.js +26 -0
- package/build/handlers/transformers/wrapWithErrorHandling.js +4 -0
- package/build/handlers/transformers/wrapWithFieldPicking.js +55 -0
- package/build/handlers/transformers/wrapWithTokenLimit.js +21 -0
- package/build/handlers/transformers/wrapWithToolResult.js +39 -0
- package/build/index.js +102 -0
- package/build/registerTools.js +37 -0
- package/build/tools/addIssue.js +94 -0
- package/build/tools/addIssueComment.js +44 -0
- package/build/tools/addProject.js +39 -0
- package/build/tools/addPullRequest.js +65 -0
- package/build/tools/addPullRequestComment.js +52 -0
- package/build/tools/addWiki.js +29 -0
- package/build/tools/countIssues.js +111 -0
- package/build/tools/deleteIssue.js +29 -0
- package/build/tools/deleteProject.js +29 -0
- package/build/tools/downloadDocumentAttachment.js +1 -0
- package/build/tools/dynamicTools/toolsets.js +103 -0
- package/build/tools/getCategories.js +30 -0
- package/build/tools/getCustomFields.js +37 -0
- package/build/tools/getDocument.js +20 -0
- package/build/tools/getDocumentTree.js +20 -0
- package/build/tools/getDocuments.js +25 -0
- package/build/tools/getGitRepositories.js +29 -0
- package/build/tools/getGitRepository.js +41 -0
- package/build/tools/getIssue.js +29 -0
- package/build/tools/getIssueComments.js +45 -0
- package/build/tools/getIssueTypes.js +30 -0
- package/build/tools/getIssues.js +155 -0
- package/build/tools/getMyself.js +14 -0
- package/build/tools/getNotifications.js +35 -0
- package/build/tools/getNotificationsCount.js +20 -0
- package/build/tools/getPriorities.js +13 -0
- package/build/tools/getProject.js +29 -0
- package/build/tools/getProjectList.js +23 -0
- package/build/tools/getPullRequest.js +44 -0
- package/build/tools/getPullRequestComments.js +60 -0
- package/build/tools/getPullRequests.js +65 -0
- package/build/tools/getPullRequestsCount.js +57 -0
- package/build/tools/getResolutions.js +13 -0
- package/build/tools/getSpace.js +14 -0
- package/build/tools/getUsers.js +14 -0
- package/build/tools/getWatchingListCount.js +17 -0
- package/build/tools/getWatchingListItems.js +17 -0
- package/build/tools/getWiki.js +21 -0
- package/build/tools/getWikiPages.js +37 -0
- package/build/tools/getWikisCount.js +29 -0
- package/build/tools/markNotificationAsRead.js +26 -0
- package/build/tools/resetUnreadNotificationCount.js +13 -0
- package/build/tools/tools.js +143 -0
- package/build/tools/updateIssue.js +116 -0
- package/build/tools/updateProject.js +57 -0
- package/build/tools/updatePullRequest.js +68 -0
- package/build/tools/updatePullRequestComment.js +51 -0
- package/build/types/mcp.js +1 -0
- package/build/types/result.js +3 -0
- package/build/types/tool.js +1 -0
- package/build/types/toolsets.js +1 -0
- package/build/types/zod/backlogOutputDefinition.js +468 -0
- package/build/utils/generateFieldsDescription.js +47 -0
- package/build/utils/resolveIdOrKey.js +25 -0
- package/build/utils/runToolSafely.js +18 -0
- package/build/utils/tokenCounter.js +11 -0
- package/build/utils/toolRegistrar.js +12 -0
- package/build/utils/toolsetUtils.js +48 -0
- package/build/utils/wrapServerWithToolRegistry.js +16 -0
- package/build/version.js +1 -0
- package/build/version.template.js +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,143 @@
|
|
|
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 { countIssuesTool } from './countIssues.js';
|
|
8
|
+
import { deleteIssueTool } from './deleteIssue.js';
|
|
9
|
+
import { deleteProjectTool } from './deleteProject.js';
|
|
10
|
+
import { getCategoriesTool } from './getCategories.js';
|
|
11
|
+
import { getCustomFieldsTool } from './getCustomFields.js';
|
|
12
|
+
import { getGitRepositoriesTool } from './getGitRepositories.js';
|
|
13
|
+
import { getGitRepositoryTool } from './getGitRepository.js';
|
|
14
|
+
import { getIssueTool } from './getIssue.js';
|
|
15
|
+
import { getIssueCommentsTool } from './getIssueComments.js';
|
|
16
|
+
import { getIssuesTool } from './getIssues.js';
|
|
17
|
+
import { getIssueTypesTool } from './getIssueTypes.js';
|
|
18
|
+
import { getMyselfTool } from './getMyself.js';
|
|
19
|
+
import { getNotificationsTool } from './getNotifications.js';
|
|
20
|
+
import { getNotificationsCountTool } from './getNotificationsCount.js';
|
|
21
|
+
import { getPrioritiesTool } from './getPriorities.js';
|
|
22
|
+
import { getProjectTool } from './getProject.js';
|
|
23
|
+
import { getProjectListTool } from './getProjectList.js';
|
|
24
|
+
import { getPullRequestTool } from './getPullRequest.js';
|
|
25
|
+
import { getPullRequestCommentsTool } from './getPullRequestComments.js';
|
|
26
|
+
import { getPullRequestsTool } from './getPullRequests.js';
|
|
27
|
+
import { getPullRequestsCountTool } from './getPullRequestsCount.js';
|
|
28
|
+
import { getResolutionsTool } from './getResolutions.js';
|
|
29
|
+
import { getSpaceTool } from './getSpace.js';
|
|
30
|
+
import { getUsersTool } from './getUsers.js';
|
|
31
|
+
import { getWatchingListCountTool } from './getWatchingListCount.js';
|
|
32
|
+
import { getWatchingListItemsTool } from './getWatchingListItems.js';
|
|
33
|
+
import { getWikiTool } from './getWiki.js';
|
|
34
|
+
import { getWikiPagesTool } from './getWikiPages.js';
|
|
35
|
+
import { getWikisCountTool } from './getWikisCount.js';
|
|
36
|
+
import { markNotificationAsReadTool } from './markNotificationAsRead.js';
|
|
37
|
+
import { resetUnreadNotificationCountTool } from './resetUnreadNotificationCount.js';
|
|
38
|
+
import { updateIssueTool } from './updateIssue.js';
|
|
39
|
+
import { updateProjectTool } from './updateProject.js';
|
|
40
|
+
import { updatePullRequestTool } from './updatePullRequest.js';
|
|
41
|
+
import { updatePullRequestCommentTool } from './updatePullRequestComment.js';
|
|
42
|
+
import { getDocumentTool } from './getDocument.js';
|
|
43
|
+
import { getDocumentsTool } from './getDocuments.js';
|
|
44
|
+
import { getDocumentTreeTool } from './getDocumentTree.js';
|
|
45
|
+
export const allTools = (backlog, helper) => {
|
|
46
|
+
return {
|
|
47
|
+
toolsets: [
|
|
48
|
+
{
|
|
49
|
+
name: 'space',
|
|
50
|
+
description: 'Tools for managing Backlog space settings and general information.',
|
|
51
|
+
enabled: false,
|
|
52
|
+
tools: [
|
|
53
|
+
getSpaceTool(backlog, helper),
|
|
54
|
+
getUsersTool(backlog, helper),
|
|
55
|
+
getMyselfTool(backlog, helper),
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'project',
|
|
60
|
+
description: 'Tools for managing projects, categories, custom fields, and issue types.',
|
|
61
|
+
enabled: false,
|
|
62
|
+
tools: [
|
|
63
|
+
getProjectListTool(backlog, helper),
|
|
64
|
+
addProjectTool(backlog, helper),
|
|
65
|
+
getProjectTool(backlog, helper),
|
|
66
|
+
updateProjectTool(backlog, helper),
|
|
67
|
+
deleteProjectTool(backlog, helper),
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'issue',
|
|
72
|
+
description: 'Tools for managing issues and their comments.',
|
|
73
|
+
enabled: false,
|
|
74
|
+
tools: [
|
|
75
|
+
getIssueTool(backlog, helper),
|
|
76
|
+
getIssuesTool(backlog, helper),
|
|
77
|
+
countIssuesTool(backlog, helper),
|
|
78
|
+
addIssueTool(backlog, helper),
|
|
79
|
+
updateIssueTool(backlog, helper),
|
|
80
|
+
deleteIssueTool(backlog, helper),
|
|
81
|
+
getIssueCommentsTool(backlog, helper),
|
|
82
|
+
addIssueCommentTool(backlog, helper),
|
|
83
|
+
getPrioritiesTool(backlog, helper),
|
|
84
|
+
getCategoriesTool(backlog, helper),
|
|
85
|
+
getCustomFieldsTool(backlog, helper),
|
|
86
|
+
getIssueTypesTool(backlog, helper),
|
|
87
|
+
getResolutionsTool(backlog, helper),
|
|
88
|
+
getWatchingListItemsTool(backlog, helper),
|
|
89
|
+
getWatchingListCountTool(backlog, helper),
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'wiki',
|
|
94
|
+
description: 'Tools for managing wiki pages.',
|
|
95
|
+
enabled: false,
|
|
96
|
+
tools: [
|
|
97
|
+
getWikiPagesTool(backlog, helper),
|
|
98
|
+
getWikisCountTool(backlog, helper),
|
|
99
|
+
getWikiTool(backlog, helper),
|
|
100
|
+
addWikiTool(backlog, helper),
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'git',
|
|
105
|
+
description: 'Tools for managing Git repositories and pull requests.',
|
|
106
|
+
enabled: false,
|
|
107
|
+
tools: [
|
|
108
|
+
getGitRepositoriesTool(backlog, helper),
|
|
109
|
+
getGitRepositoryTool(backlog, helper),
|
|
110
|
+
getPullRequestsTool(backlog, helper),
|
|
111
|
+
getPullRequestsCountTool(backlog, helper),
|
|
112
|
+
getPullRequestTool(backlog, helper),
|
|
113
|
+
addPullRequestTool(backlog, helper),
|
|
114
|
+
updatePullRequestTool(backlog, helper),
|
|
115
|
+
getPullRequestCommentsTool(backlog, helper),
|
|
116
|
+
addPullRequestCommentTool(backlog, helper),
|
|
117
|
+
updatePullRequestCommentTool(backlog, helper),
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'document',
|
|
122
|
+
description: 'Tools for managing documents.',
|
|
123
|
+
enabled: false,
|
|
124
|
+
tools: [
|
|
125
|
+
getDocumentsTool(backlog, helper),
|
|
126
|
+
getDocumentTreeTool(backlog, helper),
|
|
127
|
+
getDocumentTool(backlog, helper),
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'notifications',
|
|
132
|
+
description: 'Tools for managing user notifications.',
|
|
133
|
+
enabled: false,
|
|
134
|
+
tools: [
|
|
135
|
+
getNotificationsTool(backlog, helper),
|
|
136
|
+
getNotificationsCountTool(backlog, helper),
|
|
137
|
+
resetUnreadNotificationCountTool(backlog, helper),
|
|
138
|
+
markNotificationAsReadTool(backlog, helper),
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
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.union([z.string().max(255), z.number(), z.array(z.string())]),
|
|
89
|
+
otherValue: z
|
|
90
|
+
.string()
|
|
91
|
+
.optional()
|
|
92
|
+
.describe(t('TOOL_UPDATE_ISSUE_CUSTOM_FIELD_OTHER_VALUE', 'Other value for list type fields')),
|
|
93
|
+
}))
|
|
94
|
+
.optional()
|
|
95
|
+
.describe(t('TOOL_UPDATE_ISSUE_CUSTOM_FIELDS', 'List of custom fields to set on the issue')),
|
|
96
|
+
}));
|
|
97
|
+
export const updateIssueTool = (backlog, { t }) => {
|
|
98
|
+
return {
|
|
99
|
+
name: 'update_issue',
|
|
100
|
+
description: t('TOOL_UPDATE_ISSUE_DESCRIPTION', 'Updates an existing issue'),
|
|
101
|
+
schema: z.object(updateIssueSchema(t)),
|
|
102
|
+
outputSchema: IssueSchema,
|
|
103
|
+
handler: async ({ issueId, issueKey, customFields, ...params }) => {
|
|
104
|
+
const result = resolveIdOrKey('issue', { id: issueId, key: issueKey }, t);
|
|
105
|
+
if (!result.ok) {
|
|
106
|
+
throw result.error;
|
|
107
|
+
}
|
|
108
|
+
const customFieldPayload = customFieldsToPayload(customFields);
|
|
109
|
+
const finalPayload = {
|
|
110
|
+
...params,
|
|
111
|
+
...customFieldPayload,
|
|
112
|
+
};
|
|
113
|
+
return backlog.patchIssue(result.value, finalPayload);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { ProjectSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
import { resolveIdOrKey } from '../utils/resolveIdOrKey.js';
|
|
5
|
+
const updateProjectSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_UPDATE_PROJECT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_UPDATE_PROJECT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
name: z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(t('TOOL_UPDATE_PROJECT_NAME', 'Project name')),
|
|
18
|
+
key: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(t('TOOL_UPDATE_PROJECT_KEY', 'Project key')),
|
|
22
|
+
chartEnabled: z
|
|
23
|
+
.boolean()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe(t('TOOL_UPDATE_PROJECT_CHART_ENABLED', 'Whether to enable chart')),
|
|
26
|
+
subtaskingEnabled: z
|
|
27
|
+
.boolean()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe(t('TOOL_UPDATE_PROJECT_SUBTASKING_ENABLED', 'Whether to enable subtasking')),
|
|
30
|
+
projectLeaderCanEditProjectLeader: z
|
|
31
|
+
.boolean()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe(t('TOOL_UPDATE_PROJECT_LEADER_CAN_EDIT', 'Whether project leaders can edit other project leaders')),
|
|
34
|
+
textFormattingRule: z
|
|
35
|
+
.enum(['backlog', 'markdown'])
|
|
36
|
+
.optional()
|
|
37
|
+
.describe(t('TOOL_UPDATE_PROJECT_TEXT_FORMATTING', 'Text formatting rule')),
|
|
38
|
+
archived: z
|
|
39
|
+
.boolean()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe(t('TOOL_UPDATE_PROJECT_ARCHIVED', 'Whether to archive the project')),
|
|
42
|
+
}));
|
|
43
|
+
export const updateProjectTool = (backlog, { t }) => {
|
|
44
|
+
return {
|
|
45
|
+
name: 'update_project',
|
|
46
|
+
description: t('TOOL_UPDATE_PROJECT_DESCRIPTION', 'Updates an existing project'),
|
|
47
|
+
schema: z.object(updateProjectSchema(t)),
|
|
48
|
+
outputSchema: ProjectSchema,
|
|
49
|
+
handler: async ({ projectId, projectKey, ...param }) => {
|
|
50
|
+
const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
|
|
51
|
+
if (!result.ok) {
|
|
52
|
+
throw result.error;
|
|
53
|
+
}
|
|
54
|
+
return backlog.patchProject(result.value, param);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { PullRequestSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
import { resolveIdOrKey } from '../utils/resolveIdOrKey.js';
|
|
5
|
+
const updatePullRequestSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
repoId: z
|
|
15
|
+
.number()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_REPO_ID', 'Repository ID')),
|
|
18
|
+
repoName: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_REPO_NAME', 'Repository name')),
|
|
22
|
+
number: z
|
|
23
|
+
.number()
|
|
24
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_NUMBER', 'Pull request number')),
|
|
25
|
+
summary: z
|
|
26
|
+
.string()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_SUMMARY', 'Summary of the pull request')),
|
|
29
|
+
description: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_DESCRIPTION', 'Description of the pull request')),
|
|
33
|
+
issueId: z
|
|
34
|
+
.number()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_ISSUE_ID', 'Issue ID to link')),
|
|
37
|
+
assigneeId: z
|
|
38
|
+
.number()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_ASSIGNEE_ID', 'User ID of the assignee')),
|
|
41
|
+
notifiedUserId: z
|
|
42
|
+
.array(z.number())
|
|
43
|
+
.optional()
|
|
44
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_NOTIFIED_USER_ID', 'User IDs to notify')),
|
|
45
|
+
statusId: z
|
|
46
|
+
.number()
|
|
47
|
+
.optional()
|
|
48
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_STATUS_ID', 'Status ID')),
|
|
49
|
+
}));
|
|
50
|
+
export const updatePullRequestTool = (backlog, { t }) => {
|
|
51
|
+
return {
|
|
52
|
+
name: 'update_pull_request',
|
|
53
|
+
description: t('TOOL_UPDATE_PULL_REQUEST_DESCRIPTION', 'Updates an existing pull request'),
|
|
54
|
+
schema: z.object(updatePullRequestSchema(t)),
|
|
55
|
+
outputSchema: PullRequestSchema,
|
|
56
|
+
handler: async ({ projectId, projectKey, repoId, repoName, number, ...params }) => {
|
|
57
|
+
const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
|
|
58
|
+
if (!result.ok) {
|
|
59
|
+
throw result.error;
|
|
60
|
+
}
|
|
61
|
+
const resultRepo = resolveIdOrKey('repository', { id: repoId, key: repoName }, t);
|
|
62
|
+
if (!resultRepo.ok) {
|
|
63
|
+
throw resultRepo.error;
|
|
64
|
+
}
|
|
65
|
+
return backlog.patchPullRequest(result.value, String(resultRepo.value), number, params);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { PullRequestCommentSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
import { resolveIdOrKey, resolveIdOrName } from '../utils/resolveIdOrKey.js';
|
|
5
|
+
const updatePullRequestCommentSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
repoId: z
|
|
15
|
+
.number()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_REPO_ID', 'Repository ID')),
|
|
18
|
+
repoName: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_REPO_NAME', 'Repository name')),
|
|
22
|
+
number: z
|
|
23
|
+
.number()
|
|
24
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_NUMBER', 'Pull request number')),
|
|
25
|
+
commentId: z
|
|
26
|
+
.number()
|
|
27
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_COMMENT_ID', 'Comment ID')),
|
|
28
|
+
content: z
|
|
29
|
+
.string()
|
|
30
|
+
.describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_CONTENT', 'Comment content')),
|
|
31
|
+
}));
|
|
32
|
+
export const updatePullRequestCommentTool = (backlog, { t }) => {
|
|
33
|
+
return {
|
|
34
|
+
name: 'update_pull_request_comment',
|
|
35
|
+
description: t('TOOL_UPDATE_PULL_REQUEST_COMMENT_DESCRIPTION', 'Updates a comment on a pull request'),
|
|
36
|
+
schema: z.object(updatePullRequestCommentSchema(t)),
|
|
37
|
+
outputSchema: PullRequestCommentSchema,
|
|
38
|
+
importantFields: ['id', 'content', 'createdUser', 'updated'],
|
|
39
|
+
handler: async ({ projectId, projectKey, repoId, repoName, number, commentId, content, }) => {
|
|
40
|
+
const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
|
|
41
|
+
if (!result.ok) {
|
|
42
|
+
throw result.error;
|
|
43
|
+
}
|
|
44
|
+
const repoResult = resolveIdOrName('repository', { id: repoId, name: repoName }, t);
|
|
45
|
+
if (!repoResult.ok) {
|
|
46
|
+
throw repoResult.error;
|
|
47
|
+
}
|
|
48
|
+
return backlog.patchPullRequestComments(result.value, String(repoResult.value), number, commentId, { content });
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const buildToolSchema = (fn) => fn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|