@testomatio/mcp 1.0.14 → 2.0.0-beta.8
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/README.md +89 -372
- package/index.js +17 -1618
- package/package.json +9 -18
- package/src/api/http-client.js +68 -0
- package/src/api/testomatio-client.js +46 -0
- package/src/cli/main.js +37 -0
- package/src/config/constants.js +3 -0
- package/src/config/load-config.js +37 -0
- package/src/config/package-version.js +19 -0
- package/src/core/errors.js +24 -0
- package/src/core/logger.js +31 -0
- package/src/helpers/mcp-response.js +11 -0
- package/src/index.js +20 -0
- package/src/mcp/configs/entity-crud-config.js +99 -0
- package/src/mcp/configs/issues-config.js +9 -0
- package/src/mcp/definitions/issues.js +131 -0
- package/src/mcp/definitions/labels.js +173 -0
- package/src/mcp/definitions/plans.js +295 -0
- package/src/mcp/definitions/rungroups.js +155 -0
- package/src/mcp/definitions/runs.js +364 -0
- package/src/mcp/definitions/snippets.js +187 -0
- package/src/mcp/definitions/steps.js +187 -0
- package/src/mcp/definitions/suites.js +329 -0
- package/src/mcp/definitions/system.js +10 -0
- package/src/mcp/definitions/tags.js +43 -0
- package/src/mcp/definitions/testruns.js +235 -0
- package/src/mcp/definitions/tests.js +331 -0
- package/src/mcp/registry/handlers.js +96 -0
- package/src/mcp/registry/issues.js +106 -0
- package/src/mcp/registry/listings.js +108 -0
- package/src/mcp/registry/payloads.js +269 -0
- package/src/mcp/server.js +49 -0
- package/src/mcp/tool-definitions.js +27 -0
- package/src/mcp/tool-registry.js +81 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
export const TESTRUNS_TOOLS = [
|
|
2
|
+
{
|
|
3
|
+
"name": "testruns_list",
|
|
4
|
+
"description": "List testruns (/api/v2/{project_id}/testruns)",
|
|
5
|
+
"inputSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"page": {
|
|
9
|
+
"type": "integer",
|
|
10
|
+
"minimum": 1
|
|
11
|
+
},
|
|
12
|
+
"per_page": {
|
|
13
|
+
"type": "integer",
|
|
14
|
+
"minimum": 1,
|
|
15
|
+
"maximum": 100
|
|
16
|
+
},
|
|
17
|
+
"run_id": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"query": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"additionalProperties": false
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "testruns_get",
|
|
29
|
+
"description": "Get testrun by ID",
|
|
30
|
+
"inputSchema": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"testrun_id": {
|
|
34
|
+
"type": "integer"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": [
|
|
38
|
+
"testrun_id"
|
|
39
|
+
],
|
|
40
|
+
"additionalProperties": false
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "testruns_create",
|
|
45
|
+
"description": "Create testrun (/api/v2/{project_id}/testruns)",
|
|
46
|
+
"inputSchema": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"run_id": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"test_id": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"status": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"message": {
|
|
59
|
+
"type": "string"
|
|
60
|
+
},
|
|
61
|
+
"run_time": {
|
|
62
|
+
"type": "number"
|
|
63
|
+
},
|
|
64
|
+
"assigned_to": {
|
|
65
|
+
"type": "string"
|
|
66
|
+
},
|
|
67
|
+
"test_title": {
|
|
68
|
+
"type": "string"
|
|
69
|
+
},
|
|
70
|
+
"automated": {
|
|
71
|
+
"type": "boolean"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"required": [
|
|
75
|
+
"run_id"
|
|
76
|
+
],
|
|
77
|
+
"additionalProperties": false
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "testruns_update",
|
|
82
|
+
"description": "Update testrun (/api/v2/{project_id}/testruns/{id})",
|
|
83
|
+
"inputSchema": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"properties": {
|
|
86
|
+
"testrun_id": {
|
|
87
|
+
"type": "integer"
|
|
88
|
+
},
|
|
89
|
+
"run_id": {
|
|
90
|
+
"type": "string"
|
|
91
|
+
},
|
|
92
|
+
"test_id": {
|
|
93
|
+
"type": "string"
|
|
94
|
+
},
|
|
95
|
+
"status": {
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
"message": {
|
|
99
|
+
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"run_time": {
|
|
102
|
+
"type": "number"
|
|
103
|
+
},
|
|
104
|
+
"assigned_to": {
|
|
105
|
+
"type": "string"
|
|
106
|
+
},
|
|
107
|
+
"test_title": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
},
|
|
110
|
+
"automated": {
|
|
111
|
+
"type": "boolean"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"required": [
|
|
115
|
+
"testrun_id"
|
|
116
|
+
],
|
|
117
|
+
"additionalProperties": false
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "testruns_delete",
|
|
122
|
+
"description": "Delete testrun (/api/v2/{project_id}/testruns/{id})",
|
|
123
|
+
"inputSchema": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"properties": {
|
|
126
|
+
"testrun_id": {
|
|
127
|
+
"type": "integer"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"required": [
|
|
131
|
+
"testrun_id"
|
|
132
|
+
],
|
|
133
|
+
"additionalProperties": false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "testruns_search",
|
|
138
|
+
"description": "Search testruns (delegates to testruns list; docs has no dedicated search parameter)",
|
|
139
|
+
"inputSchema": {
|
|
140
|
+
"type": "object",
|
|
141
|
+
"properties": {
|
|
142
|
+
"run_id": {
|
|
143
|
+
"type": "string"
|
|
144
|
+
},
|
|
145
|
+
"query": {
|
|
146
|
+
"type": "string"
|
|
147
|
+
},
|
|
148
|
+
"page": {
|
|
149
|
+
"type": "integer",
|
|
150
|
+
"minimum": 1
|
|
151
|
+
},
|
|
152
|
+
"per_page": {
|
|
153
|
+
"type": "integer",
|
|
154
|
+
"minimum": 1,
|
|
155
|
+
"maximum": 100
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"additionalProperties": false
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "testruns_issues_list",
|
|
163
|
+
"description": "List linked issues for a testrun (/api/v2/{project_id}/issues?testrun_id=...)",
|
|
164
|
+
"inputSchema": {
|
|
165
|
+
"type": "object",
|
|
166
|
+
"properties": {
|
|
167
|
+
"testrun_id": {
|
|
168
|
+
"type": "integer"
|
|
169
|
+
},
|
|
170
|
+
"page": {
|
|
171
|
+
"type": "integer",
|
|
172
|
+
"minimum": 1
|
|
173
|
+
},
|
|
174
|
+
"per_page": {
|
|
175
|
+
"type": "integer",
|
|
176
|
+
"minimum": 1,
|
|
177
|
+
"maximum": 100
|
|
178
|
+
},
|
|
179
|
+
"source": {
|
|
180
|
+
"type": "string"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"required": [
|
|
184
|
+
"testrun_id"
|
|
185
|
+
],
|
|
186
|
+
"additionalProperties": false
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"name": "testruns_issues_link",
|
|
191
|
+
"description": "Link issue to a testrun (/api/v2/{project_id}/issues)",
|
|
192
|
+
"inputSchema": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"properties": {
|
|
195
|
+
"testrun_id": {
|
|
196
|
+
"type": "integer"
|
|
197
|
+
},
|
|
198
|
+
"url": {
|
|
199
|
+
"type": "string"
|
|
200
|
+
},
|
|
201
|
+
"jira_id": {
|
|
202
|
+
"type": "string"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"required": [
|
|
206
|
+
"testrun_id"
|
|
207
|
+
],
|
|
208
|
+
"additionalProperties": false
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"name": "testruns_issues_unlink",
|
|
213
|
+
"description": "Unlink issue from a testrun (/api/v2/{project_id}/issues/{id})",
|
|
214
|
+
"inputSchema": {
|
|
215
|
+
"type": "object",
|
|
216
|
+
"properties": {
|
|
217
|
+
"issue_id": {
|
|
218
|
+
"type": "integer"
|
|
219
|
+
},
|
|
220
|
+
"type": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"enum": [
|
|
223
|
+
"issue",
|
|
224
|
+
"jira_issue"
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
"required": [
|
|
229
|
+
"issue_id",
|
|
230
|
+
"type"
|
|
231
|
+
],
|
|
232
|
+
"additionalProperties": false
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
];
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
export const TESTS_TOOLS = [
|
|
2
|
+
{
|
|
3
|
+
"name": "tests_list",
|
|
4
|
+
"description": "List tests (/api/v2/{project_id}/tests)",
|
|
5
|
+
"inputSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"page": {
|
|
9
|
+
"type": "integer",
|
|
10
|
+
"minimum": 1
|
|
11
|
+
},
|
|
12
|
+
"per_page": {
|
|
13
|
+
"type": "integer",
|
|
14
|
+
"minimum": 1,
|
|
15
|
+
"maximum": 100
|
|
16
|
+
},
|
|
17
|
+
"suite_id": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"search_text": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"query": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"assigned_to": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"priority": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"state": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"additionalProperties": false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "tests_get",
|
|
41
|
+
"description": "Get test by ID",
|
|
42
|
+
"inputSchema": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"test_id": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": [
|
|
50
|
+
"test_id"
|
|
51
|
+
],
|
|
52
|
+
"additionalProperties": false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "tests_create",
|
|
57
|
+
"description": "Create test (/api/v2/{project_id}/tests)",
|
|
58
|
+
"inputSchema": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"properties": {
|
|
61
|
+
"title": {
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"suite_id": {
|
|
65
|
+
"type": "string"
|
|
66
|
+
},
|
|
67
|
+
"description": {
|
|
68
|
+
"type": "string"
|
|
69
|
+
},
|
|
70
|
+
"emoji": {
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"priority": {
|
|
74
|
+
"type": "string"
|
|
75
|
+
},
|
|
76
|
+
"assigned_to": {
|
|
77
|
+
"type": "string"
|
|
78
|
+
},
|
|
79
|
+
"code": {
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"state": {
|
|
83
|
+
"type": "string"
|
|
84
|
+
},
|
|
85
|
+
"link": {
|
|
86
|
+
"type": "array",
|
|
87
|
+
"items": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"properties": {
|
|
90
|
+
"action": {
|
|
91
|
+
"type": "string",
|
|
92
|
+
"enum": [
|
|
93
|
+
"add",
|
|
94
|
+
"remove"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"type": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"enum": [
|
|
100
|
+
"label",
|
|
101
|
+
"custom_field",
|
|
102
|
+
"tag",
|
|
103
|
+
"issue",
|
|
104
|
+
"jira"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"value": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"required": [
|
|
112
|
+
"action",
|
|
113
|
+
"type",
|
|
114
|
+
"value"
|
|
115
|
+
],
|
|
116
|
+
"additionalProperties": false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"required": [
|
|
121
|
+
"title",
|
|
122
|
+
"suite_id"
|
|
123
|
+
],
|
|
124
|
+
"additionalProperties": false
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "tests_update",
|
|
129
|
+
"description": "Update test (/api/v2/{project_id}/tests/{id})",
|
|
130
|
+
"inputSchema": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": {
|
|
133
|
+
"test_id": {
|
|
134
|
+
"type": "string"
|
|
135
|
+
},
|
|
136
|
+
"title": {
|
|
137
|
+
"type": "string"
|
|
138
|
+
},
|
|
139
|
+
"suite_id": {
|
|
140
|
+
"type": "string"
|
|
141
|
+
},
|
|
142
|
+
"description": {
|
|
143
|
+
"type": "string"
|
|
144
|
+
},
|
|
145
|
+
"emoji": {
|
|
146
|
+
"type": "string"
|
|
147
|
+
},
|
|
148
|
+
"priority": {
|
|
149
|
+
"type": "string"
|
|
150
|
+
},
|
|
151
|
+
"assigned_to": {
|
|
152
|
+
"type": "string"
|
|
153
|
+
},
|
|
154
|
+
"code": {
|
|
155
|
+
"type": "string"
|
|
156
|
+
},
|
|
157
|
+
"state": {
|
|
158
|
+
"type": "string"
|
|
159
|
+
},
|
|
160
|
+
"sync": {
|
|
161
|
+
"type": "boolean"
|
|
162
|
+
},
|
|
163
|
+
"link": {
|
|
164
|
+
"type": "array",
|
|
165
|
+
"items": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"properties": {
|
|
168
|
+
"action": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"enum": [
|
|
171
|
+
"add",
|
|
172
|
+
"remove"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
"type": {
|
|
176
|
+
"type": "string",
|
|
177
|
+
"enum": [
|
|
178
|
+
"label",
|
|
179
|
+
"custom_field",
|
|
180
|
+
"tag",
|
|
181
|
+
"issue",
|
|
182
|
+
"jira"
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
"value": {
|
|
186
|
+
"type": "string"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"required": [
|
|
190
|
+
"action",
|
|
191
|
+
"type",
|
|
192
|
+
"value"
|
|
193
|
+
],
|
|
194
|
+
"additionalProperties": false
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"required": [
|
|
199
|
+
"test_id"
|
|
200
|
+
],
|
|
201
|
+
"additionalProperties": false
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"name": "tests_delete",
|
|
206
|
+
"description": "Delete test",
|
|
207
|
+
"inputSchema": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"properties": {
|
|
210
|
+
"test_id": {
|
|
211
|
+
"type": "string"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
"required": [
|
|
215
|
+
"test_id"
|
|
216
|
+
],
|
|
217
|
+
"additionalProperties": false
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "tests_search",
|
|
222
|
+
"description": "Search tests by text (delegates to tests list with search_text)",
|
|
223
|
+
"inputSchema": {
|
|
224
|
+
"type": "object",
|
|
225
|
+
"properties": {
|
|
226
|
+
"query": {
|
|
227
|
+
"type": "string"
|
|
228
|
+
},
|
|
229
|
+
"search_text": {
|
|
230
|
+
"type": "string"
|
|
231
|
+
},
|
|
232
|
+
"page": {
|
|
233
|
+
"type": "integer",
|
|
234
|
+
"minimum": 1
|
|
235
|
+
},
|
|
236
|
+
"per_page": {
|
|
237
|
+
"type": "integer",
|
|
238
|
+
"minimum": 1,
|
|
239
|
+
"maximum": 100
|
|
240
|
+
},
|
|
241
|
+
"suite_id": {
|
|
242
|
+
"type": "string"
|
|
243
|
+
},
|
|
244
|
+
"assigned_to": {
|
|
245
|
+
"type": "string"
|
|
246
|
+
},
|
|
247
|
+
"priority": {
|
|
248
|
+
"type": "string"
|
|
249
|
+
},
|
|
250
|
+
"state": {
|
|
251
|
+
"type": "string"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
"additionalProperties": false
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"name": "tests_issues_list",
|
|
259
|
+
"description": "List linked issues for a test (/api/v2/{project_id}/issues?test_id=...)",
|
|
260
|
+
"inputSchema": {
|
|
261
|
+
"type": "object",
|
|
262
|
+
"properties": {
|
|
263
|
+
"test_id": {
|
|
264
|
+
"type": "string"
|
|
265
|
+
},
|
|
266
|
+
"page": {
|
|
267
|
+
"type": "integer",
|
|
268
|
+
"minimum": 1
|
|
269
|
+
},
|
|
270
|
+
"per_page": {
|
|
271
|
+
"type": "integer",
|
|
272
|
+
"minimum": 1,
|
|
273
|
+
"maximum": 100
|
|
274
|
+
},
|
|
275
|
+
"source": {
|
|
276
|
+
"type": "string"
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
"required": [
|
|
280
|
+
"test_id"
|
|
281
|
+
],
|
|
282
|
+
"additionalProperties": false
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "tests_issues_link",
|
|
287
|
+
"description": "Link issue to a test (/api/v2/{project_id}/issues)",
|
|
288
|
+
"inputSchema": {
|
|
289
|
+
"type": "object",
|
|
290
|
+
"properties": {
|
|
291
|
+
"test_id": {
|
|
292
|
+
"type": "string"
|
|
293
|
+
},
|
|
294
|
+
"url": {
|
|
295
|
+
"type": "string"
|
|
296
|
+
},
|
|
297
|
+
"jira_id": {
|
|
298
|
+
"type": "string"
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"required": [
|
|
302
|
+
"test_id"
|
|
303
|
+
],
|
|
304
|
+
"additionalProperties": false
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"name": "tests_issues_unlink",
|
|
309
|
+
"description": "Unlink issue from a test (/api/v2/{project_id}/issues/{id})",
|
|
310
|
+
"inputSchema": {
|
|
311
|
+
"type": "object",
|
|
312
|
+
"properties": {
|
|
313
|
+
"issue_id": {
|
|
314
|
+
"type": "integer"
|
|
315
|
+
},
|
|
316
|
+
"type": {
|
|
317
|
+
"type": "string",
|
|
318
|
+
"enum": [
|
|
319
|
+
"issue",
|
|
320
|
+
"jira_issue"
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
"required": [
|
|
325
|
+
"issue_id",
|
|
326
|
+
"type"
|
|
327
|
+
],
|
|
328
|
+
"additionalProperties": false
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ENTITY_CRUD_CONFIGS } from '../configs/entity-crud-config.js';
|
|
2
|
+
import { ISSUE_SCOPED_TOOL_CONFIGS } from '../configs/issues-config.js';
|
|
3
|
+
|
|
4
|
+
export const handlerMethods = {
|
|
5
|
+
registerEntityCrudHandlers(handlers) {
|
|
6
|
+
for (const spec of ENTITY_CRUD_CONFIGS) {
|
|
7
|
+
const { toolPrefix, resource, idArg, listMethod, searchMethod } = spec;
|
|
8
|
+
|
|
9
|
+
handlers[`${toolPrefix}_list`] = async (args = {}) =>
|
|
10
|
+
this.asText(await this[listMethod](args));
|
|
11
|
+
handlers[`${toolPrefix}_search`] = async (args = {}) =>
|
|
12
|
+
this.asText(await this[searchMethod](args));
|
|
13
|
+
handlers[`${toolPrefix}_get`] = async (args = {}) =>
|
|
14
|
+
this.asText(await this.apiClient.get(resource, this.pickRequiredArg(args, idArg)));
|
|
15
|
+
handlers[`${toolPrefix}_create`] = async (args = {}) =>
|
|
16
|
+
this.asText(await this.executeCreate(spec, args));
|
|
17
|
+
handlers[`${toolPrefix}_update`] = async (args = {}) => {
|
|
18
|
+
const id = this.pickRequiredArg(args, idArg);
|
|
19
|
+
const payloadArgs = this.omitArg(args, idArg);
|
|
20
|
+
return this.asText(await this.executeUpdate(spec, id, payloadArgs));
|
|
21
|
+
};
|
|
22
|
+
handlers[`${toolPrefix}_delete`] = async (args = {}) =>
|
|
23
|
+
this.asText(await this.apiClient.delete(resource, this.pickRequiredArg(args, idArg)));
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
registerScopedIssueHandlers(handlers) {
|
|
28
|
+
for (const { toolPrefix, resourceKey } of ISSUE_SCOPED_TOOL_CONFIGS) {
|
|
29
|
+
handlers[`${toolPrefix}_issues_list`] = async (args = {}) =>
|
|
30
|
+
this.asText(
|
|
31
|
+
await this.listIssuesForKey({
|
|
32
|
+
resourceKey,
|
|
33
|
+
resourceId: this.pickRequiredArg(args, resourceKey),
|
|
34
|
+
page: args.page,
|
|
35
|
+
per_page: args.per_page,
|
|
36
|
+
source: args.source,
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
handlers[`${toolPrefix}_issues_link`] = async (args = {}) =>
|
|
41
|
+
this.asText(
|
|
42
|
+
await this.linkIssueForKey({
|
|
43
|
+
resourceKey,
|
|
44
|
+
resourceId: this.pickRequiredArg(args, resourceKey),
|
|
45
|
+
url: args.url,
|
|
46
|
+
jira_id: args.jira_id,
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
handlers[`${toolPrefix}_issues_unlink`] = async ({ issue_id: issueId, type }) =>
|
|
51
|
+
this.asText(await this.apiClient.delete('issues', issueId, { type }));
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
registerGlobalHandlers(handlers) {
|
|
56
|
+
handlers.tags_list = async () => this.asText(await this.listTags());
|
|
57
|
+
handlers.tags_get = async ({ tag_id: tagId }) => this.asText(await this.getTagByTitle(tagId));
|
|
58
|
+
handlers.tags_search = async (args = {}) => this.asText(await this.searchTags(args));
|
|
59
|
+
|
|
60
|
+
handlers.issues_list = async (args = {}) => this.asText(await this.listIssues(args));
|
|
61
|
+
handlers.issues_search = async (args = {}) => this.asText(await this.searchIssues(args));
|
|
62
|
+
handlers.issues_create = async (args = {}) => this.asText(await this.createIssue(args));
|
|
63
|
+
handlers.issues_delete = async ({ issue_id: issueId, type }) =>
|
|
64
|
+
this.asText(await this.apiClient.delete('issues', issueId, { type }));
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
pickRequiredArg(args = {}, key) {
|
|
68
|
+
const value = args[key];
|
|
69
|
+
if (value === undefined || value === null || value === '') {
|
|
70
|
+
throw new Error(`Missing required argument: ${key}`);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
omitArg(args = {}, key) {
|
|
76
|
+
const payload = { ...args };
|
|
77
|
+
delete payload[key];
|
|
78
|
+
return payload;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
executeCreate(spec, args = {}) {
|
|
82
|
+
if (spec.createMode === 'run') {
|
|
83
|
+
return this.createRunWithFallback(args);
|
|
84
|
+
}
|
|
85
|
+
const payload = this[spec.payloadBuilder](args);
|
|
86
|
+
return this.createWrapped(spec.resource, spec.wrapperKey, payload);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
executeUpdate(spec, id, args = {}) {
|
|
90
|
+
if (spec.updateMode === 'run') {
|
|
91
|
+
return this.updateRunWithFallback(id, args);
|
|
92
|
+
}
|
|
93
|
+
const payload = this[spec.payloadBuilder](args);
|
|
94
|
+
return this.updateWrapped(spec.resource, id, spec.wrapperKey, payload);
|
|
95
|
+
},
|
|
96
|
+
};
|