@giantswarm-io/pro 1.11.1 → 1.11.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giantswarm-io/pro",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Core library and MCP server for managing Giant Swarm's roadmap and customer project boards",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -388,7 +388,7 @@ export async function handleUpdateIssueField(args, extra) {
388
388
  export const createIssueInProjectTool = {
389
389
  name: 'create_issue_in_project',
390
390
  annotations: additiveWrite(),
391
- description: 'Create a new GitHub Issue in a specified repository and add it to a project board. Supports optional initial status, assignees, and labels. For public repos, only create sanitized, non-customer-specific content. If applying labels fails after the issue has already been created and added to the board, the issue is NOT rolled back -- the response reports success with a `warning` explaining that labels were not applied.',
391
+ description: 'Create a new GitHub Issue in a specified repository and add it to a project board. Supports optional initial status, assignees, and labels. For public repos, only create sanitized, non-customer-specific content. If applying labels fails after the issue has already been created and added to the board, the issue is NOT rolled back -- the response reports success with a `warning` explaining that labels were not applied. If GitHub refuses the creation (the token lacks issues:write on the repository, e.g. a GitHub App token outside its installation), the error names the repository and the missing permission and no issue is created.',
392
392
  inputSchema: {
393
393
  type: 'object',
394
394
  properties: {
@@ -432,6 +432,31 @@ export const createIssueInProjectTool = {
432
432
  }
433
433
  };
434
434
 
435
+ /**
436
+ * Whether a GitHub API error is a permission refusal: GraphQL reports it as a
437
+ * FORBIDDEN error ("Resource not accessible by integration" for a GitHub App
438
+ * token outside its installation's repositories or permissions), REST as 403.
439
+ * @param {Error} error
440
+ * @returns {boolean}
441
+ */
442
+ export function isPermissionRefusal(error) {
443
+ return error?.status === 403 ||
444
+ (Array.isArray(error?.errors) && error.errors.some(e => e?.type === 'FORBIDDEN')) ||
445
+ /Resource not accessible by integration/i.test(error?.message || '');
446
+ }
447
+
448
+ /**
449
+ * The error returned when GitHub refuses to create an issue in a repository.
450
+ * @param {string} owner
451
+ * @param {string} repo
452
+ * @returns {string}
453
+ */
454
+ export function issueCreationRefusedMessage(owner, repo) {
455
+ return `No issue was created: GitHub refused to create an issue in ${owner}/${repo} because the token lacks the issues:write permission there. ` +
456
+ 'A token issued by a GitHub App (for example through muster\'s GitHub sign-in) can only write to the repositories the App\'s installation covers; ' +
457
+ `ask an organization owner to add ${owner}/${repo} to that installation, or create the issue elsewhere and use add_existing_issue.`;
458
+ }
459
+
435
460
  export async function handleCreateIssueInProject(args, extra) {
436
461
  try {
437
462
  const token = extractToken(extra);
@@ -494,12 +519,21 @@ export async function handleCreateIssueInProject(args, extra) {
494
519
  }
495
520
 
496
521
  // Create the issue
497
- const createResult = await graphQLWithAuth(CREATE_ISSUE_MUTATION, {
498
- repositoryId,
499
- title: args.title,
500
- body: args.body || '',
501
- assigneeIds: assigneeIds.length > 0 ? assigneeIds : undefined
502
- }, token);
522
+ let createResult;
523
+ try {
524
+ createResult = await graphQLWithAuth(CREATE_ISSUE_MUTATION, {
525
+ repositoryId,
526
+ title: args.title,
527
+ body: args.body || '',
528
+ assigneeIds: assigneeIds.length > 0 ? assigneeIds : undefined
529
+ }, token);
530
+ } catch (error) {
531
+ if (isPermissionRefusal(error)) {
532
+ logger.error('MCP: Issue creation refused', { repository: `${owner}/${repo}`, error: error.message });
533
+ return { error: issueCreationRefusedMessage(owner, repo) };
534
+ }
535
+ throw error;
536
+ }
503
537
 
504
538
  const issue = createResult.createIssue.issue;
505
539