mcp-git-issue-priority 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.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +412 -0
  3. package/dist/config/index.d.ts +20 -0
  4. package/dist/config/index.d.ts.map +1 -0
  5. package/dist/config/index.js +76 -0
  6. package/dist/config/index.js.map +1 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +54 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/models/audit-log.d.ts +57 -0
  12. package/dist/models/audit-log.d.ts.map +1 -0
  13. package/dist/models/audit-log.js +50 -0
  14. package/dist/models/audit-log.js.map +1 -0
  15. package/dist/models/batch-state.d.ts +81 -0
  16. package/dist/models/batch-state.d.ts.map +1 -0
  17. package/dist/models/batch-state.js +38 -0
  18. package/dist/models/batch-state.js.map +1 -0
  19. package/dist/models/index.d.ts +9 -0
  20. package/dist/models/index.d.ts.map +1 -0
  21. package/dist/models/index.js +9 -0
  22. package/dist/models/index.js.map +1 -0
  23. package/dist/models/issue.d.ts +193 -0
  24. package/dist/models/issue.d.ts.map +1 -0
  25. package/dist/models/issue.js +86 -0
  26. package/dist/models/issue.js.map +1 -0
  27. package/dist/models/lock.d.ts +35 -0
  28. package/dist/models/lock.d.ts.map +1 -0
  29. package/dist/models/lock.js +48 -0
  30. package/dist/models/lock.js.map +1 -0
  31. package/dist/models/pr-status.d.ts +152 -0
  32. package/dist/models/pr-status.d.ts.map +1 -0
  33. package/dist/models/pr-status.js +36 -0
  34. package/dist/models/pr-status.js.map +1 -0
  35. package/dist/models/priority-score.d.ts +41 -0
  36. package/dist/models/priority-score.d.ts.map +1 -0
  37. package/dist/models/priority-score.js +64 -0
  38. package/dist/models/priority-score.js.map +1 -0
  39. package/dist/models/selection-filter.d.ts +16 -0
  40. package/dist/models/selection-filter.d.ts.map +1 -0
  41. package/dist/models/selection-filter.js +40 -0
  42. package/dist/models/selection-filter.js.map +1 -0
  43. package/dist/models/workflow-state.d.ts +126 -0
  44. package/dist/models/workflow-state.d.ts.map +1 -0
  45. package/dist/models/workflow-state.js +106 -0
  46. package/dist/models/workflow-state.js.map +1 -0
  47. package/dist/services/batch.d.ts +23 -0
  48. package/dist/services/batch.d.ts.map +1 -0
  49. package/dist/services/batch.js +126 -0
  50. package/dist/services/batch.js.map +1 -0
  51. package/dist/services/github.d.ts +48 -0
  52. package/dist/services/github.d.ts.map +1 -0
  53. package/dist/services/github.js +315 -0
  54. package/dist/services/github.js.map +1 -0
  55. package/dist/services/index.d.ts +7 -0
  56. package/dist/services/index.d.ts.map +1 -0
  57. package/dist/services/index.js +7 -0
  58. package/dist/services/index.js.map +1 -0
  59. package/dist/services/locking.d.ts +42 -0
  60. package/dist/services/locking.d.ts.map +1 -0
  61. package/dist/services/locking.js +195 -0
  62. package/dist/services/locking.js.map +1 -0
  63. package/dist/services/logging.d.ts +40 -0
  64. package/dist/services/logging.d.ts.map +1 -0
  65. package/dist/services/logging.js +80 -0
  66. package/dist/services/logging.js.map +1 -0
  67. package/dist/services/priority.d.ts +18 -0
  68. package/dist/services/priority.d.ts.map +1 -0
  69. package/dist/services/priority.js +33 -0
  70. package/dist/services/priority.js.map +1 -0
  71. package/dist/services/workflow.d.ts +39 -0
  72. package/dist/services/workflow.d.ts.map +1 -0
  73. package/dist/services/workflow.js +201 -0
  74. package/dist/services/workflow.js.map +1 -0
  75. package/dist/tools/advance-workflow.d.ts +3 -0
  76. package/dist/tools/advance-workflow.d.ts.map +1 -0
  77. package/dist/tools/advance-workflow.js +120 -0
  78. package/dist/tools/advance-workflow.js.map +1 -0
  79. package/dist/tools/batch-continue.d.ts +3 -0
  80. package/dist/tools/batch-continue.d.ts.map +1 -0
  81. package/dist/tools/batch-continue.js +133 -0
  82. package/dist/tools/batch-continue.js.map +1 -0
  83. package/dist/tools/bulk-update-issues.d.ts +3 -0
  84. package/dist/tools/bulk-update-issues.d.ts.map +1 -0
  85. package/dist/tools/bulk-update-issues.js +87 -0
  86. package/dist/tools/bulk-update-issues.js.map +1 -0
  87. package/dist/tools/create-issue.d.ts +41 -0
  88. package/dist/tools/create-issue.d.ts.map +1 -0
  89. package/dist/tools/create-issue.js +186 -0
  90. package/dist/tools/create-issue.js.map +1 -0
  91. package/dist/tools/force-claim.d.ts +3 -0
  92. package/dist/tools/force-claim.d.ts.map +1 -0
  93. package/dist/tools/force-claim.js +99 -0
  94. package/dist/tools/force-claim.js.map +1 -0
  95. package/dist/tools/get-pr-status.d.ts +3 -0
  96. package/dist/tools/get-pr-status.d.ts.map +1 -0
  97. package/dist/tools/get-pr-status.js +51 -0
  98. package/dist/tools/get-pr-status.js.map +1 -0
  99. package/dist/tools/get-workflow-analytics.d.ts +3 -0
  100. package/dist/tools/get-workflow-analytics.d.ts.map +1 -0
  101. package/dist/tools/get-workflow-analytics.js +264 -0
  102. package/dist/tools/get-workflow-analytics.js.map +1 -0
  103. package/dist/tools/get-workflow-status.d.ts +3 -0
  104. package/dist/tools/get-workflow-status.d.ts.map +1 -0
  105. package/dist/tools/get-workflow-status.js +103 -0
  106. package/dist/tools/get-workflow-status.js.map +1 -0
  107. package/dist/tools/implement-batch.d.ts +3 -0
  108. package/dist/tools/implement-batch.d.ts.map +1 -0
  109. package/dist/tools/implement-batch.js +124 -0
  110. package/dist/tools/implement-batch.js.map +1 -0
  111. package/dist/tools/list-backlog.d.ts +3 -0
  112. package/dist/tools/list-backlog.d.ts.map +1 -0
  113. package/dist/tools/list-backlog.js +146 -0
  114. package/dist/tools/list-backlog.js.map +1 -0
  115. package/dist/tools/release-lock.d.ts +3 -0
  116. package/dist/tools/release-lock.d.ts.map +1 -0
  117. package/dist/tools/release-lock.js +95 -0
  118. package/dist/tools/release-lock.js.map +1 -0
  119. package/dist/tools/select-next-issue.d.ts +3 -0
  120. package/dist/tools/select-next-issue.d.ts.map +1 -0
  121. package/dist/tools/select-next-issue.js +192 -0
  122. package/dist/tools/select-next-issue.js.map +1 -0
  123. package/dist/tools/sync-backlog-labels.d.ts +3 -0
  124. package/dist/tools/sync-backlog-labels.d.ts.map +1 -0
  125. package/dist/tools/sync-backlog-labels.js +164 -0
  126. package/dist/tools/sync-backlog-labels.js.map +1 -0
  127. package/package.json +70 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 steiner385
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,412 @@
1
+ # MCP GitHub Issue Priority Server
2
+
3
+ A Model Context Protocol (MCP) server that enables AI assistants to manage GitHub issues with deterministic priority scoring and concurrency-safe selection.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # 1. Install from npm (recommended)
9
+ npm install -g mcp-git-issue-priority
10
+
11
+ # 2. Authenticate (if not already using GitHub CLI)
12
+ gh auth login
13
+
14
+ # 3. Add to Claude Code (~/.claude.json)
15
+ ```
16
+
17
+ ```json
18
+ {
19
+ "mcpServers": {
20
+ "github-issue-priority": {
21
+ "command": "mcp-git-issue-priority"
22
+ }
23
+ }
24
+ }
25
+ ```
26
+
27
+ ```bash
28
+ # 4. Restart Claude Code and verify
29
+ # The MCP tools should appear when you run /mcp
30
+ ```
31
+
32
+ ## Features
33
+
34
+ - **Priority-Based Issue Selection**: Deterministic scoring algorithm ensures consistent issue prioritization across sessions
35
+ - **Concurrency-Safe Locking**: File-based atomic locking prevents multiple AI sessions from selecting the same issue
36
+ - **Guided Workflow**: 8-phase workflow (selection → research → branch → implementation → testing → commit → pr → review) with transition validation
37
+ - **Automatic Labeling**: Creates and manages priority (`P0`-`P3`), type (`bug`, `feature`, `chore`, `docs`), and status labels
38
+ - **Stale Lock Detection**: Automatically detects and cleans up locks from dead processes
39
+ - **Audit Logging**: JSON Lines logging for all operations with 30-day retention
40
+
41
+ ## Installation
42
+
43
+ ### Prerequisites
44
+
45
+ - **Node.js 20+** - [Download](https://nodejs.org/)
46
+ - **GitHub CLI** (recommended) - [Install](https://cli.github.com/) and run `gh auth login`
47
+ - Or: a GitHub personal access token with `repo` scope
48
+
49
+ ### Install from npm (recommended)
50
+
51
+ ```bash
52
+ npm install -g mcp-git-issue-priority
53
+ ```
54
+
55
+ ### Install specific version
56
+
57
+ ```bash
58
+ npm install -g mcp-git-issue-priority@1.0.0
59
+ ```
60
+
61
+ ### Install from source
62
+
63
+ ```bash
64
+ git clone https://github.com/steiner385/mcp-git-issue-priority.git
65
+ cd mcp-git-issue-priority
66
+ npm install && npm link
67
+ ```
68
+
69
+ ### Troubleshooting
70
+
71
+ | Issue | Solution |
72
+ |-------|----------|
73
+ | `command not found: mcp-git-issue-priority` | Ensure npm global bin is in your PATH: `npm bin -g` |
74
+ | `GitHub authentication required` | Run `gh auth login` or set `GITHUB_TOKEN` |
75
+ | Build errors during install | Ensure Node.js 20+ is installed: `node --version` |
76
+
77
+ ## Configuration
78
+
79
+ ### GitHub Authentication
80
+
81
+ The server supports two authentication methods:
82
+
83
+ #### Recommended: GitHub CLI (automatic)
84
+
85
+ If you have [GitHub CLI](https://cli.github.com/) installed and authenticated, the server automatically retrieves your token:
86
+
87
+ ```bash
88
+ # One-time setup
89
+ gh auth login
90
+ ```
91
+
92
+ This is the recommended approach - no manual token management required.
93
+
94
+ #### Alternative: Environment Variable
95
+
96
+ Set `GITHUB_TOKEN` with a [personal access token](https://github.com/settings/tokens) that has `repo` scope:
97
+
98
+ ```bash
99
+ export GITHUB_TOKEN="ghp_your_personal_access_token"
100
+ ```
101
+
102
+ Or configure it in your MCP settings (see below).
103
+
104
+ ### Claude Code Configuration
105
+
106
+ Add to `~/.claude.json` (global) or `.claude/settings.json` (project):
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "github-issue-priority": {
112
+ "command": "mcp-git-issue-priority"
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ **Using a personal access token instead of GitHub CLI?** Add the token to the config:
119
+
120
+ ```json
121
+ {
122
+ "mcpServers": {
123
+ "github-issue-priority": {
124
+ "command": "mcp-git-issue-priority",
125
+ "env": {
126
+ "GITHUB_TOKEN": "ghp_your_personal_access_token"
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ ### Verify Installation
134
+
135
+ After restarting Claude Code:
136
+
137
+ 1. Run `/mcp` to see available MCP servers
138
+ 2. The `github-issue-priority` server should be listed with 13 tools
139
+ 3. Try `list_backlog` on any repository to confirm it's working
140
+
141
+ ## Available Tools
142
+
143
+ ### `create_issue`
144
+
145
+ Create a new GitHub issue with mandatory priority and type labels.
146
+
147
+ ```
148
+ Arguments:
149
+ - title (required): Issue title
150
+ - body (optional): Issue description
151
+ - priority (required): P0 (critical) | P1 (high) | P2 (medium) | P3 (low)
152
+ - type (required): bug | feature | chore | docs
153
+ - repository (required): "owner/repo" format
154
+ ```
155
+
156
+ ### `select_next_issue`
157
+
158
+ Select and lock the highest-priority issue from the backlog. Uses deterministic scoring to ensure consistent selection.
159
+
160
+ ```
161
+ Arguments:
162
+ - repository (required): "owner/repo" format
163
+ - type (optional): Filter by issue type
164
+ - maxPriority (optional): Only consider issues at or above this priority
165
+ ```
166
+
167
+ ### `list_backlog`
168
+
169
+ List all open issues in priority order without acquiring locks (read-only).
170
+
171
+ ```
172
+ Arguments:
173
+ - repository (required): "owner/repo" format
174
+ - type (optional): Filter by issue type
175
+ - limit (optional): Maximum issues to return (default: 20)
176
+ ```
177
+
178
+ ### `advance_workflow`
179
+
180
+ Advance the workflow to the next phase for a locked issue.
181
+
182
+ ```
183
+ Arguments:
184
+ - issueNumber (required): Issue number to advance
185
+ - targetPhase (required): research | branch | implementation | testing | commit | pr | review
186
+ - repository (required): "owner/repo" format
187
+ - testsPassed (optional): Required when advancing to 'commit' phase
188
+ - prTitle (optional): Required for 'pr' phase
189
+ - prBody (optional): Required for 'pr' phase
190
+ - skipJustification (optional): Required if skipping phases
191
+ ```
192
+
193
+ ### `get_workflow_status`
194
+
195
+ Get the current workflow status for locked issues.
196
+
197
+ ```
198
+ Arguments:
199
+ - issueNumber (optional): Specific issue number
200
+ - repository (optional): "owner/repo" format
201
+ ```
202
+
203
+ ### `release_lock`
204
+
205
+ Release lock on an issue (on completion, abandonment, or merge).
206
+
207
+ ```
208
+ Arguments:
209
+ - issueNumber (required): Issue number
210
+ - reason (required): completed | abandoned | merged
211
+ - repository (required): "owner/repo" format
212
+ ```
213
+
214
+ ### `force_claim`
215
+
216
+ Force claim an issue locked by another session (requires confirmation).
217
+
218
+ ```
219
+ Arguments:
220
+ - issueNumber (required): Issue number to claim
221
+ - confirmation (required): Must be exactly "I understand this may cause conflicts"
222
+ - repository (required): "owner/repo" format
223
+ ```
224
+
225
+ ### `sync_backlog_labels`
226
+
227
+ Detect and optionally fix issues missing required priority/type/status labels.
228
+
229
+ ```
230
+ Arguments:
231
+ - repository (required): "owner/repo" format
232
+ - mode (optional): "report" (default) to list issues, "update" to apply labels
233
+ - defaultPriority (optional): P0 | P1 | P2 | P3 (defaults to P2)
234
+ - defaultType (optional): bug | feature | chore | docs (defaults to feature)
235
+ ```
236
+
237
+ In **report mode**, returns a list of all issues missing labels with details about what's missing.
238
+
239
+ In **update mode**, applies default labels to issues:
240
+ - Missing priority → `priority:P2` (or specified default)
241
+ - Missing type → `type:feature` (or specified default)
242
+ - Missing status → `status:backlog`
243
+
244
+ ### `get_pr_status`
245
+
246
+ Check CI status, approval state, and merge state of a pull request.
247
+
248
+ ```
249
+ Arguments:
250
+ - repository (required): "owner/repo" format
251
+ - prNumber (required): Pull request number to check
252
+ ```
253
+
254
+ ### `bulk_update_issues`
255
+
256
+ Add/remove labels and close/reopen multiple issues at once.
257
+
258
+ ```
259
+ Arguments:
260
+ - repository (required): "owner/repo" format
261
+ - issues (required): Array of issue numbers (1-50)
262
+ - addLabels (optional): Labels to add
263
+ - removeLabels (optional): Labels to remove
264
+ - state (optional): "open" | "closed"
265
+ ```
266
+
267
+ ### `implement_batch`
268
+
269
+ Start implementing a batch of N issues in priority order. Returns the first issue to implement.
270
+
271
+ ```
272
+ Arguments:
273
+ - repository (required): "owner/repo" format
274
+ - count (required): Number of issues to implement (1-10)
275
+ - includeTypes (optional): Only include these issue types
276
+ - excludeTypes (optional): Exclude these issue types
277
+ - maxPriority (optional): Only P0, P1, etc.
278
+ ```
279
+
280
+ ### `batch_continue`
281
+
282
+ Continue batch implementation. Polls for PR merge, then returns next issue or completion.
283
+
284
+ ```
285
+ Arguments:
286
+ - batchId (required): Batch ID from implement_batch
287
+ - prNumber (optional): PR number for current issue
288
+ ```
289
+
290
+ ### `get_workflow_analytics`
291
+
292
+ Get time-based workflow analytics: cycle time, phase breakdown, aging reports.
293
+
294
+ ```
295
+ Arguments:
296
+ - repository (required): "owner/repo" format
297
+ - period (optional): "7d" | "30d" | "90d" | "all" (default: 30d)
298
+ ```
299
+
300
+ ## Priority Scoring Algorithm
301
+
302
+ Issues are scored using a deterministic formula:
303
+
304
+ ```
305
+ score = (basePoints + ageBonus) * blockingMultiplier * blockedPenalty
306
+ ```
307
+
308
+ - **Base Points**: P0=1000, P1=100, P2=10, P3=1
309
+ - **Age Bonus**: +1 point per day since creation (max 365)
310
+ - **Blocking Multiplier**: 1.5x for issues with "blocking" label
311
+ - **Blocked Penalty**: 0.1x for issues blocked by open parent issues (via GitHub sub-issues)
312
+ - **Tiebreaker**: Earlier creation date wins (FIFO)
313
+
314
+ ### Dependency Detection
315
+
316
+ Issues with open parent issues (using GitHub's sub-issues feature) are automatically deprioritized with a 0.1x penalty. This ensures that blocked work sinks to the bottom of the backlog until its dependencies are resolved. Once a parent issue is closed, the child issue's priority returns to normal.
317
+
318
+ ## Workflow Phases
319
+
320
+ 1. **selection**: Issue selected and locked
321
+ 2. **research**: Understanding the problem
322
+ 3. **branch**: Feature branch created
323
+ 4. **implementation**: Code changes in progress
324
+ 5. **testing**: Running tests and validation
325
+ 6. **commit**: Changes committed
326
+ 7. **pr**: Pull request created
327
+ 8. **review**: Awaiting review/merge
328
+
329
+ ## Data Storage
330
+
331
+ All data is stored locally in `~/.mcp-git-issue-priority/`:
332
+
333
+ ```
334
+ ~/.mcp-git-issue-priority/
335
+ ├── locks/ # Active lock files (.lockdata)
336
+ ├── workflow/ # Workflow state files (.json)
337
+ └── logs/ # Audit logs (JSON Lines format)
338
+ ```
339
+
340
+ ## Development
341
+
342
+ ### Build
343
+
344
+ ```bash
345
+ npm run build
346
+ ```
347
+
348
+ ### Test
349
+
350
+ ```bash
351
+ npm test
352
+ ```
353
+
354
+ ### Lint
355
+
356
+ ```bash
357
+ npm run lint
358
+ ```
359
+
360
+ ### Type Check
361
+
362
+ ```bash
363
+ npm run typecheck
364
+ ```
365
+
366
+ ## Releasing (Maintainers)
367
+
368
+ ### One-time Setup
369
+
370
+ 1. Create an npm account at https://www.npmjs.com/
371
+ 2. Go to https://www.npmjs.com/settings/tokens
372
+ 3. Create an "Automation" token with "Publish" permission
373
+ 4. Add to GitHub: Settings → Secrets → Actions → New secret named `NPM_TOKEN`
374
+
375
+ ### Creating a Release
376
+
377
+ ```bash
378
+ # Patch release (bug fixes): 1.0.0 → 1.0.1
379
+ npm version patch -m "Release v%s"
380
+ git push && git push --tags
381
+
382
+ # Minor release (new features): 1.0.0 → 1.1.0
383
+ npm version minor -m "Release v%s"
384
+ git push && git push --tags
385
+
386
+ # Major release (breaking changes): 1.0.0 → 2.0.0
387
+ npm version major -m "Release v%s"
388
+ git push && git push --tags
389
+ ```
390
+
391
+ Pushing a tag triggers the release workflow which:
392
+ - Runs lint, build, and tests
393
+ - Creates a GitHub release with the tarball attached
394
+ - Publishes to npm registry
395
+
396
+ ### Download Tracking
397
+
398
+ - **GitHub**: Releases page shows download count per `.tgz` asset
399
+ - **npm**: https://www.npmjs.com/package/mcp-git-issue-priority shows weekly downloads
400
+
401
+ ## License
402
+
403
+ MIT License - see [LICENSE](LICENSE) for details.
404
+
405
+ ## Contributing
406
+
407
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
408
+
409
+ ## Support
410
+
411
+ - [Open an issue](https://github.com/steiner385/mcp-git-issue-priority/issues) for bug reports or feature requests
412
+ - Check existing issues before creating new ones
@@ -0,0 +1,20 @@
1
+ export interface Config {
2
+ baseDir: string;
3
+ locksDir: string;
4
+ workflowDir: string;
5
+ logsDir: string;
6
+ githubToken: string;
7
+ sessionId: string;
8
+ }
9
+ export declare function getBaseDir(): string;
10
+ export declare function getLocksDir(): string;
11
+ export declare function getWorkflowDir(): string;
12
+ export declare function getLogsDir(): string;
13
+ export declare function getBatchesDir(): string;
14
+ export declare function ensureDirectories(): Promise<void>;
15
+ export declare function generateSessionId(): string;
16
+ export declare function createConfig(githubToken?: string): Config;
17
+ export declare function getConfig(): Config;
18
+ export declare function setConfig(config: Config): void;
19
+ export declare function resetConfig(): void;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKvD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAkBD,wBAAgB,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBzD;AAID,wBAAgB,SAAS,IAAI,MAAM,CAKlC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
@@ -0,0 +1,76 @@
1
+ import { homedir } from 'os';
2
+ import { join } from 'path';
3
+ import { mkdir } from 'fs/promises';
4
+ import { execFileSync } from 'child_process';
5
+ const BASE_DIR_NAME = '.mcp-git-issue-priority';
6
+ export function getBaseDir() {
7
+ return join(homedir(), BASE_DIR_NAME);
8
+ }
9
+ export function getLocksDir() {
10
+ return join(getBaseDir(), 'locks');
11
+ }
12
+ export function getWorkflowDir() {
13
+ return join(getBaseDir(), 'workflow');
14
+ }
15
+ export function getLogsDir() {
16
+ return join(getBaseDir(), 'logs');
17
+ }
18
+ export function getBatchesDir() {
19
+ return join(getBaseDir(), 'batches');
20
+ }
21
+ export async function ensureDirectories() {
22
+ const dirs = [getBaseDir(), getLocksDir(), getWorkflowDir(), getLogsDir(), getBatchesDir()];
23
+ for (const dir of dirs) {
24
+ await mkdir(dir, { recursive: true });
25
+ }
26
+ }
27
+ export function generateSessionId() {
28
+ return crypto.randomUUID();
29
+ }
30
+ /**
31
+ * Attempts to get a GitHub token from the GitHub CLI (`gh auth token`).
32
+ * Returns null if gh is not installed or not authenticated.
33
+ */
34
+ function getGitHubCliToken() {
35
+ try {
36
+ const token = execFileSync('gh', ['auth', 'token'], {
37
+ encoding: 'utf-8',
38
+ stdio: ['pipe', 'pipe', 'pipe'],
39
+ }).trim();
40
+ return token || null;
41
+ }
42
+ catch {
43
+ return null;
44
+ }
45
+ }
46
+ export function createConfig(githubToken) {
47
+ // Try sources in order: explicit param, env var, GitHub CLI
48
+ const token = githubToken ?? process.env.GITHUB_TOKEN ?? getGitHubCliToken();
49
+ if (!token) {
50
+ throw new Error('GitHub authentication required. Either:\n' +
51
+ ' 1. Set GITHUB_TOKEN environment variable, or\n' +
52
+ ' 2. Install and authenticate GitHub CLI: gh auth login');
53
+ }
54
+ return {
55
+ baseDir: getBaseDir(),
56
+ locksDir: getLocksDir(),
57
+ workflowDir: getWorkflowDir(),
58
+ logsDir: getLogsDir(),
59
+ githubToken: token,
60
+ sessionId: generateSessionId(),
61
+ };
62
+ }
63
+ let globalConfig = null;
64
+ export function getConfig() {
65
+ if (!globalConfig) {
66
+ globalConfig = createConfig();
67
+ }
68
+ return globalConfig;
69
+ }
70
+ export function setConfig(config) {
71
+ globalConfig = config;
72
+ }
73
+ export function resetConfig() {
74
+ globalConfig = null;
75
+ }
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAW7C,MAAM,aAAa,GAAG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C;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,WAAoB;IAC/C,4DAA4D;IAC5D,MAAM,KAAK,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,iBAAiB,EAAE,CAAC;IAC7E,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,2CAA2C;YACzC,kDAAkD;YAClD,yDAAyD,CAC5D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,UAAU,EAAE;QACrB,QAAQ,EAAE,WAAW,EAAE;QACvB,WAAW,EAAE,cAAc,EAAE;QAC7B,OAAO,EAAE,UAAU,EAAE;QACrB,WAAW,EAAE,KAAK;QAClB,SAAS,EAAE,iBAAiB,EAAE;KAC/B,CAAC;AACJ,CAAC;AAED,IAAI,YAAY,GAAkB,IAAI,CAAC;AAEvC,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,YAAY,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,YAAY,GAAG,MAAM,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { createConfig, ensureDirectories, setConfig } from './config/index.js';
5
+ import { initializeLogger } from './services/logging.js';
6
+ import { initializeGitHubService } from './services/github.js';
7
+ import { registerCreateIssueTool } from './tools/create-issue.js';
8
+ import { registerSelectNextIssueTool } from './tools/select-next-issue.js';
9
+ import { registerAdvanceWorkflowTool } from './tools/advance-workflow.js';
10
+ import { registerReleaseLockTool } from './tools/release-lock.js';
11
+ import { registerForceClaimTool } from './tools/force-claim.js';
12
+ import { registerGetWorkflowStatusTool } from './tools/get-workflow-status.js';
13
+ import { registerListBacklogTool } from './tools/list-backlog.js';
14
+ import { registerSyncBacklogLabelsTool } from './tools/sync-backlog-labels.js';
15
+ import { registerGetPrStatusTool } from './tools/get-pr-status.js';
16
+ import { registerBulkUpdateIssuesTool } from './tools/bulk-update-issues.js';
17
+ import { registerImplementBatchTool } from './tools/implement-batch.js';
18
+ import { registerBatchContinueTool } from './tools/batch-continue.js';
19
+ import { registerGetWorkflowAnalyticsTool } from './tools/get-workflow-analytics.js';
20
+ async function main() {
21
+ try {
22
+ const config = createConfig();
23
+ setConfig(config);
24
+ await ensureDirectories();
25
+ initializeLogger(config.sessionId);
26
+ initializeGitHubService(config.githubToken);
27
+ const server = new McpServer({
28
+ name: 'mcp-git-issue-priority',
29
+ version: '1.0.0',
30
+ });
31
+ registerCreateIssueTool(server);
32
+ registerSelectNextIssueTool(server);
33
+ registerAdvanceWorkflowTool(server);
34
+ registerReleaseLockTool(server);
35
+ registerForceClaimTool(server);
36
+ registerGetWorkflowStatusTool(server);
37
+ registerListBacklogTool(server);
38
+ registerSyncBacklogLabelsTool(server);
39
+ registerGetPrStatusTool(server);
40
+ registerBulkUpdateIssuesTool(server);
41
+ registerImplementBatchTool(server);
42
+ registerBatchContinueTool(server);
43
+ registerGetWorkflowAnalyticsTool(server);
44
+ const transport = new StdioServerTransport();
45
+ await server.connect(transport);
46
+ console.error(`MCP Issue Priority Server started (session: ${config.sessionId})`);
47
+ }
48
+ catch (error) {
49
+ console.error('Failed to start MCP server:', error);
50
+ process.exit(1);
51
+ }
52
+ }
53
+ main();
54
+ //# sourceMappingURL=index.js.map
@@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MAAM,CAAC,SAAS,CAAC,CAAC;QACnC,uBAAuB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAE5C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;YAC3B,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAChC,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACpC,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACpC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAChC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC/B,6BAA6B,CAAC,MAAM,CAAC,CAAC;QACtC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAChC,6BAA6B,CAAC,MAAM,CAAC,CAAC;QACtC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAChC,4BAA4B,CAAC,MAAM,CAAC,CAAC;QACrC,0BAA0B,CAAC,MAAM,CAAC,CAAC;QACnC,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAClC,gCAAgC,CAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEhC,OAAO,CAAC,KAAK,CAAC,+CAA+C,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;IACpF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { z } from 'zod';
2
+ import type { WorkflowPhase } from './workflow-state.js';
3
+ export declare const AuditLogLevelSchema: z.ZodEnum<["info", "warn", "error"]>;
4
+ export type AuditLogLevel = z.infer<typeof AuditLogLevelSchema>;
5
+ export declare const AuditLogOutcomeSchema: z.ZodEnum<["success", "failure", "skipped"]>;
6
+ export type AuditLogOutcome = z.infer<typeof AuditLogOutcomeSchema>;
7
+ export declare const AuditLogEntrySchema: z.ZodObject<{
8
+ timestamp: z.ZodString;
9
+ level: z.ZodEnum<["info", "warn", "error"]>;
10
+ tool: z.ZodString;
11
+ sessionId: z.ZodString;
12
+ repoFullName: z.ZodOptional<z.ZodString>;
13
+ issueNumber: z.ZodOptional<z.ZodNumber>;
14
+ phase: z.ZodOptional<z.ZodEnum<["selection", "research", "branch", "implementation", "testing", "commit", "pr", "review", "merged", "abandoned"]>>;
15
+ duration: z.ZodOptional<z.ZodNumber>;
16
+ outcome: z.ZodEnum<["success", "failure", "skipped"]>;
17
+ error: z.ZodOptional<z.ZodString>;
18
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ sessionId: string;
21
+ timestamp: string;
22
+ level: "info" | "warn" | "error";
23
+ tool: string;
24
+ outcome: "success" | "failure" | "skipped";
25
+ issueNumber?: number | undefined;
26
+ repoFullName?: string | undefined;
27
+ error?: string | undefined;
28
+ phase?: "selection" | "research" | "branch" | "implementation" | "testing" | "commit" | "pr" | "review" | "merged" | "abandoned" | undefined;
29
+ duration?: number | undefined;
30
+ metadata?: Record<string, unknown> | undefined;
31
+ }, {
32
+ sessionId: string;
33
+ timestamp: string;
34
+ level: "info" | "warn" | "error";
35
+ tool: string;
36
+ outcome: "success" | "failure" | "skipped";
37
+ issueNumber?: number | undefined;
38
+ repoFullName?: string | undefined;
39
+ error?: string | undefined;
40
+ phase?: "selection" | "research" | "branch" | "implementation" | "testing" | "commit" | "pr" | "review" | "merged" | "abandoned" | undefined;
41
+ duration?: number | undefined;
42
+ metadata?: Record<string, unknown> | undefined;
43
+ }>;
44
+ export type AuditLogEntry = z.infer<typeof AuditLogEntrySchema>;
45
+ export declare function createAuditLogEntry(tool: string, sessionId: string, outcome: AuditLogOutcome, options?: {
46
+ level?: AuditLogLevel;
47
+ repoFullName?: string;
48
+ issueNumber?: number;
49
+ phase?: WorkflowPhase;
50
+ duration?: number;
51
+ error?: string;
52
+ metadata?: Record<string, unknown>;
53
+ }): AuditLogEntry;
54
+ export declare function serializeLogEntry(entry: AuditLogEntry): string;
55
+ export declare function parseLogEntry(line: string): AuditLogEntry | null;
56
+ export declare function getLogFileName(date?: Date): string;
57
+ //# sourceMappingURL=audit-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-log.d.ts","sourceRoot":"","sources":["../../src/models/audit-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,eAAO,MAAM,mBAAmB,sCAAoC,CAAC;AACrE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,qBAAqB,8CAA4C,CAAC;AAC/E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,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