@ycadence/mcp 0.0.0-stage → 0.1.1
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 +202 -0
- package/README.md +70 -2
- package/dist/bin.js +706 -0
- package/package.json +50 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Yarlis, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ycadence/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A [Model Context Protocol](https://modelcontextprotocol.io) server for YCadence. It lets
|
|
4
|
+
an AI agent list, read, create and update work items, and read states and cycles. It
|
|
5
|
+
speaks JSON-RPC over stdio.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | What it does |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `ycadence_list_work_items` | List work items in a project, optionally filtered |
|
|
12
|
+
| `ycadence_get_work_item` | Read one work item |
|
|
13
|
+
| `ycadence_create_work_item` | Create a work item |
|
|
14
|
+
| `ycadence_update_work_item` | Change a work item's state, priority, title and so on |
|
|
15
|
+
| `ycadence_list_states` | The project's workflow states |
|
|
16
|
+
| `ycadence_list_cycles` | The project's cycles |
|
|
17
|
+
|
|
18
|
+
The older `devpulse_*` names are still registered, as deprecated aliases, for one release.
|
|
19
|
+
|
|
20
|
+
## Use with Claude Code
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
claude mcp add ycadence \
|
|
24
|
+
-e YCADENCE_URL=https://ycadence.example.com \
|
|
25
|
+
-e YCADENCE_API_KEY=yc_live_p_... \
|
|
26
|
+
-- npx -y @ycadence/mcp
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Use with any MCP client
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"ycadence": {
|
|
35
|
+
"command": "npx",
|
|
36
|
+
"args": ["-y", "@ycadence/mcp"],
|
|
37
|
+
"env": {
|
|
38
|
+
"YCADENCE_URL": "https://ycadence.example.com",
|
|
39
|
+
"YCADENCE_API_KEY": "yc_live_p_..."
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The package installs two commands that behave the same: `ycadence-mcp`, and
|
|
47
|
+
`devpulse-mcp`, the name from before the rename. For an instance behind Google IAP,
|
|
48
|
+
also set `YCADENCE_IDENTITY_TOKEN`. It lasts about an hour, so restart the server
|
|
49
|
+
when it expires. When a `YCADENCE_*` variable is unset, the server reads the older
|
|
50
|
+
`DEVPULSE_*` name instead.
|
|
51
|
+
|
|
52
|
+
Requires Node 18 or later. The package is self-contained and installs no other packages.
|
|
53
|
+
|
|
54
|
+
## If npm is unavailable
|
|
55
|
+
|
|
56
|
+
Each release is mirrored to GitHub Packages when the npm publish fails, as
|
|
57
|
+
`@yarlisaisolutions/ycadence-mcp`. It needs a GitHub token with `read:packages`:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
# ~/.npmrc
|
|
61
|
+
@yarlisaisolutions:registry=https://npm.pkg.github.com
|
|
62
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
npx -y @yarlisaisolutions/ycadence-mcp
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
Apache-2.0
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/bin.ts
|
|
4
|
+
import { createInterface } from "node:readline";
|
|
5
|
+
|
|
6
|
+
// ../core/src/env.ts
|
|
7
|
+
var ENV_PREFIX = "YCADENCE_";
|
|
8
|
+
var LEGACY_ENV_PREFIX = "DEVPULSE_";
|
|
9
|
+
function processEnv() {
|
|
10
|
+
const candidate = globalThis.process;
|
|
11
|
+
return candidate?.env ?? {};
|
|
12
|
+
}
|
|
13
|
+
function readEnv(name, env = processEnv()) {
|
|
14
|
+
const current = env[`${ENV_PREFIX}${name}`];
|
|
15
|
+
if (current !== undefined && current !== "")
|
|
16
|
+
return current;
|
|
17
|
+
const legacy = env[`${LEGACY_ENV_PREFIX}${name}`];
|
|
18
|
+
if (legacy !== undefined && legacy !== "")
|
|
19
|
+
return legacy;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ../sdk/src/errors.ts
|
|
24
|
+
class YCadenceError extends Error {
|
|
25
|
+
status;
|
|
26
|
+
code;
|
|
27
|
+
issues;
|
|
28
|
+
requestId;
|
|
29
|
+
details;
|
|
30
|
+
retryAfter;
|
|
31
|
+
method;
|
|
32
|
+
path;
|
|
33
|
+
constructor(status, code, message, issues, extras = {}) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.status = status;
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.issues = issues;
|
|
38
|
+
this.name = "YCadenceError";
|
|
39
|
+
this.requestId = extras.requestId;
|
|
40
|
+
this.details = extras.details;
|
|
41
|
+
this.retryAfter = extras.retryAfter;
|
|
42
|
+
this.method = extras.method;
|
|
43
|
+
this.path = extras.path;
|
|
44
|
+
}
|
|
45
|
+
get retryable() {
|
|
46
|
+
return this.status === 0 || this.status === 408 || this.status === 429 || this.status >= 500;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class YCadenceValidationError extends YCadenceError {
|
|
51
|
+
name = "YCadenceValidationError";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class YCadencePermissionError extends YCadenceError {
|
|
55
|
+
name = "YCadencePermissionError";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
class YCadenceNotFoundError extends YCadenceError {
|
|
59
|
+
name = "YCadenceNotFoundError";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class YCadenceConflictError extends YCadenceError {
|
|
63
|
+
name = "YCadenceConflictError";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class YCadencePreconditionError extends YCadenceError {
|
|
67
|
+
name = "YCadencePreconditionError";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class YCadenceRateLimitError extends YCadenceError {
|
|
71
|
+
name = "YCadenceRateLimitError";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
class YCadenceNetworkError extends YCadenceError {
|
|
75
|
+
name = "YCadenceNetworkError";
|
|
76
|
+
}
|
|
77
|
+
function errorClassFor(status) {
|
|
78
|
+
if (status === 0 || status === 408)
|
|
79
|
+
return YCadenceNetworkError;
|
|
80
|
+
if (status === 400 || status === 422)
|
|
81
|
+
return YCadenceValidationError;
|
|
82
|
+
if (status === 401 || status === 403)
|
|
83
|
+
return YCadencePermissionError;
|
|
84
|
+
if (status === 404)
|
|
85
|
+
return YCadenceNotFoundError;
|
|
86
|
+
if (status === 409)
|
|
87
|
+
return YCadenceConflictError;
|
|
88
|
+
if (status === 412)
|
|
89
|
+
return YCadencePreconditionError;
|
|
90
|
+
if (status === 429)
|
|
91
|
+
return YCadenceRateLimitError;
|
|
92
|
+
return YCadenceError;
|
|
93
|
+
}
|
|
94
|
+
function createError(status, code, message, issues, extras = {}) {
|
|
95
|
+
const ErrorClass = errorClassFor(status);
|
|
96
|
+
return new ErrorClass(status, code, message, issues, extras);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
class RequestIntercepted extends Error {
|
|
100
|
+
request;
|
|
101
|
+
name = "RequestIntercepted";
|
|
102
|
+
constructor(request) {
|
|
103
|
+
super(`${request.method} ${request.url} was not sent.`);
|
|
104
|
+
this.request = request;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ../sdk/src/operations.ts
|
|
109
|
+
var OPERATIONS = {
|
|
110
|
+
health: { method: "GET", path: "/api/health" },
|
|
111
|
+
me: { method: "GET", path: "/api/v1/me" },
|
|
112
|
+
listProjects: { method: "GET", path: "/api/v1/projects" },
|
|
113
|
+
listWorkItems: { method: "GET", path: "/api/v1/projects/{projectId}/work-items" },
|
|
114
|
+
createWorkItem: { method: "POST", path: "/api/v1/projects/{projectId}/work-items" },
|
|
115
|
+
getWorkItem: { method: "GET", path: "/api/v1/work-items/{workItemId}" },
|
|
116
|
+
updateWorkItem: { method: "PATCH", path: "/api/v1/work-items/{workItemId}" },
|
|
117
|
+
deleteWorkItem: { method: "DELETE", path: "/api/v1/work-items/{workItemId}" },
|
|
118
|
+
listStates: { method: "GET", path: "/api/v1/projects/{projectId}/states" },
|
|
119
|
+
listLabels: { method: "GET", path: "/api/v1/projects/{projectId}/labels" },
|
|
120
|
+
createLabel: { method: "POST", path: "/api/v1/projects/{projectId}/labels" },
|
|
121
|
+
listTypes: { method: "GET", path: "/api/v1/projects/{projectId}/types" },
|
|
122
|
+
listCycles: { method: "GET", path: "/api/v1/projects/{projectId}/cycles" },
|
|
123
|
+
createCycle: { method: "POST", path: "/api/v1/projects/{projectId}/cycles" },
|
|
124
|
+
getCycleProgress: { method: "GET", path: "/api/v1/cycles/{cycleId}/progress" },
|
|
125
|
+
addWorkItemsToCycle: { method: "POST", path: "/api/v1/cycles/{cycleId}/work-items" },
|
|
126
|
+
listViews: { method: "GET", path: "/api/v1/projects/{projectId}/views" },
|
|
127
|
+
createView: { method: "POST", path: "/api/v1/projects/{projectId}/views" },
|
|
128
|
+
listIntake: { method: "GET", path: "/api/v1/projects/{projectId}/intake" },
|
|
129
|
+
submitIntake: { method: "POST", path: "/api/v1/projects/{projectId}/intake" },
|
|
130
|
+
triageIntake: { method: "POST", path: "/api/v1/intake-items/{intakeItemId}/triage" },
|
|
131
|
+
previewImport: { method: "POST", path: "/api/v1/projects/{projectId}/imports/preview" },
|
|
132
|
+
startImport: { method: "POST", path: "/api/v1/projects/{projectId}/imports" },
|
|
133
|
+
listImports: { method: "GET", path: "/api/v1/projects/{projectId}/imports" },
|
|
134
|
+
getImport: { method: "GET", path: "/api/v1/imports/{runId}" }
|
|
135
|
+
};
|
|
136
|
+
function isIdempotentMethod(method) {
|
|
137
|
+
return method === "GET" || method === "HEAD";
|
|
138
|
+
}
|
|
139
|
+
function buildPath(template, params = {}) {
|
|
140
|
+
return template.replace(/\{(\w+)\}/g, (_match, name) => {
|
|
141
|
+
const value = params[name];
|
|
142
|
+
if (value === undefined || value === "") {
|
|
143
|
+
throw new TypeError(`Missing path parameter "${name}" for ${template}.`);
|
|
144
|
+
}
|
|
145
|
+
return encodeURIComponent(value);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ../sdk/src/pagination.ts
|
|
150
|
+
async function* paginate(fetchPage, options = {}) {
|
|
151
|
+
let cursor = options.cursor;
|
|
152
|
+
let yielded = 0;
|
|
153
|
+
do {
|
|
154
|
+
const page = await fetchPage(cursor);
|
|
155
|
+
for (const item of page.items) {
|
|
156
|
+
if (options.maxItems !== undefined && yielded >= options.maxItems)
|
|
157
|
+
return;
|
|
158
|
+
yielded += 1;
|
|
159
|
+
yield item;
|
|
160
|
+
}
|
|
161
|
+
cursor = page.nextCursor ?? undefined;
|
|
162
|
+
} while (cursor !== undefined);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ../sdk/src/version.ts
|
|
166
|
+
var SDK_VERSION = "0.2.0";
|
|
167
|
+
|
|
168
|
+
// ../sdk/src/client.ts
|
|
169
|
+
var DEFAULT_RETRY = { retries: 2, baseDelayMs: 250, maxDelayMs: 8000 };
|
|
170
|
+
|
|
171
|
+
class YCadenceClient {
|
|
172
|
+
options;
|
|
173
|
+
baseUrl;
|
|
174
|
+
apiKey;
|
|
175
|
+
identityToken;
|
|
176
|
+
timeoutMs;
|
|
177
|
+
doFetch;
|
|
178
|
+
retry;
|
|
179
|
+
userAgent;
|
|
180
|
+
onResponse;
|
|
181
|
+
sleep;
|
|
182
|
+
constructor(options) {
|
|
183
|
+
this.options = options;
|
|
184
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
185
|
+
this.apiKey = options.apiKey;
|
|
186
|
+
this.identityToken = options.identityToken;
|
|
187
|
+
this.timeoutMs = options.timeoutMs ?? 30000;
|
|
188
|
+
this.doFetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
189
|
+
this.retry = { ...DEFAULT_RETRY, ...options.retry };
|
|
190
|
+
this.userAgent = [options.userAgent, `ycadence-sdk/${SDK_VERSION}`].filter((part) => part !== undefined && part !== "").join(" ");
|
|
191
|
+
this.onResponse = options.onResponse;
|
|
192
|
+
this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
193
|
+
}
|
|
194
|
+
withOptions(overrides) {
|
|
195
|
+
return new YCadenceClient({ ...this.options, ...overrides });
|
|
196
|
+
}
|
|
197
|
+
get fetchImplementation() {
|
|
198
|
+
return this.doFetch;
|
|
199
|
+
}
|
|
200
|
+
async health() {
|
|
201
|
+
return this.call("health");
|
|
202
|
+
}
|
|
203
|
+
async me(options) {
|
|
204
|
+
return this.call("me", {}, undefined, undefined, options);
|
|
205
|
+
}
|
|
206
|
+
async listProjects(query = {}, options) {
|
|
207
|
+
return this.call("listProjects", {}, query, undefined, options);
|
|
208
|
+
}
|
|
209
|
+
async listWorkItems(projectId, query = {}, options) {
|
|
210
|
+
return this.call("listWorkItems", { projectId }, {
|
|
211
|
+
filter: query.filter === undefined ? undefined : JSON.stringify(query.filter),
|
|
212
|
+
limit: query.limit,
|
|
213
|
+
cursor: query.cursor,
|
|
214
|
+
state: query.state,
|
|
215
|
+
priority: query.priority
|
|
216
|
+
}, undefined, options);
|
|
217
|
+
}
|
|
218
|
+
iterateWorkItems(projectId, options = {}) {
|
|
219
|
+
return paginate((cursor) => this.listWorkItems(projectId, {
|
|
220
|
+
filter: options.filter,
|
|
221
|
+
limit: options.pageSize ?? 100,
|
|
222
|
+
cursor
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
async createWorkItem(projectId, body, options) {
|
|
226
|
+
return this.call("createWorkItem", { projectId }, undefined, body, options);
|
|
227
|
+
}
|
|
228
|
+
async getWorkItem(workItemId, options) {
|
|
229
|
+
return this.call("getWorkItem", { workItemId }, undefined, undefined, options);
|
|
230
|
+
}
|
|
231
|
+
async updateWorkItem(workItemId, body, options) {
|
|
232
|
+
return this.call("updateWorkItem", { workItemId }, undefined, body, options);
|
|
233
|
+
}
|
|
234
|
+
async deleteWorkItem(workItemId, options) {
|
|
235
|
+
await this.call("deleteWorkItem", { workItemId }, undefined, undefined, options);
|
|
236
|
+
}
|
|
237
|
+
async listStates(projectId, options) {
|
|
238
|
+
return this.call("listStates", { projectId }, undefined, undefined, options);
|
|
239
|
+
}
|
|
240
|
+
async listLabels(projectId, options) {
|
|
241
|
+
return this.call("listLabels", { projectId }, undefined, undefined, options);
|
|
242
|
+
}
|
|
243
|
+
async createLabel(projectId, body, options) {
|
|
244
|
+
return this.call("createLabel", { projectId }, undefined, body, options);
|
|
245
|
+
}
|
|
246
|
+
async listTypes(projectId, options) {
|
|
247
|
+
return this.call("listTypes", { projectId }, undefined, undefined, options);
|
|
248
|
+
}
|
|
249
|
+
async listCycles(projectId, options) {
|
|
250
|
+
return this.call("listCycles", { projectId }, undefined, undefined, options);
|
|
251
|
+
}
|
|
252
|
+
async createCycle(projectId, body, options) {
|
|
253
|
+
return this.call("createCycle", { projectId }, undefined, body, options);
|
|
254
|
+
}
|
|
255
|
+
async getCycleProgress(cycleId, options) {
|
|
256
|
+
return this.call("getCycleProgress", { cycleId }, undefined, undefined, options);
|
|
257
|
+
}
|
|
258
|
+
async addWorkItemsToCycle(cycleId, workItemIds, options) {
|
|
259
|
+
return this.call("addWorkItemsToCycle", { cycleId }, undefined, { workItemIds }, options);
|
|
260
|
+
}
|
|
261
|
+
async listViews(projectId, options) {
|
|
262
|
+
return this.call("listViews", { projectId }, undefined, undefined, options);
|
|
263
|
+
}
|
|
264
|
+
async createView(projectId, body, options) {
|
|
265
|
+
return this.call("createView", { projectId }, undefined, body, options);
|
|
266
|
+
}
|
|
267
|
+
async listIntake(projectId, query = {}, options) {
|
|
268
|
+
return this.call("listIntake", { projectId }, query, undefined, options);
|
|
269
|
+
}
|
|
270
|
+
async submitIntake(projectId, body, options) {
|
|
271
|
+
return this.call("submitIntake", { projectId }, undefined, body, options);
|
|
272
|
+
}
|
|
273
|
+
async triageIntake(intakeItemId, body, options) {
|
|
274
|
+
return this.call("triageIntake", { intakeItemId }, undefined, body, options);
|
|
275
|
+
}
|
|
276
|
+
async previewImport(projectId, body, options) {
|
|
277
|
+
return this.call("previewImport", { projectId }, undefined, body, options);
|
|
278
|
+
}
|
|
279
|
+
async startImport(projectId, body, options) {
|
|
280
|
+
return this.call("startImport", { projectId }, undefined, body, options);
|
|
281
|
+
}
|
|
282
|
+
async getImport(runId, options) {
|
|
283
|
+
return this.call("getImport", { runId }, undefined, undefined, options);
|
|
284
|
+
}
|
|
285
|
+
async listImports(projectId, options) {
|
|
286
|
+
return this.call("listImports", { projectId }, undefined, undefined, options);
|
|
287
|
+
}
|
|
288
|
+
async call(operation, params = {}, query, body, options = {}) {
|
|
289
|
+
const { method, path } = OPERATIONS[operation];
|
|
290
|
+
let url = buildPath(path, params);
|
|
291
|
+
if (query !== undefined) {
|
|
292
|
+
const search = new URLSearchParams;
|
|
293
|
+
for (const [name, value] of Object.entries(query)) {
|
|
294
|
+
if (value !== undefined)
|
|
295
|
+
search.set(name, String(value));
|
|
296
|
+
}
|
|
297
|
+
const encoded = search.toString();
|
|
298
|
+
if (encoded.length > 0)
|
|
299
|
+
url += `?${encoded}`;
|
|
300
|
+
}
|
|
301
|
+
return this.request(method, url, body, options);
|
|
302
|
+
}
|
|
303
|
+
async request(method, path, body, options) {
|
|
304
|
+
const retryable = isIdempotentMethod(method) || options.idempotencyKey !== undefined;
|
|
305
|
+
const retries = retryable ? options.retries ?? this.retry.retries : 0;
|
|
306
|
+
for (let attempt = 0;; attempt += 1) {
|
|
307
|
+
try {
|
|
308
|
+
return await this.send(method, path, body, options, attempt);
|
|
309
|
+
} catch (error) {
|
|
310
|
+
const failure = error;
|
|
311
|
+
const again = attempt < retries && typeof failure.retryable === "boolean" && (failure.retryable || failure.code === "request_in_progress");
|
|
312
|
+
if (!again)
|
|
313
|
+
throw error;
|
|
314
|
+
await this.sleep(this.backoff(attempt, failure.retryAfter));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
backoff(attempt, retryAfter) {
|
|
319
|
+
if (retryAfter !== undefined)
|
|
320
|
+
return Math.min(retryAfter * 1000, this.retry.maxDelayMs);
|
|
321
|
+
const exponential = this.retry.baseDelayMs * 2 ** attempt;
|
|
322
|
+
const jittered = exponential / 2 + Math.random() * (exponential / 2);
|
|
323
|
+
return Math.min(jittered, this.retry.maxDelayMs);
|
|
324
|
+
}
|
|
325
|
+
async send(method, path, body, options, attempt) {
|
|
326
|
+
const controller = new AbortController;
|
|
327
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
328
|
+
const abort = () => controller.abort();
|
|
329
|
+
options.signal?.addEventListener("abort", abort);
|
|
330
|
+
const started = Date.now();
|
|
331
|
+
let response;
|
|
332
|
+
try {
|
|
333
|
+
const identityToken = typeof this.identityToken === "function" ? await this.identityToken() : this.identityToken;
|
|
334
|
+
const headers = {
|
|
335
|
+
"x-api-key": this.apiKey,
|
|
336
|
+
...identityToken === undefined || identityToken.length === 0 ? {} : { Authorization: `Bearer ${identityToken}` },
|
|
337
|
+
...body === undefined ? {} : { "Content-Type": "application/json" },
|
|
338
|
+
Accept: "application/json",
|
|
339
|
+
"User-Agent": this.userAgent
|
|
340
|
+
};
|
|
341
|
+
if (options.idempotencyKey !== undefined && !isIdempotentMethod(method)) {
|
|
342
|
+
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
343
|
+
}
|
|
344
|
+
if (options.expectedVersion !== undefined && !isIdempotentMethod(method)) {
|
|
345
|
+
headers["If-Match"] = `"${String(options.expectedVersion).replace(/"/g, "")}"`;
|
|
346
|
+
}
|
|
347
|
+
response = await this.doFetch(`${this.baseUrl}${path}`, {
|
|
348
|
+
method,
|
|
349
|
+
headers,
|
|
350
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
351
|
+
signal: controller.signal
|
|
352
|
+
});
|
|
353
|
+
} catch (error) {
|
|
354
|
+
if (error instanceof RequestIntercepted)
|
|
355
|
+
throw error;
|
|
356
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
357
|
+
throw createError(408, "timeout", `${method} ${path} timed out after ${this.timeoutMs}ms.`, undefined, { method, path });
|
|
358
|
+
}
|
|
359
|
+
throw createError(0, "network_error", `Could not reach ${this.baseUrl}: ${error instanceof Error ? error.message : "unknown error"}`, undefined, { method, path });
|
|
360
|
+
} finally {
|
|
361
|
+
clearTimeout(timer);
|
|
362
|
+
options.signal?.removeEventListener("abort", abort);
|
|
363
|
+
}
|
|
364
|
+
const headerRequestId = response.headers?.get?.("x-request-id") ?? undefined;
|
|
365
|
+
this.onResponse?.({
|
|
366
|
+
method,
|
|
367
|
+
path,
|
|
368
|
+
status: response.status,
|
|
369
|
+
requestId: headerRequestId,
|
|
370
|
+
durationMs: Date.now() - started,
|
|
371
|
+
attempt,
|
|
372
|
+
replayed: response.headers?.get?.("idempotent-replayed") === "true"
|
|
373
|
+
});
|
|
374
|
+
if (response.status === 204)
|
|
375
|
+
return;
|
|
376
|
+
const text = await response.text();
|
|
377
|
+
const parsed = text.length === 0 ? undefined : safeJson(text);
|
|
378
|
+
if (!response.ok) {
|
|
379
|
+
const failure = isRecord(parsed) ? parsed : {};
|
|
380
|
+
throw createError(response.status, typeof failure.code === "string" ? failure.code : codeForStatus(response.status), typeof failure.error === "string" ? failure.error : `${method} ${path} failed with ${response.status}.`, failure.issues, {
|
|
381
|
+
requestId: failure.requestId ?? headerRequestId,
|
|
382
|
+
details: failure.details,
|
|
383
|
+
retryAfter: parseRetryAfter(response.headers?.get?.("retry-after") ?? null),
|
|
384
|
+
method,
|
|
385
|
+
path
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
return parsed;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function safeJson(text) {
|
|
392
|
+
try {
|
|
393
|
+
return JSON.parse(text);
|
|
394
|
+
} catch {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function isRecord(value) {
|
|
399
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
400
|
+
}
|
|
401
|
+
function codeForStatus(status) {
|
|
402
|
+
const codes = {
|
|
403
|
+
400: "bad_request",
|
|
404
|
+
401: "unauthorized",
|
|
405
|
+
403: "forbidden",
|
|
406
|
+
404: "not_found",
|
|
407
|
+
409: "conflict",
|
|
408
|
+
412: "precondition_failed",
|
|
409
|
+
422: "validation_failed",
|
|
410
|
+
429: "rate_limited"
|
|
411
|
+
};
|
|
412
|
+
return codes[status] ?? (status >= 500 ? "server_error" : "unknown");
|
|
413
|
+
}
|
|
414
|
+
function parseRetryAfter(value, now = Date.now()) {
|
|
415
|
+
if (value === null || value.trim() === "")
|
|
416
|
+
return;
|
|
417
|
+
const seconds = Number(value);
|
|
418
|
+
if (Number.isFinite(seconds))
|
|
419
|
+
return Math.max(0, seconds);
|
|
420
|
+
const date = Date.parse(value);
|
|
421
|
+
if (Number.isNaN(date))
|
|
422
|
+
return;
|
|
423
|
+
return Math.max(0, Math.ceil((date - now) / 1000));
|
|
424
|
+
}
|
|
425
|
+
// ../sdk/src/types.ts
|
|
426
|
+
var WORK_ITEM_FIELDS = {
|
|
427
|
+
id: true,
|
|
428
|
+
key: true,
|
|
429
|
+
sequenceId: true,
|
|
430
|
+
name: true,
|
|
431
|
+
priority: true,
|
|
432
|
+
stateId: true,
|
|
433
|
+
assigneeIds: true,
|
|
434
|
+
labelIds: true,
|
|
435
|
+
parentId: true,
|
|
436
|
+
sortOrder: true,
|
|
437
|
+
createdAt: true,
|
|
438
|
+
projectId: true,
|
|
439
|
+
version: true
|
|
440
|
+
};
|
|
441
|
+
var WORK_ITEM_DETAIL_FIELDS = {
|
|
442
|
+
...WORK_ITEM_FIELDS,
|
|
443
|
+
description: true,
|
|
444
|
+
startDate: true,
|
|
445
|
+
targetDate: true,
|
|
446
|
+
archivedAt: true,
|
|
447
|
+
updatedAt: true
|
|
448
|
+
};
|
|
449
|
+
// src/tools.ts
|
|
450
|
+
var projectId = {
|
|
451
|
+
type: "string",
|
|
452
|
+
description: "The project id. Ask the user if you do not have one."
|
|
453
|
+
};
|
|
454
|
+
var TOOLS = [
|
|
455
|
+
{
|
|
456
|
+
name: "ycadence_list_work_items",
|
|
457
|
+
description: "List work items in a project, optionally filtered. Use this before creating anything, " + "to check whether the work already exists.",
|
|
458
|
+
inputSchema: {
|
|
459
|
+
type: "object",
|
|
460
|
+
properties: {
|
|
461
|
+
projectId,
|
|
462
|
+
filter: {
|
|
463
|
+
type: "object",
|
|
464
|
+
description: 'A filter expression, e.g. {"field":"priority","operator":"is","value":"urgent"} or ' + '{"all":[{"field":"assignee","operator":"isNull"},{"field":"archived","operator":"is","value":false}]}. ' + "Fields: state, stateGroup, priority, assignee, label, cycle, module, parent, " + "startDate, targetDate, createdAt, updatedAt, completedAt, name, archived."
|
|
465
|
+
},
|
|
466
|
+
limit: { type: "number", description: "Maximum items to return. Defaults to 50." }
|
|
467
|
+
},
|
|
468
|
+
required: ["projectId"]
|
|
469
|
+
},
|
|
470
|
+
handler: async (client, args) => {
|
|
471
|
+
const page = await client.listWorkItems(String(args.projectId), {
|
|
472
|
+
filter: args.filter,
|
|
473
|
+
limit: typeof args.limit === "number" ? args.limit : 50
|
|
474
|
+
});
|
|
475
|
+
if (page.items.length === 0)
|
|
476
|
+
return "No work items matched.";
|
|
477
|
+
const lines = page.items.map((item) => `${item.key} ${item.name} [${item.priority}]${item.assigneeIds.length > 0 ? ` (${item.assigneeIds.length} assignee)` : ""}`);
|
|
478
|
+
if (page.nextCursor !== null)
|
|
479
|
+
lines.push(`… more available (cursor: ${page.nextCursor})`);
|
|
480
|
+
return lines.join(`
|
|
481
|
+
`);
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
name: "ycadence_get_work_item",
|
|
486
|
+
description: "Read one work item in full, including its description.",
|
|
487
|
+
inputSchema: {
|
|
488
|
+
type: "object",
|
|
489
|
+
properties: { workItemId: { type: "string", description: "The work item id." } },
|
|
490
|
+
required: ["workItemId"]
|
|
491
|
+
},
|
|
492
|
+
handler: async (client, args) => {
|
|
493
|
+
const item = await client.getWorkItem(String(args.workItemId));
|
|
494
|
+
return [
|
|
495
|
+
`${item.key} ${item.name}`,
|
|
496
|
+
`priority: ${item.priority}`,
|
|
497
|
+
`state: ${item.stateId ?? "none"}`,
|
|
498
|
+
`assignees: ${item.assigneeIds.length}`,
|
|
499
|
+
"",
|
|
500
|
+
item.description ?? "(no description)"
|
|
501
|
+
].join(`
|
|
502
|
+
`);
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: "ycadence_create_work_item",
|
|
507
|
+
description: "Create a work item. Check with ycadence_list_work_items first — filing a duplicate is " + "worse than asking.",
|
|
508
|
+
inputSchema: {
|
|
509
|
+
type: "object",
|
|
510
|
+
properties: {
|
|
511
|
+
projectId,
|
|
512
|
+
name: { type: "string", description: "A short, specific title." },
|
|
513
|
+
description: { type: "string", description: "Optional detail, plain text." },
|
|
514
|
+
priority: {
|
|
515
|
+
type: "string",
|
|
516
|
+
enum: ["urgent", "high", "medium", "low", "none"],
|
|
517
|
+
description: "Defaults to none. Do not guess urgent."
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
required: ["projectId", "name"]
|
|
521
|
+
},
|
|
522
|
+
handler: async (client, args) => {
|
|
523
|
+
const created = await client.createWorkItem(String(args.projectId), {
|
|
524
|
+
name: String(args.name),
|
|
525
|
+
description: args.description === undefined ? undefined : String(args.description),
|
|
526
|
+
priority: args.priority
|
|
527
|
+
});
|
|
528
|
+
return `Created ${created.key}: ${created.name}`;
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
name: "ycadence_update_work_item",
|
|
533
|
+
description: "Change a work item’s title, description, priority or state.",
|
|
534
|
+
inputSchema: {
|
|
535
|
+
type: "object",
|
|
536
|
+
properties: {
|
|
537
|
+
workItemId: { type: "string" },
|
|
538
|
+
name: { type: "string" },
|
|
539
|
+
description: { type: "string" },
|
|
540
|
+
priority: { type: "string", enum: ["urgent", "high", "medium", "low", "none"] },
|
|
541
|
+
stateId: { type: "string", description: "From ycadence_list_states." }
|
|
542
|
+
},
|
|
543
|
+
required: ["workItemId"]
|
|
544
|
+
},
|
|
545
|
+
handler: async (client, args) => {
|
|
546
|
+
const { workItemId, ...rest } = args;
|
|
547
|
+
const body = Object.fromEntries(Object.entries(rest).filter(([, value]) => value !== undefined));
|
|
548
|
+
if (Object.keys(body).length === 0) {
|
|
549
|
+
return "Nothing to update. Provide at least one field.";
|
|
550
|
+
}
|
|
551
|
+
const updated = await client.updateWorkItem(String(workItemId), body);
|
|
552
|
+
return `Updated ${updated.key}.`;
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
name: "ycadence_list_states",
|
|
557
|
+
description: "List a project’s workflow states. Needed before moving a work item.",
|
|
558
|
+
inputSchema: { type: "object", properties: { projectId }, required: ["projectId"] },
|
|
559
|
+
handler: async (client, args) => {
|
|
560
|
+
const { states } = await client.listStates(String(args.projectId));
|
|
561
|
+
return states.map((state) => `${state.id} ${state.name} (${state.group})`).join(`
|
|
562
|
+
`);
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
name: "ycadence_list_cycles",
|
|
567
|
+
description: "List a project’s cycles and their status.",
|
|
568
|
+
inputSchema: { type: "object", properties: { projectId }, required: ["projectId"] },
|
|
569
|
+
handler: async (client, args) => {
|
|
570
|
+
const { cycles } = await client.listCycles(String(args.projectId));
|
|
571
|
+
if (cycles.length === 0)
|
|
572
|
+
return "No cycles.";
|
|
573
|
+
return cycles.map((cycle) => `${cycle.id} ${cycle.name} [${cycle.status}]`).join(`
|
|
574
|
+
`);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
];
|
|
578
|
+
var LEGACY_TOOLS = TOOLS.map((tool) => ({
|
|
579
|
+
...tool,
|
|
580
|
+
name: tool.name.replace(/^ycadence_/, "devpulse_"),
|
|
581
|
+
description: `Deprecated: use ${tool.name}, which this is an alias of. ${tool.description}`
|
|
582
|
+
}));
|
|
583
|
+
var ALL_TOOLS = [...TOOLS, ...LEGACY_TOOLS];
|
|
584
|
+
async function runTool(client, name, args) {
|
|
585
|
+
const tool = ALL_TOOLS.find((candidate) => candidate.name === name);
|
|
586
|
+
if (tool === undefined) {
|
|
587
|
+
return { text: `No such tool: ${name}.`, isError: true };
|
|
588
|
+
}
|
|
589
|
+
for (const required of tool.inputSchema.required ?? []) {
|
|
590
|
+
if (args[required] === undefined) {
|
|
591
|
+
return { text: `${name} requires "${required}".`, isError: true };
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
try {
|
|
595
|
+
return { text: await tool.handler(client, args), isError: false };
|
|
596
|
+
} catch (error) {
|
|
597
|
+
if (error instanceof YCadenceError) {
|
|
598
|
+
const detail = error.issues === undefined ? error.message : `${error.message} (${error.issues.map((issue) => `${issue.path}: ${issue.message}`).join(", ")})`;
|
|
599
|
+
return { text: detail, isError: true };
|
|
600
|
+
}
|
|
601
|
+
return {
|
|
602
|
+
text: error instanceof Error ? error.message : "The request failed for an unknown reason.",
|
|
603
|
+
isError: true
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// src/server.ts
|
|
609
|
+
var PROTOCOL_VERSION = "2024-11-05";
|
|
610
|
+
function createServer(options) {
|
|
611
|
+
const { client, write, log } = options;
|
|
612
|
+
function reply(id, result) {
|
|
613
|
+
if (id === undefined || id === null)
|
|
614
|
+
return;
|
|
615
|
+
write(JSON.stringify({ jsonrpc: "2.0", id, result }));
|
|
616
|
+
}
|
|
617
|
+
function replyError(id, code, message) {
|
|
618
|
+
if (id === undefined || id === null)
|
|
619
|
+
return;
|
|
620
|
+
write(JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } }));
|
|
621
|
+
}
|
|
622
|
+
return {
|
|
623
|
+
async handle(line) {
|
|
624
|
+
const trimmed = line.trim();
|
|
625
|
+
if (trimmed.length === 0)
|
|
626
|
+
return;
|
|
627
|
+
let request;
|
|
628
|
+
try {
|
|
629
|
+
request = JSON.parse(trimmed);
|
|
630
|
+
} catch {
|
|
631
|
+
log(`ignored unparseable message: ${trimmed.slice(0, 120)}`);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
switch (request.method) {
|
|
635
|
+
case "initialize":
|
|
636
|
+
reply(request.id, {
|
|
637
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
638
|
+
capabilities: { tools: {} },
|
|
639
|
+
serverInfo: { name: "ycadence", version: "0.0.0" }
|
|
640
|
+
});
|
|
641
|
+
return;
|
|
642
|
+
case "notifications/initialized":
|
|
643
|
+
return;
|
|
644
|
+
case "tools/list":
|
|
645
|
+
reply(request.id, {
|
|
646
|
+
tools: ALL_TOOLS.map((tool) => ({
|
|
647
|
+
name: tool.name,
|
|
648
|
+
description: tool.description,
|
|
649
|
+
inputSchema: tool.inputSchema
|
|
650
|
+
}))
|
|
651
|
+
});
|
|
652
|
+
return;
|
|
653
|
+
case "tools/call": {
|
|
654
|
+
const name = String(request.params?.name ?? "");
|
|
655
|
+
const args = request.params?.arguments ?? {};
|
|
656
|
+
const outcome = await runTool(client, name, args);
|
|
657
|
+
reply(request.id, {
|
|
658
|
+
content: [{ type: "text", text: outcome.text }],
|
|
659
|
+
isError: outcome.isError
|
|
660
|
+
});
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
case "ping":
|
|
664
|
+
reply(request.id, {});
|
|
665
|
+
return;
|
|
666
|
+
default:
|
|
667
|
+
replyError(request.id, -32601, `Unknown method: ${request.method}`);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// src/bin.ts
|
|
674
|
+
var baseUrl = readEnv("URL");
|
|
675
|
+
var apiKey = readEnv("API_KEY");
|
|
676
|
+
if (baseUrl === undefined || apiKey === undefined) {
|
|
677
|
+
process.stderr.write(`ycadence-mcp: set YCADENCE_URL and YCADENCE_API_KEY.
|
|
678
|
+
` + ` export YCADENCE_URL=https://devpulse.yarlis.com
|
|
679
|
+
` + ` export YCADENCE_API_KEY=yc_live_p_...
|
|
680
|
+
` + ` export YCADENCE_IDENTITY_TOKEN=... # only behind IAP; expires in about an hour
|
|
681
|
+
` + `(the DEVPULSE_* names are still read when the YCADENCE_* one is unset)
|
|
682
|
+
`);
|
|
683
|
+
process.exit(1);
|
|
684
|
+
}
|
|
685
|
+
var server = createServer({
|
|
686
|
+
client: new YCadenceClient({
|
|
687
|
+
baseUrl,
|
|
688
|
+
apiKey,
|
|
689
|
+
identityToken: readEnv("IDENTITY_TOKEN")
|
|
690
|
+
}),
|
|
691
|
+
write: (line) => process.stdout.write(`${line}
|
|
692
|
+
`),
|
|
693
|
+
log: (message) => process.stderr.write(`ycadence-mcp: ${message}
|
|
694
|
+
`)
|
|
695
|
+
});
|
|
696
|
+
var input = createInterface({ input: process.stdin });
|
|
697
|
+
var queue = Promise.resolve();
|
|
698
|
+
input.on("line", (line) => {
|
|
699
|
+
queue = queue.then(() => server.handle(line)).catch((error) => {
|
|
700
|
+
process.stderr.write(`ycadence-mcp: ${error instanceof Error ? error.message : "error"}
|
|
701
|
+
`);
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
input.on("close", () => {
|
|
705
|
+
queue.then(() => process.exit(0)).catch(() => process.exit(1));
|
|
706
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycadence/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Model Context Protocol server for YCadence: lets an AI agent read and file work items.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ycadence",
|
|
7
|
+
"mcp",
|
|
8
|
+
"model-context-protocol",
|
|
9
|
+
"ai-agent",
|
|
10
|
+
"project-management"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/YarlisAISolutions/dev-pulse.git",
|
|
16
|
+
"directory": "packages/mcp"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/YarlisAISolutions/dev-pulse/tree/main/packages/mcp#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/YarlisAISolutions/dev-pulse/issues"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"bin": {
|
|
24
|
+
"ycadence-mcp": "dist/bin.js",
|
|
25
|
+
"devpulse-mcp": "dist/bin.js"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"provenance": false
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "rm -rf dist && bun build src/bin.ts --outdir dist --target node --format esm --conditions ycadence-source --define __YCADENCE_SDK_VERSION__=\\\"$(node -p \"require('../sdk/package.json').version\")\\\"",
|
|
44
|
+
"prepack": "cp ../../LICENSE LICENSE && bun run build",
|
|
45
|
+
"type-check": "tsc --noEmit",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@devpulse/core": "workspace:*",
|
|
50
|
+
"@ycadence/sdk": "workspace:*"
|
|
51
|
+
}
|
|
52
|
+
}
|