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,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { NotificationCountSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
const getNotificationsCountSchema = buildToolSchema((t) => ({
|
|
5
|
+
alreadyRead: z
|
|
6
|
+
.boolean()
|
|
7
|
+
.describe(t('TOOL_GET_NOTIFICATIONS_COUNT_ALREADY_READ', 'Whether to include already read notifications')),
|
|
8
|
+
resourceAlreadyRead: z
|
|
9
|
+
.boolean()
|
|
10
|
+
.describe(t('TOOL_GET_NOTIFICATIONS_COUNT_RESOURCE_ALREADY_READ', 'Whether to include notifications for already read resources')),
|
|
11
|
+
}));
|
|
12
|
+
export const getNotificationsCountTool = (backlog, { t }) => {
|
|
13
|
+
return {
|
|
14
|
+
name: 'count_notifications',
|
|
15
|
+
description: t('TOOL_COUNT_NOTIFICATIONS_DESCRIPTION', 'Returns count of notifications'),
|
|
16
|
+
schema: z.object(getNotificationsCountSchema(t)),
|
|
17
|
+
outputSchema: NotificationCountSchema,
|
|
18
|
+
handler: async (params) => backlog.getNotificationsCount(params),
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { PrioritySchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
const getPrioritiesSchema = buildToolSchema((_t) => ({}));
|
|
5
|
+
export const getPrioritiesTool = (backlog, { t }) => {
|
|
6
|
+
return {
|
|
7
|
+
name: 'get_priorities',
|
|
8
|
+
description: t('TOOL_GET_PRIORITIES_DESCRIPTION', 'Returns list of priorities'),
|
|
9
|
+
schema: z.object(getPrioritiesSchema(t)),
|
|
10
|
+
outputSchema: PrioritySchema,
|
|
11
|
+
handler: async () => backlog.getPriorities(),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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 getProjectSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_GET_PROJECT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_GET_PROJECT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
}));
|
|
15
|
+
export const getProjectTool = (backlog, { t }) => {
|
|
16
|
+
return {
|
|
17
|
+
name: 'get_project',
|
|
18
|
+
description: t('TOOL_GET_PROJECT_DESCRIPTION', 'Returns information about a specific project'),
|
|
19
|
+
schema: z.object(getProjectSchema(t)),
|
|
20
|
+
outputSchema: ProjectSchema,
|
|
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.getProject(result.value);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { ProjectSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
const getProjectListSchema = buildToolSchema((t) => ({
|
|
5
|
+
archived: z
|
|
6
|
+
.boolean()
|
|
7
|
+
.optional()
|
|
8
|
+
.describe(t('TOOL_GET_PROJECT_LIST_ARCHIVED', 'For unspecified parameters, this form returns all projects. For ‘false’ parameters, it returns unarchived projects. For ‘true’ parameters, it returns archived projects.')),
|
|
9
|
+
all: z
|
|
10
|
+
.boolean()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe(t('TOOL_GET_PROJECT_LIST_ALL', 'Only applies to administrators. If ‘true,’ it returns all projects. If ‘false,’ it returns only projects they have joined.')),
|
|
13
|
+
}));
|
|
14
|
+
export const getProjectListTool = (backlog, { t }) => {
|
|
15
|
+
return {
|
|
16
|
+
name: 'get_project_list',
|
|
17
|
+
description: t('TOOL_GET_PROJECT_LIST_DESCRIPTION', 'Returns list of projects'),
|
|
18
|
+
schema: z.object(getProjectListSchema(t)),
|
|
19
|
+
outputSchema: ProjectSchema,
|
|
20
|
+
importantFields: ['id', 'projectKey', 'name'],
|
|
21
|
+
handler: async ({ archived, all }) => backlog.getProjects({ archived, all }),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { PullRequestSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
import { resolveIdOrKey, resolveIdOrName } from '../utils/resolveIdOrKey.js';
|
|
5
|
+
const getPullRequestSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_GET_PULL_REQUEST_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_GET_PULL_REQUEST_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
repoId: z
|
|
15
|
+
.number()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(t('TOOL_GET_PULL_REQUEST_REPO_ID', 'Repository ID')),
|
|
18
|
+
repoName: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(t('TOOL_GET_PULL_REQUEST_REPO_NAME', 'Repository name')),
|
|
22
|
+
number: z
|
|
23
|
+
.number()
|
|
24
|
+
.describe(t('TOOL_GET_PULL_REQUEST_NUMBER', 'Pull request number')),
|
|
25
|
+
}));
|
|
26
|
+
export const getPullRequestTool = (backlog, { t }) => {
|
|
27
|
+
return {
|
|
28
|
+
name: 'get_pull_request',
|
|
29
|
+
description: t('TOOL_GET_PULL_REQUEST_DESCRIPTION', 'Returns information about a specific pull request'),
|
|
30
|
+
schema: z.object(getPullRequestSchema(t)),
|
|
31
|
+
outputSchema: PullRequestSchema,
|
|
32
|
+
handler: async ({ projectId, projectKey, repoId, repoName, number }) => {
|
|
33
|
+
const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
|
|
34
|
+
if (!result.ok) {
|
|
35
|
+
throw result.error;
|
|
36
|
+
}
|
|
37
|
+
const repoRes = resolveIdOrName('repository', { id: repoId, name: repoName }, t);
|
|
38
|
+
if (!repoRes.ok) {
|
|
39
|
+
throw repoRes.error;
|
|
40
|
+
}
|
|
41
|
+
return backlog.getPullRequest(result.value, String(repoRes.value), number);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
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 getPullRequestCommentsSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_GET_PROJECT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_GET_PROJECT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
repoId: z
|
|
15
|
+
.number()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(t('TOOL_GET_PULL_REQUEST_COMMENTS_REPO_ID_OR_NAME', 'Repository ID')),
|
|
18
|
+
repoName: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(t('TOOL_GET_PULL_REQUEST_COMMENTS_REPO_ID_OR_NAME', 'Repository name')),
|
|
22
|
+
number: z
|
|
23
|
+
.number()
|
|
24
|
+
.describe(t('TOOL_GET_PULL_REQUEST_COMMENTS_NUMBER', 'Pull request number')),
|
|
25
|
+
minId: z
|
|
26
|
+
.number()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe(t('TOOL_GET_PULL_REQUEST_COMMENTS_MIN_ID', 'Minimum comment ID')),
|
|
29
|
+
maxId: z
|
|
30
|
+
.number()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe(t('TOOL_GET_PULL_REQUEST_COMMENTS_MAX_ID', 'Maximum comment ID')),
|
|
33
|
+
count: z
|
|
34
|
+
.number()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe(t('TOOL_GET_PULL_REQUEST_COMMENTS_COUNT', 'Number of comments to retrieve')),
|
|
37
|
+
order: z
|
|
38
|
+
.enum(['asc', 'desc'])
|
|
39
|
+
.optional()
|
|
40
|
+
.describe(t('TOOL_GET_PULL_REQUEST_COMMENTS_ORDER', 'Sort order')),
|
|
41
|
+
}));
|
|
42
|
+
export const getPullRequestCommentsTool = (backlog, { t }) => {
|
|
43
|
+
return {
|
|
44
|
+
name: 'get_pull_request_comments',
|
|
45
|
+
description: t('TOOL_GET_PULL_REQUEST_COMMENTS_DESCRIPTION', 'Returns list of comments for a pull request'),
|
|
46
|
+
schema: z.object(getPullRequestCommentsSchema(t)),
|
|
47
|
+
outputSchema: PullRequestCommentSchema,
|
|
48
|
+
handler: async ({ projectId, projectKey, repoId, repoName, number, ...params }) => {
|
|
49
|
+
const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
|
|
50
|
+
if (!result.ok) {
|
|
51
|
+
throw result.error;
|
|
52
|
+
}
|
|
53
|
+
const repoResult = resolveIdOrName('repository', { id: repoId, name: repoName }, t);
|
|
54
|
+
if (!repoResult.ok) {
|
|
55
|
+
throw repoResult.error;
|
|
56
|
+
}
|
|
57
|
+
return backlog.getPullRequestComments(result.value, String(repoResult.value), number, params);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { PullRequestSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
import { resolveIdOrKey, resolveIdOrName } from '../utils/resolveIdOrKey.js';
|
|
5
|
+
const getPullRequestsSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
repoId: z
|
|
15
|
+
.number()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_REPO_ID', 'Repository ID')),
|
|
18
|
+
repoName: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_REPO_NAME', 'Repository name')),
|
|
22
|
+
statusId: z
|
|
23
|
+
.array(z.number())
|
|
24
|
+
.optional()
|
|
25
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_STATUS_ID', 'Status IDs')),
|
|
26
|
+
assigneeId: z
|
|
27
|
+
.array(z.number())
|
|
28
|
+
.optional()
|
|
29
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_ASSIGNEE_ID', 'Assignee user IDs')),
|
|
30
|
+
issueId: z
|
|
31
|
+
.array(z.number())
|
|
32
|
+
.optional()
|
|
33
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_ISSUE_ID', 'Issue IDs')),
|
|
34
|
+
createdUserId: z
|
|
35
|
+
.array(z.number())
|
|
36
|
+
.optional()
|
|
37
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_CREATED_USER_ID', 'Created user IDs')),
|
|
38
|
+
offset: z
|
|
39
|
+
.number()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_OFFSET', 'Offset for pagination')),
|
|
42
|
+
count: z
|
|
43
|
+
.number()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT', 'Number of pull requests to retrieve')),
|
|
46
|
+
}));
|
|
47
|
+
export const getPullRequestsTool = (backlog, { t }) => {
|
|
48
|
+
return {
|
|
49
|
+
name: 'get_pull_requests',
|
|
50
|
+
description: t('TOOL_GET_PULL_REQUESTS_DESCRIPTION', 'Returns list of pull requests for a repository'),
|
|
51
|
+
schema: z.object(getPullRequestsSchema(t)),
|
|
52
|
+
outputSchema: PullRequestSchema,
|
|
53
|
+
handler: async ({ projectId, projectKey, repoId, repoName, ...params }) => {
|
|
54
|
+
const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
|
|
55
|
+
if (!result.ok) {
|
|
56
|
+
throw result.error;
|
|
57
|
+
}
|
|
58
|
+
const repoResult = resolveIdOrName('repository', { id: repoId, name: repoName }, t);
|
|
59
|
+
if (!repoResult.ok) {
|
|
60
|
+
throw repoResult.error;
|
|
61
|
+
}
|
|
62
|
+
return backlog.getPullRequests(result.value, String(repoResult.value), params);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolSchema } from '../types/tool.js';
|
|
3
|
+
import { PullRequestCountSchema } from '../types/zod/backlogOutputDefinition.js';
|
|
4
|
+
import { resolveIdOrKey, resolveIdOrName } from '../utils/resolveIdOrKey.js';
|
|
5
|
+
const getPullRequestsCountSchema = buildToolSchema((t) => ({
|
|
6
|
+
projectId: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)')),
|
|
10
|
+
projectKey: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')")),
|
|
14
|
+
repoId: z
|
|
15
|
+
.number()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_REPO_ID', 'Repository ID')),
|
|
18
|
+
repoName: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_REPO_NAME', 'Repository name')),
|
|
22
|
+
statusId: z
|
|
23
|
+
.array(z.number())
|
|
24
|
+
.optional()
|
|
25
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_STATUS_ID', 'Status IDs')),
|
|
26
|
+
assigneeId: z
|
|
27
|
+
.array(z.number())
|
|
28
|
+
.optional()
|
|
29
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_ASSIGNEE_ID', 'Assignee user IDs')),
|
|
30
|
+
issueId: z
|
|
31
|
+
.array(z.number())
|
|
32
|
+
.optional()
|
|
33
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_ISSUE_ID', 'Issue IDs')),
|
|
34
|
+
createdUserId: z
|
|
35
|
+
.array(z.number())
|
|
36
|
+
.optional()
|
|
37
|
+
.describe(t('TOOL_GET_PULL_REQUESTS_COUNT_CREATED_USER_ID', 'Created user IDs')),
|
|
38
|
+
}));
|
|
39
|
+
export const getPullRequestsCountTool = (backlog, { t }) => {
|
|
40
|
+
return {
|
|
41
|
+
name: 'get_pull_requests_count',
|
|
42
|
+
description: t('TOOL_GET_PULL_REQUESTS_COUNT_DESCRIPTION', 'Returns count of pull requests for a repository'),
|
|
43
|
+
schema: z.object(getPullRequestsCountSchema(t)),
|
|
44
|
+
outputSchema: PullRequestCountSchema,
|
|
45
|
+
handler: async ({ projectId, projectKey, repoId, repoName, ...params }) => {
|
|
46
|
+
const result = resolveIdOrKey('project', { id: projectId, key: projectKey }, t);
|
|
47
|
+
if (!result.ok) {
|
|
48
|
+
throw result.error;
|
|
49
|
+
}
|
|
50
|
+
const repoResult = resolveIdOrName('repository', { id: repoId, name: repoName }, t);
|
|
51
|
+
if (!repoResult.ok) {
|
|
52
|
+
throw repoResult.error;
|
|
53
|
+
}
|
|
54
|
+
return backlog.getPullRequestsCount(result.value, String(repoResult.value), params);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|