@lvmk/jira-mcp 1.0.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.md +583 -0
- package/dist/client.d.ts +287 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +235 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +54 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +66 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +222 -0
- package/dist/index.js.map +1 -0
- package/dist/setup.d.ts +41 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +275 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/issues.d.ts +363 -0
- package/dist/tools/issues.d.ts.map +1 -0
- package/dist/tools/issues.js +365 -0
- package/dist/tools/issues.js.map +1 -0
- package/dist/tools/projects.d.ts +69 -0
- package/dist/tools/projects.d.ts.map +1 -0
- package/dist/tools/projects.js +93 -0
- package/dist/tools/projects.js.map +1 -0
- package/dist/tools/search.d.ts +76 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +98 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/transitions.d.ts +98 -0
- package/dist/tools/transitions.d.ts.map +1 -0
- package/dist/tools/transitions.js +109 -0
- package/dist/tools/transitions.js.map +1 -0
- package/dist/tools/users.d.ts +69 -0
- package/dist/tools/users.d.ts.map +1 -0
- package/dist/tools/users.js +89 -0
- package/dist/tools/users.js.map +1 -0
- package/package.json +57 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file client.ts
|
|
3
|
+
* @description Jira REST API client with HTTP Basic Authentication.
|
|
4
|
+
* Provides typed methods for interacting with Jira Server v7.x API.
|
|
5
|
+
*/
|
|
6
|
+
import { JiraConfig } from './config.js';
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when Jira API requests fail.
|
|
9
|
+
*/
|
|
10
|
+
export declare class JiraApiError extends Error {
|
|
11
|
+
readonly statusCode: number;
|
|
12
|
+
readonly body?: unknown | undefined;
|
|
13
|
+
constructor(message: string, statusCode: number, body?: unknown | undefined);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Jira REST API client with basic authentication.
|
|
17
|
+
*/
|
|
18
|
+
export declare class JiraClient {
|
|
19
|
+
private readonly config;
|
|
20
|
+
private readonly apiBaseUrl;
|
|
21
|
+
private readonly authBaseUrl;
|
|
22
|
+
private readonly authHeader;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new Jira client instance.
|
|
25
|
+
* @param config - Validated Jira configuration
|
|
26
|
+
*/
|
|
27
|
+
constructor(config: JiraConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Makes an authenticated request to the Jira API.
|
|
30
|
+
* @param method - HTTP method
|
|
31
|
+
* @param path - API path (relative to base URL)
|
|
32
|
+
* @param body - Optional request body
|
|
33
|
+
* @param useAuthEndpoint - Whether to use auth endpoint instead of api endpoint
|
|
34
|
+
* @returns Parsed JSON response
|
|
35
|
+
*/
|
|
36
|
+
private request;
|
|
37
|
+
/**
|
|
38
|
+
* Gets current authenticated user session info.
|
|
39
|
+
* @returns Current user session data
|
|
40
|
+
*/
|
|
41
|
+
getCurrentSession(): Promise<JiraSession>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets an issue by key or ID.
|
|
44
|
+
* @param issueIdOrKey - Issue key (e.g., "PROJ-123") or ID
|
|
45
|
+
* @param fields - Optional comma-separated list of fields to return
|
|
46
|
+
* @param expand - Optional fields to expand
|
|
47
|
+
* @returns Issue data
|
|
48
|
+
*/
|
|
49
|
+
getIssue(issueIdOrKey: string, fields?: string, expand?: string): Promise<JiraIssue>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new issue.
|
|
52
|
+
* @param data - Issue creation data
|
|
53
|
+
* @returns Created issue reference
|
|
54
|
+
*/
|
|
55
|
+
createIssue(data: CreateIssueInput): Promise<CreatedIssue>;
|
|
56
|
+
/**
|
|
57
|
+
* Updates an existing issue.
|
|
58
|
+
* @param issueIdOrKey - Issue key or ID
|
|
59
|
+
* @param data - Fields to update
|
|
60
|
+
*/
|
|
61
|
+
updateIssue(issueIdOrKey: string, data: UpdateIssueInput): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Deletes an issue.
|
|
64
|
+
* @param issueIdOrKey - Issue key or ID
|
|
65
|
+
* @param deleteSubtasks - Whether to delete subtasks
|
|
66
|
+
*/
|
|
67
|
+
deleteIssue(issueIdOrKey: string, deleteSubtasks?: boolean): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Gets comments on an issue.
|
|
70
|
+
* @param issueIdOrKey - Issue key or ID
|
|
71
|
+
* @returns Comments data
|
|
72
|
+
*/
|
|
73
|
+
getComments(issueIdOrKey: string): Promise<CommentsResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Adds a comment to an issue.
|
|
76
|
+
* @param issueIdOrKey - Issue key or ID
|
|
77
|
+
* @param body - Comment body text
|
|
78
|
+
* @returns Created comment
|
|
79
|
+
*/
|
|
80
|
+
addComment(issueIdOrKey: string, body: string): Promise<JiraComment>;
|
|
81
|
+
/**
|
|
82
|
+
* Gets available transitions for an issue.
|
|
83
|
+
* @param issueIdOrKey - Issue key or ID
|
|
84
|
+
* @returns Available transitions
|
|
85
|
+
*/
|
|
86
|
+
getTransitions(issueIdOrKey: string): Promise<TransitionsResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Transitions an issue to a new status.
|
|
89
|
+
* @param issueIdOrKey - Issue key or ID
|
|
90
|
+
* @param transitionId - ID of the transition to execute
|
|
91
|
+
* @param comment - Optional comment to add
|
|
92
|
+
*/
|
|
93
|
+
transitionIssue(issueIdOrKey: string, transitionId: string, comment?: string): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Searches for issues using JQL.
|
|
96
|
+
* @param jql - JQL query string
|
|
97
|
+
* @param maxResults - Maximum results to return (default 50)
|
|
98
|
+
* @param startAt - Starting index for pagination
|
|
99
|
+
* @param fields - Fields to include in results
|
|
100
|
+
* @returns Search results
|
|
101
|
+
*/
|
|
102
|
+
search(jql: string, maxResults?: number, startAt?: number, fields?: string[]): Promise<SearchResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* Gets all accessible projects.
|
|
105
|
+
* @returns List of projects
|
|
106
|
+
*/
|
|
107
|
+
getProjects(): Promise<JiraProject[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Gets a project by key or ID.
|
|
110
|
+
* @param projectIdOrKey - Project key or ID
|
|
111
|
+
* @returns Project data
|
|
112
|
+
*/
|
|
113
|
+
getProject(projectIdOrKey: string): Promise<JiraProject>;
|
|
114
|
+
/**
|
|
115
|
+
* Gets the currently authenticated user.
|
|
116
|
+
* @returns Current user data
|
|
117
|
+
*/
|
|
118
|
+
getCurrentUser(): Promise<JiraUser>;
|
|
119
|
+
/**
|
|
120
|
+
* Gets a user by username.
|
|
121
|
+
* @param username - Username to look up
|
|
122
|
+
* @returns User data
|
|
123
|
+
*/
|
|
124
|
+
getUser(username: string): Promise<JiraUser>;
|
|
125
|
+
}
|
|
126
|
+
/** Session information from auth endpoint */
|
|
127
|
+
export interface JiraSession {
|
|
128
|
+
self: string;
|
|
129
|
+
name: string;
|
|
130
|
+
loginInfo: {
|
|
131
|
+
failedLoginCount: number;
|
|
132
|
+
loginCount: number;
|
|
133
|
+
lastFailedLoginTime?: string;
|
|
134
|
+
previousLoginTime?: string;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** Jira issue structure */
|
|
138
|
+
export interface JiraIssue {
|
|
139
|
+
id: string;
|
|
140
|
+
key: string;
|
|
141
|
+
self: string;
|
|
142
|
+
fields: {
|
|
143
|
+
summary: string;
|
|
144
|
+
description?: string;
|
|
145
|
+
status: {
|
|
146
|
+
name: string;
|
|
147
|
+
id: string;
|
|
148
|
+
};
|
|
149
|
+
priority?: {
|
|
150
|
+
name: string;
|
|
151
|
+
id: string;
|
|
152
|
+
};
|
|
153
|
+
assignee?: {
|
|
154
|
+
displayName: string;
|
|
155
|
+
name: string;
|
|
156
|
+
emailAddress?: string;
|
|
157
|
+
};
|
|
158
|
+
reporter?: {
|
|
159
|
+
displayName: string;
|
|
160
|
+
name: string;
|
|
161
|
+
};
|
|
162
|
+
issuetype: {
|
|
163
|
+
name: string;
|
|
164
|
+
id: string;
|
|
165
|
+
};
|
|
166
|
+
project: {
|
|
167
|
+
key: string;
|
|
168
|
+
name: string;
|
|
169
|
+
};
|
|
170
|
+
created: string;
|
|
171
|
+
updated: string;
|
|
172
|
+
labels?: string[];
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** Input for creating an issue */
|
|
177
|
+
export interface CreateIssueInput {
|
|
178
|
+
project: {
|
|
179
|
+
key: string;
|
|
180
|
+
} | {
|
|
181
|
+
id: string;
|
|
182
|
+
};
|
|
183
|
+
summary: string;
|
|
184
|
+
issuetype: {
|
|
185
|
+
name: string;
|
|
186
|
+
} | {
|
|
187
|
+
id: string;
|
|
188
|
+
};
|
|
189
|
+
description?: string;
|
|
190
|
+
assignee?: {
|
|
191
|
+
name: string;
|
|
192
|
+
};
|
|
193
|
+
priority?: {
|
|
194
|
+
name: string;
|
|
195
|
+
} | {
|
|
196
|
+
id: string;
|
|
197
|
+
};
|
|
198
|
+
labels?: string[];
|
|
199
|
+
[key: string]: unknown;
|
|
200
|
+
}
|
|
201
|
+
/** Response when creating an issue */
|
|
202
|
+
export interface CreatedIssue {
|
|
203
|
+
id: string;
|
|
204
|
+
key: string;
|
|
205
|
+
self: string;
|
|
206
|
+
}
|
|
207
|
+
/** Input for updating an issue */
|
|
208
|
+
export interface UpdateIssueInput {
|
|
209
|
+
summary?: string;
|
|
210
|
+
description?: string;
|
|
211
|
+
assignee?: {
|
|
212
|
+
name: string;
|
|
213
|
+
} | null;
|
|
214
|
+
priority?: {
|
|
215
|
+
name: string;
|
|
216
|
+
} | {
|
|
217
|
+
id: string;
|
|
218
|
+
};
|
|
219
|
+
labels?: string[];
|
|
220
|
+
[key: string]: unknown;
|
|
221
|
+
}
|
|
222
|
+
/** Jira comment structure */
|
|
223
|
+
export interface JiraComment {
|
|
224
|
+
id: string;
|
|
225
|
+
self: string;
|
|
226
|
+
author: {
|
|
227
|
+
displayName: string;
|
|
228
|
+
name: string;
|
|
229
|
+
};
|
|
230
|
+
body: string;
|
|
231
|
+
created: string;
|
|
232
|
+
updated: string;
|
|
233
|
+
}
|
|
234
|
+
/** Response containing comments */
|
|
235
|
+
export interface CommentsResponse {
|
|
236
|
+
startAt: number;
|
|
237
|
+
maxResults: number;
|
|
238
|
+
total: number;
|
|
239
|
+
comments: JiraComment[];
|
|
240
|
+
}
|
|
241
|
+
/** Transition information */
|
|
242
|
+
export interface JiraTransition {
|
|
243
|
+
id: string;
|
|
244
|
+
name: string;
|
|
245
|
+
to: {
|
|
246
|
+
id: string;
|
|
247
|
+
name: string;
|
|
248
|
+
statusCategory: {
|
|
249
|
+
name: string;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/** Response containing transitions */
|
|
254
|
+
export interface TransitionsResponse {
|
|
255
|
+
transitions: JiraTransition[];
|
|
256
|
+
}
|
|
257
|
+
/** Search response structure */
|
|
258
|
+
export interface SearchResponse {
|
|
259
|
+
startAt: number;
|
|
260
|
+
maxResults: number;
|
|
261
|
+
total: number;
|
|
262
|
+
issues: JiraIssue[];
|
|
263
|
+
}
|
|
264
|
+
/** Jira project structure */
|
|
265
|
+
export interface JiraProject {
|
|
266
|
+
id: string;
|
|
267
|
+
key: string;
|
|
268
|
+
name: string;
|
|
269
|
+
self: string;
|
|
270
|
+
projectTypeKey?: string;
|
|
271
|
+
lead?: {
|
|
272
|
+
displayName: string;
|
|
273
|
+
name: string;
|
|
274
|
+
};
|
|
275
|
+
description?: string;
|
|
276
|
+
}
|
|
277
|
+
/** Jira user structure */
|
|
278
|
+
export interface JiraUser {
|
|
279
|
+
self: string;
|
|
280
|
+
key: string;
|
|
281
|
+
name: string;
|
|
282
|
+
displayName: string;
|
|
283
|
+
emailAddress?: string;
|
|
284
|
+
active: boolean;
|
|
285
|
+
timeZone?: string;
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAiC,MAAM,aAAa,CAAC;AAExE;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;aAGf,UAAU,EAAE,MAAM;aAClB,IAAI,CAAC,EAAE,OAAO;gBAF9B,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,OAAO,YAAA;CAKrC;AAOD;;GAEG;AACH,qBAAa,UAAU;IASP,OAAO,CAAC,QAAQ,CAAC,MAAM;IARnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC;;;OAGG;gBAC0B,MAAM,EAAE,UAAU;IAS/C;;;;;;;OAOG;YACW,OAAO;IA2DrB;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,WAAW,CAAC;IAM/C;;;;;;OAMG;IACG,QAAQ,CACV,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,SAAS,CAAC;IAQrB;;;;OAIG;IACG,WAAW,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC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AE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file client.ts
|
|
3
|
+
* @description Jira REST API client with HTTP Basic Authentication.
|
|
4
|
+
* Provides typed methods for interacting with Jira Server v7.x API.
|
|
5
|
+
*/
|
|
6
|
+
import { getApiBaseUrl, getAuthBaseUrl } from './config.js';
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when Jira API requests fail.
|
|
9
|
+
*/
|
|
10
|
+
export class JiraApiError extends Error {
|
|
11
|
+
statusCode;
|
|
12
|
+
body;
|
|
13
|
+
constructor(message, statusCode, body) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.statusCode = statusCode;
|
|
16
|
+
this.body = body;
|
|
17
|
+
this.name = 'JiraApiError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Jira REST API client with basic authentication.
|
|
22
|
+
*/
|
|
23
|
+
export class JiraClient {
|
|
24
|
+
config;
|
|
25
|
+
apiBaseUrl;
|
|
26
|
+
authBaseUrl;
|
|
27
|
+
authHeader;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new Jira client instance.
|
|
30
|
+
* @param config - Validated Jira configuration
|
|
31
|
+
*/
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.config = config;
|
|
34
|
+
this.apiBaseUrl = getApiBaseUrl(config);
|
|
35
|
+
this.authBaseUrl = getAuthBaseUrl(config);
|
|
36
|
+
// Generate Basic auth header: base64(username:password)
|
|
37
|
+
this.authHeader = `Basic ${Buffer.from(`${config.JIRA_USERNAME}:${config.JIRA_PASSWORD}`).toString('base64')}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Makes an authenticated request to the Jira API.
|
|
41
|
+
* @param method - HTTP method
|
|
42
|
+
* @param path - API path (relative to base URL)
|
|
43
|
+
* @param body - Optional request body
|
|
44
|
+
* @param useAuthEndpoint - Whether to use auth endpoint instead of api endpoint
|
|
45
|
+
* @returns Parsed JSON response
|
|
46
|
+
*/
|
|
47
|
+
async request(method, path, body, useAuthEndpoint = false) {
|
|
48
|
+
const baseUrl = useAuthEndpoint ? this.authBaseUrl : this.apiBaseUrl;
|
|
49
|
+
const url = `${baseUrl}${path}`;
|
|
50
|
+
const headers = {
|
|
51
|
+
Authorization: this.authHeader,
|
|
52
|
+
Accept: 'application/json',
|
|
53
|
+
};
|
|
54
|
+
if (body) {
|
|
55
|
+
headers['Content-Type'] = 'application/json';
|
|
56
|
+
}
|
|
57
|
+
const response = await fetch(url, {
|
|
58
|
+
method,
|
|
59
|
+
headers,
|
|
60
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
61
|
+
});
|
|
62
|
+
// Handle empty responses (e.g., 204 No Content)
|
|
63
|
+
if (response.status === 204 || response.headers.get('content-length') === '0') {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
const responseBody = await response.text();
|
|
67
|
+
let parsedBody;
|
|
68
|
+
try {
|
|
69
|
+
parsedBody = responseBody ? JSON.parse(responseBody) : {};
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
parsedBody = responseBody;
|
|
73
|
+
}
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
let errorMessage = `Request failed with status ${response.status}`;
|
|
76
|
+
if (typeof parsedBody === 'object' && parsedBody !== null) {
|
|
77
|
+
const bodyRecord = parsedBody;
|
|
78
|
+
const errorMessages = bodyRecord.errorMessages;
|
|
79
|
+
if (Array.isArray(errorMessages) && errorMessages.length > 0) {
|
|
80
|
+
errorMessage = String(errorMessages[0]);
|
|
81
|
+
}
|
|
82
|
+
else if (typeof bodyRecord.message === 'string') {
|
|
83
|
+
errorMessage = bodyRecord.message;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
throw new JiraApiError(errorMessage, response.status, parsedBody);
|
|
87
|
+
}
|
|
88
|
+
return parsedBody;
|
|
89
|
+
}
|
|
90
|
+
// ============ Session/Auth Methods ============
|
|
91
|
+
/**
|
|
92
|
+
* Gets current authenticated user session info.
|
|
93
|
+
* @returns Current user session data
|
|
94
|
+
*/
|
|
95
|
+
async getCurrentSession() {
|
|
96
|
+
return this.request('GET', '/session', undefined, true);
|
|
97
|
+
}
|
|
98
|
+
// ============ Issue Methods ============
|
|
99
|
+
/**
|
|
100
|
+
* Gets an issue by key or ID.
|
|
101
|
+
* @param issueIdOrKey - Issue key (e.g., "PROJ-123") or ID
|
|
102
|
+
* @param fields - Optional comma-separated list of fields to return
|
|
103
|
+
* @param expand - Optional fields to expand
|
|
104
|
+
* @returns Issue data
|
|
105
|
+
*/
|
|
106
|
+
async getIssue(issueIdOrKey, fields, expand) {
|
|
107
|
+
const params = new URLSearchParams();
|
|
108
|
+
if (fields)
|
|
109
|
+
params.set('fields', fields);
|
|
110
|
+
if (expand)
|
|
111
|
+
params.set('expand', expand);
|
|
112
|
+
const query = params.toString() ? `?${params.toString()}` : '';
|
|
113
|
+
return this.request('GET', `/issue/${issueIdOrKey}${query}`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates a new issue.
|
|
117
|
+
* @param data - Issue creation data
|
|
118
|
+
* @returns Created issue reference
|
|
119
|
+
*/
|
|
120
|
+
async createIssue(data) {
|
|
121
|
+
return this.request('POST', '/issue', { fields: data });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Updates an existing issue.
|
|
125
|
+
* @param issueIdOrKey - Issue key or ID
|
|
126
|
+
* @param data - Fields to update
|
|
127
|
+
*/
|
|
128
|
+
async updateIssue(issueIdOrKey, data) {
|
|
129
|
+
await this.request('PUT', `/issue/${issueIdOrKey}`, { fields: data });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Deletes an issue.
|
|
133
|
+
* @param issueIdOrKey - Issue key or ID
|
|
134
|
+
* @param deleteSubtasks - Whether to delete subtasks
|
|
135
|
+
*/
|
|
136
|
+
async deleteIssue(issueIdOrKey, deleteSubtasks = false) {
|
|
137
|
+
const query = deleteSubtasks ? '?deleteSubtasks=true' : '';
|
|
138
|
+
await this.request('DELETE', `/issue/${issueIdOrKey}${query}`);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Gets comments on an issue.
|
|
142
|
+
* @param issueIdOrKey - Issue key or ID
|
|
143
|
+
* @returns Comments data
|
|
144
|
+
*/
|
|
145
|
+
async getComments(issueIdOrKey) {
|
|
146
|
+
return this.request('GET', `/issue/${issueIdOrKey}/comment`);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Adds a comment to an issue.
|
|
150
|
+
* @param issueIdOrKey - Issue key or ID
|
|
151
|
+
* @param body - Comment body text
|
|
152
|
+
* @returns Created comment
|
|
153
|
+
*/
|
|
154
|
+
async addComment(issueIdOrKey, body) {
|
|
155
|
+
return this.request('POST', `/issue/${issueIdOrKey}/comment`, {
|
|
156
|
+
body,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// ============ Transition Methods ============
|
|
160
|
+
/**
|
|
161
|
+
* Gets available transitions for an issue.
|
|
162
|
+
* @param issueIdOrKey - Issue key or ID
|
|
163
|
+
* @returns Available transitions
|
|
164
|
+
*/
|
|
165
|
+
async getTransitions(issueIdOrKey) {
|
|
166
|
+
return this.request('GET', `/issue/${issueIdOrKey}/transitions`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Transitions an issue to a new status.
|
|
170
|
+
* @param issueIdOrKey - Issue key or ID
|
|
171
|
+
* @param transitionId - ID of the transition to execute
|
|
172
|
+
* @param comment - Optional comment to add
|
|
173
|
+
*/
|
|
174
|
+
async transitionIssue(issueIdOrKey, transitionId, comment) {
|
|
175
|
+
const body = {
|
|
176
|
+
transition: { id: transitionId },
|
|
177
|
+
};
|
|
178
|
+
if (comment) {
|
|
179
|
+
body.update = {
|
|
180
|
+
comment: [{ add: { body: comment } }],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
await this.request('POST', `/issue/${issueIdOrKey}/transitions`, body);
|
|
184
|
+
}
|
|
185
|
+
// ============ Search Methods ============
|
|
186
|
+
/**
|
|
187
|
+
* Searches for issues using JQL.
|
|
188
|
+
* @param jql - JQL query string
|
|
189
|
+
* @param maxResults - Maximum results to return (default 50)
|
|
190
|
+
* @param startAt - Starting index for pagination
|
|
191
|
+
* @param fields - Fields to include in results
|
|
192
|
+
* @returns Search results
|
|
193
|
+
*/
|
|
194
|
+
async search(jql, maxResults = 50, startAt = 0, fields) {
|
|
195
|
+
return this.request('POST', '/search', {
|
|
196
|
+
jql,
|
|
197
|
+
maxResults,
|
|
198
|
+
startAt,
|
|
199
|
+
fields: fields ?? ['summary', 'status', 'assignee', 'priority', 'issuetype'],
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// ============ Project Methods ============
|
|
203
|
+
/**
|
|
204
|
+
* Gets all accessible projects.
|
|
205
|
+
* @returns List of projects
|
|
206
|
+
*/
|
|
207
|
+
async getProjects() {
|
|
208
|
+
return this.request('GET', '/project');
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Gets a project by key or ID.
|
|
212
|
+
* @param projectIdOrKey - Project key or ID
|
|
213
|
+
* @returns Project data
|
|
214
|
+
*/
|
|
215
|
+
async getProject(projectIdOrKey) {
|
|
216
|
+
return this.request('GET', `/project/${projectIdOrKey}`);
|
|
217
|
+
}
|
|
218
|
+
// ============ User Methods ============
|
|
219
|
+
/**
|
|
220
|
+
* Gets the currently authenticated user.
|
|
221
|
+
* @returns Current user data
|
|
222
|
+
*/
|
|
223
|
+
async getCurrentUser() {
|
|
224
|
+
return this.request('GET', '/myself');
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Gets a user by username.
|
|
228
|
+
* @param username - Username to look up
|
|
229
|
+
* @returns User data
|
|
230
|
+
*/
|
|
231
|
+
async getUser(username) {
|
|
232
|
+
return this.request('GET', `/user?username=${encodeURIComponent(username)}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAc,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAExE;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAGf;IACA;IAHpB,YACI,OAAe,EACC,UAAkB,EAClB,IAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC/B,CAAC;CACJ;AAOD;;GAEG;AACH,MAAM,OAAO,UAAU;IASU;IARZ,UAAU,CAAS;IACnB,WAAW,CAAS;IACpB,UAAU,CAAS;IAEpC;;;OAGG;IACH,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAC3C,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAC1C,wDAAwD;QACxD,IAAI,CAAC,UAAU,GAAG,SAAS,MAAM,CAAC,IAAI,CAClC,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,aAAa,EAAE,CACpD,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACK,KAAK,CAAC,OAAO,CACjB,MAAkB,EAClB,IAAY,EACZ,IAAc,EACd,eAAe,GAAG,KAAK;QAEvB,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QACrE,MAAM,GAAG,GAA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,EAAE,CAAC;aACxC,CAAC;QACN,CAAC;QACD,MAAM,IAAI,CAAC,OAAO,CAAO,MAAM,EAAE,UAAU,YAAY,cAAc,EAAE,IAAI,CAAC,CAAC;IACjF,CAAC;IAED,2CAA2C;IAE3C;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CACR,GAAW,EACX,UAAU,GAAG,EAAE,EACf,OAAO,GAAG,CAAC,EACX,MAAiB;QAEjB,OAAO,IAAI,CAAC,OAAO,CAAiB,MAAM,EAAE,SAAS,EAAE;YACnD,GAAG;YACH,UAAU;YACV,OAAO;YACP,MAAM,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC;SAC/E,CAAC,CAAC;IACP,CAAC;IAED,4CAA4C;IAE5C;;;OAGG;IACH,KAAK,CAAC,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAgB,KAAK,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,cAAsB;QACnC,OAAO,IAAI,CAAC,OAAO,CAAc,KAAK,EAAE,YAAY,cAAc,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,yCAAyC;IAEzC;;;OAGG;IACH,KAAK,CAAC,cAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAW,KAAK,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,QAAgB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAW,KAAK,EAAE,kBAAkB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3F,CAAC;CACJ"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file config.ts
|
|
3
|
+
* @description Configuration module for Jira MCP server.
|
|
4
|
+
* Handles environment variable parsing and validation.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Environment variable schema for Jira configuration.
|
|
9
|
+
* Validates required and optional configuration values.
|
|
10
|
+
*/
|
|
11
|
+
declare const configSchema: z.ZodObject<{
|
|
12
|
+
/** Base URL of the Jira instance (e.g., http://jira.example.com:8080) */
|
|
13
|
+
JIRA_BASE_URL: z.ZodString;
|
|
14
|
+
/** Username for basic authentication */
|
|
15
|
+
JIRA_USERNAME: z.ZodString;
|
|
16
|
+
/** Password for basic authentication */
|
|
17
|
+
JIRA_PASSWORD: z.ZodString;
|
|
18
|
+
/** API version (defaults to "2") */
|
|
19
|
+
JIRA_API_VERSION: z.ZodDefault<z.ZodString>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
JIRA_BASE_URL: string;
|
|
22
|
+
JIRA_USERNAME: string;
|
|
23
|
+
JIRA_PASSWORD: string;
|
|
24
|
+
JIRA_API_VERSION: string;
|
|
25
|
+
}, {
|
|
26
|
+
JIRA_BASE_URL: string;
|
|
27
|
+
JIRA_USERNAME: string;
|
|
28
|
+
JIRA_PASSWORD: string;
|
|
29
|
+
JIRA_API_VERSION?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Validated configuration type inferred from schema.
|
|
33
|
+
*/
|
|
34
|
+
export type JiraConfig = z.infer<typeof configSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* Loads and validates configuration from environment variables.
|
|
37
|
+
* @returns Validated configuration object
|
|
38
|
+
* @throws Error if required environment variables are missing or invalid
|
|
39
|
+
*/
|
|
40
|
+
export declare function loadConfig(): JiraConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Constructs the full REST API base URL.
|
|
43
|
+
* @param config - Validated configuration
|
|
44
|
+
* @returns Full API base URL (e.g., http://jira.example.com:8080/rest/api/2)
|
|
45
|
+
*/
|
|
46
|
+
export declare function getApiBaseUrl(config: JiraConfig): string;
|
|
47
|
+
/**
|
|
48
|
+
* Constructs the auth API base URL for session endpoints.
|
|
49
|
+
* @param config - Validated configuration
|
|
50
|
+
* @returns Full auth API base URL (e.g., http://jira.example.com:8080/rest/auth/1)
|
|
51
|
+
*/
|
|
52
|
+
export declare function getAuthBaseUrl(config: JiraConfig): string;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,QAAA,MAAM,YAAY;IACd,yEAAyE;;IAEzE,wCAAwC;;IAExC,wCAAwC;;IAExC,oCAAoC;;;;;;;;;;;;EAEtC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAwBvC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAIxD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAGzD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file config.ts
|
|
3
|
+
* @description Configuration module for Jira MCP server.
|
|
4
|
+
* Handles environment variable parsing and validation.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Environment variable schema for Jira configuration.
|
|
9
|
+
* Validates required and optional configuration values.
|
|
10
|
+
*/
|
|
11
|
+
const configSchema = z.object({
|
|
12
|
+
/** Base URL of the Jira instance (e.g., http://jira.example.com:8080) */
|
|
13
|
+
JIRA_BASE_URL: z.string().url('JIRA_BASE_URL must be a valid URL'),
|
|
14
|
+
/** Username for basic authentication */
|
|
15
|
+
JIRA_USERNAME: z.string().min(1, 'JIRA_USERNAME is required'),
|
|
16
|
+
/** Password for basic authentication */
|
|
17
|
+
JIRA_PASSWORD: z.string().min(1, 'JIRA_PASSWORD is required'),
|
|
18
|
+
/** API version (defaults to "2") */
|
|
19
|
+
JIRA_API_VERSION: z.string().default('2'),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Loads and validates configuration from environment variables.
|
|
23
|
+
* @returns Validated configuration object
|
|
24
|
+
* @throws Error if required environment variables are missing or invalid
|
|
25
|
+
*/
|
|
26
|
+
export function loadConfig() {
|
|
27
|
+
const result = configSchema.safeParse({
|
|
28
|
+
JIRA_BASE_URL: process.env.JIRA_BASE_URL,
|
|
29
|
+
JIRA_USERNAME: process.env.JIRA_USERNAME,
|
|
30
|
+
JIRA_PASSWORD: process.env.JIRA_PASSWORD,
|
|
31
|
+
JIRA_API_VERSION: process.env.JIRA_API_VERSION ?? '2',
|
|
32
|
+
});
|
|
33
|
+
if (!result.success) {
|
|
34
|
+
const errors = result.error.errors
|
|
35
|
+
.map((e) => ` - ${e.path.join('.')}: ${e.message}`)
|
|
36
|
+
.join('\n');
|
|
37
|
+
throw new Error(`Jira MCP configuration error:\n${errors}\n\n` +
|
|
38
|
+
'Required environment variables:\n' +
|
|
39
|
+
' JIRA_BASE_URL - Base URL of Jira instance\n' +
|
|
40
|
+
' JIRA_USERNAME - Username for authentication\n' +
|
|
41
|
+
' JIRA_PASSWORD - Password for authentication\n' +
|
|
42
|
+
'\nOptional:\n' +
|
|
43
|
+
' JIRA_API_VERSION - API version (default: "2")');
|
|
44
|
+
}
|
|
45
|
+
return result.data;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Constructs the full REST API base URL.
|
|
49
|
+
* @param config - Validated configuration
|
|
50
|
+
* @returns Full API base URL (e.g., http://jira.example.com:8080/rest/api/2)
|
|
51
|
+
*/
|
|
52
|
+
export function getApiBaseUrl(config) {
|
|
53
|
+
// Remove trailing slash if present
|
|
54
|
+
const baseUrl = config.JIRA_BASE_URL.replace(/\/$/, '');
|
|
55
|
+
return `${baseUrl}/rest/api/${config.JIRA_API_VERSION}`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Constructs the auth API base URL for session endpoints.
|
|
59
|
+
* @param config - Validated configuration
|
|
60
|
+
* @returns Full auth API base URL (e.g., http://jira.example.com:8080/rest/auth/1)
|
|
61
|
+
*/
|
|
62
|
+
export function getAuthBaseUrl(config) {
|
|
63
|
+
const baseUrl = config.JIRA_BASE_URL.replace(/\/$/, '');
|
|
64
|
+
return `${baseUrl}/rest/auth/1`;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,yEAAyE;IACzE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,mCAAmC,CAAC;IAClE,wCAAwC;IACxC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,2BAA2B,CAAC;IAC7D,wCAAwC;IACxC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,2BAA2B,CAAC;IAC7D,oCAAoC;IACpC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;CAC5C,CAAC,CAAC;AAOH;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACtB,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC;QAClC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;QACxC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;QACxC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;QACxC,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG;KACxD,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM;aAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;aACnD,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,MAAM,IAAI,KAAK,CACX,kCAAkC,MAAM,MAAM;YAC9C,mCAAmC;YACnC,+CAA+C;YAC/C,iDAAiD;YACjD,iDAAiD;YACjD,eAAe;YACf,iDAAiD,CACpD,CAAC;IACN,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC5C,mCAAmC;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxD,OAAO,GAAG,OAAO,aAAa,MAAM,CAAC,gBAAgB,EAAE,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAkB;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxD,OAAO,GAAG,OAAO,cAAc,CAAC;AACpC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @file index.ts
|
|
4
|
+
* @description Main entry point for the Jira MCP server.
|
|
5
|
+
* Supports two modes:
|
|
6
|
+
* 1. MCP Server mode (default) - Runs as stdio MCP server for AI tools
|
|
7
|
+
* 2. Setup mode - Injects MCP configuration into AI tool config files
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG"}
|