@northbridge-security/secureai 0.1.13

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 (50) hide show
  1. package/.claude/README.md +122 -0
  2. package/.claude/commands/architect/clean.md +978 -0
  3. package/.claude/commands/architect/kiss.md +762 -0
  4. package/.claude/commands/architect/review.md +704 -0
  5. package/.claude/commands/catchup.md +90 -0
  6. package/.claude/commands/code.md +115 -0
  7. package/.claude/commands/commit.md +1218 -0
  8. package/.claude/commands/cover.md +1298 -0
  9. package/.claude/commands/fmea.md +275 -0
  10. package/.claude/commands/kaizen.md +312 -0
  11. package/.claude/commands/pr.md +503 -0
  12. package/.claude/commands/todo.md +99 -0
  13. package/.claude/commands/worktree.md +738 -0
  14. package/.claude/commands/wrapup.md +103 -0
  15. package/LICENSE +183 -0
  16. package/README.md +108 -0
  17. package/dist/cli.js +75634 -0
  18. package/docs/agents/devops-reviewer.md +889 -0
  19. package/docs/agents/kiss-simplifier.md +1088 -0
  20. package/docs/agents/typescript.md +8 -0
  21. package/docs/guides/README.md +109 -0
  22. package/docs/guides/agents.clean.arch.md +244 -0
  23. package/docs/guides/agents.clean.arch.ts.md +1314 -0
  24. package/docs/guides/agents.gotask.md +1037 -0
  25. package/docs/guides/agents.markdown.md +1209 -0
  26. package/docs/guides/agents.onepassword.md +285 -0
  27. package/docs/guides/agents.sonar.md +857 -0
  28. package/docs/guides/agents.tdd.md +838 -0
  29. package/docs/guides/agents.tdd.ts.md +1062 -0
  30. package/docs/guides/agents.typesript.md +1389 -0
  31. package/docs/guides/github-mcp.md +1075 -0
  32. package/package.json +130 -0
  33. package/packages/secureai-cli/src/cli.ts +21 -0
  34. package/tasks/README.md +880 -0
  35. package/tasks/aws.yml +64 -0
  36. package/tasks/bash.yml +118 -0
  37. package/tasks/bun.yml +738 -0
  38. package/tasks/claude.yml +183 -0
  39. package/tasks/docker.yml +420 -0
  40. package/tasks/docs.yml +127 -0
  41. package/tasks/git.yml +1336 -0
  42. package/tasks/gotask.yml +132 -0
  43. package/tasks/json.yml +77 -0
  44. package/tasks/markdown.yml +95 -0
  45. package/tasks/onepassword.yml +350 -0
  46. package/tasks/security.yml +102 -0
  47. package/tasks/sonar.yml +437 -0
  48. package/tasks/template.yml +74 -0
  49. package/tasks/vscode.yml +103 -0
  50. package/tasks/yaml.yml +121 -0
@@ -0,0 +1,1075 @@
1
+ # GitHub MCP Integration Guide
2
+
3
+ This guide explains how to integrate GitHub MCP server with AI development tools for repository management, issue tracking, and pull request workflows.
4
+
5
+ <details>
6
+ <summary>Table of Contents</summary>
7
+
8
+ - [GitHub MCP Integration Guide](#github-mcp-integration-guide)
9
+ - [Overview](#overview)
10
+ - [What the Installer Does](#what-the-installer-does)
11
+ - [1. Token Validation](#1-token-validation)
12
+ - [2. MCP Server Configuration](#2-mcp-server-configuration)
13
+ - [3. Environment Setup](#3-environment-setup)
14
+ - [Prerequisites](#prerequisites)
15
+ - [System Requirements](#system-requirements)
16
+ - [GitHub Account Setup](#github-account-setup)
17
+ - [Fine-Grained Token Creation](#fine-grained-token-creation)
18
+ - [Security Considerations](#security-considerations)
19
+ - [Create Token](#create-token)
20
+ - [Manual Setup](#manual-setup)
21
+ - [Configure MCP Server](#configure-mcp-server)
22
+ - [Store Token in 1Password](#store-token-in-1password)
23
+ - [Update MCP Configuration](#update-mcp-configuration)
24
+ - [Verify Installation](#verify-installation)
25
+ - [Token Management](#token-management)
26
+ - [Token Rotation](#token-rotation)
27
+ - [Token Expiration](#token-expiration)
28
+ - [Emergency Revocation](#emergency-revocation)
29
+ - [Security Model](#security-model)
30
+ - [Read-Only Contents Permission](#read-only-contents-permission)
31
+ - [PR-Based Workflow](#pr-based-workflow)
32
+ - [What You Can Do](#what-you-can-do)
33
+ - [What You Cannot Do](#what-you-cannot-do)
34
+ - [Defense in Depth](#defense-in-depth)
35
+ - [Common Operations](#common-operations)
36
+ - [Repository Information](#repository-information)
37
+ - [Issue Management](#issue-management)
38
+ - [Pull Request Workflow](#pull-request-workflow)
39
+ - [CI/CD Monitoring](#cicd-monitoring)
40
+ - [Troubleshooting](#troubleshooting)
41
+ - [Token Validation Fails](#token-validation-fails)
42
+ - [MCP Server Not Found](#mcp-server-not-found)
43
+ - [Permission Denied](#permission-denied)
44
+ - [Rate Limit Exceeded](#rate-limit-exceeded)
45
+ - [External Resources](#external-resources)
46
+ - [Official Documentation](#official-documentation)
47
+ - [Security Best Practices](#security-best-practices)
48
+ - [Community Support](#community-support)
49
+
50
+ </details>
51
+
52
+ ## Overview
53
+
54
+ GitHub MCP server enables AI assistants to interact with GitHub repositories without requiring direct code push permissions. Using fine-grained Personal Access Tokens (PATs) with read-only repository access and PR creation rights, you maintain security while enabling powerful automation.
55
+
56
+ **Key Features:**
57
+
58
+ - Read repository contents and metadata
59
+ - Create and manage issues
60
+ - Create pull requests (code changes go through review)
61
+ - Monitor CI/CD workflows and security alerts
62
+ - Query repository statistics and contributor activity
63
+
64
+ **Security Benefits:**
65
+
66
+ - No direct code push capability (prevents unauthorized changes)
67
+ - Token compromise cannot modify code without review
68
+ - All changes tracked through pull request audit trail
69
+ - Follows principle of least privilege
70
+
71
+ ## What the Installer Does
72
+
73
+ Running `ai-toolkit install` with GitHub MCP selected automates the following:
74
+
75
+ <details>
76
+ <summary>1. Token Validation</summary>
77
+
78
+ ### 1. Token Validation
79
+
80
+ Validates GitHub token permissions:
81
+
82
+ - Checks token format (fine-grained: `github_pat_*`, classic: `ghp_*`)
83
+ - Verifies token is valid via GitHub API
84
+ - For classic tokens: Checks OAuth scopes
85
+ - For fine-grained tokens: Validates authentication (permissions not exposed via API)
86
+
87
+ **Validation process:**
88
+
89
+ ```typescript
90
+ // src/installers/github-mcp.ts:validateGitHubToken()
91
+ const response = await fetch("https://api.github.com/user", {
92
+ headers: {
93
+ Authorization: `Bearer ${token}`,
94
+ "X-GitHub-Api-Version": "2022-11-28",
95
+ },
96
+ });
97
+
98
+ // HTTP 200: Token valid
99
+ // HTTP 401: Invalid or expired
100
+ // HTTP 403: Insufficient permissions or rate limited
101
+ ```
102
+
103
+ </details>
104
+
105
+ <details>
106
+ <summary>2. MCP Server Configuration</summary>
107
+
108
+ ### 2. MCP Server Configuration
109
+
110
+ Configures Claude Code or other AI tools to use GitHub MCP:
111
+
112
+ **Command executed:**
113
+
114
+ ```bash
115
+ claude mcp add --scope user github-mcp \
116
+ --env GITHUB_PERSONAL_ACCESS_TOKEN=<token> \
117
+ -- npx -y @github/github-mcp-server
118
+ ```
119
+
120
+ **Configuration created** (`~/.claude/config.json`):
121
+
122
+ ```json
123
+ {
124
+ "mcpServers": {
125
+ "github-mcp": {
126
+ "command": "npx",
127
+ "args": ["-y", "@github/github-mcp-server"],
128
+ "env": {
129
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
130
+ }
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ </details>
137
+
138
+ <details>
139
+ <summary>3. Environment Setup</summary>
140
+
141
+ ### 3. Environment Setup
142
+
143
+ For project-level usage, creates environment template:
144
+
145
+ **.env.example:**
146
+
147
+ ```bash
148
+ # GitHub MCP Integration
149
+ # Fine-grained token with read-only contents + PR write permissions
150
+ GITHUB_PERSONAL_ACCESS_TOKEN=op://Private/GitHub/API Token (Read-Only)/token
151
+ ```
152
+
153
+ </details>
154
+
155
+ ## Prerequisites
156
+
157
+ <details>
158
+ <summary>System Requirements</summary>
159
+
160
+ ### System Requirements
161
+
162
+ **Required:**
163
+
164
+ - Node.js 18+ or Bun 1.0+
165
+ - Claude Code, Cursor, or Codex CLI installed
166
+ - Git 2.30+ configured
167
+ - Internet connection for GitHub API access
168
+
169
+ **Optional:**
170
+
171
+ - 1Password CLI for secure token storage
172
+ - 1Password Desktop app (version 8.0+)
173
+
174
+ </details>
175
+
176
+ <details>
177
+ <summary>GitHub Account Setup</summary>
178
+
179
+ ### GitHub Account Setup
180
+
181
+ **Account requirements:**
182
+
183
+ - Active GitHub account (free or paid)
184
+ - Access to repositories you want to manage
185
+ - Two-factor authentication (2FA) enabled (required for fine-grained tokens)
186
+
187
+ **Enable 2FA if not already active:**
188
+
189
+ 1. GitHub → Settings → Password and authentication
190
+ 2. Two-factor authentication → Enable
191
+ 3. Use authenticator app or SMS
192
+
193
+ </details>
194
+
195
+ ## Fine-Grained Token Creation
196
+
197
+ <details>
198
+ <summary>Security Considerations</summary>
199
+
200
+ ### Security Considerations
201
+
202
+ Fine-grained tokens provide granular control over permissions and repository access. This configuration follows the principle of least privilege:
203
+
204
+ **Read-Only Contents:**
205
+
206
+ - Token cannot push code directly to branches
207
+ - Token cannot force push or delete branches
208
+ - Token cannot modify repository settings
209
+ - All code changes must go through pull request review
210
+
211
+ **PR Write Access:**
212
+
213
+ - Token can create pull requests
214
+ - Token can comment on issues and PRs
215
+ - Token cannot approve or merge pull requests (requires separate permission)
216
+ - PR creation provides audit trail for all code changes
217
+
218
+ **Security Benefits:**
219
+
220
+ - Token compromise cannot directly modify codebase
221
+ - All changes visible in PR review process
222
+ - No workflow manipulation (read-only Actions permission)
223
+ - Cannot disable security features (read-only security permissions)
224
+
225
+ </details>
226
+
227
+ <details>
228
+ <summary>Create Token</summary>
229
+
230
+ ### Create Token
231
+
232
+ Navigate to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token
233
+
234
+ **Token configuration:**
235
+
236
+ | Setting | Value |
237
+ | ----------------- | --------------------------------------- |
238
+ | Token name | `AI Assistant (Read-Only)` |
239
+ | Expiration | 90 days (recommended) or custom |
240
+ | Resource owner | Your username or organization |
241
+ | Repository access | All repositories OR select repositories |
242
+
243
+ **Repository permissions:**
244
+
245
+ | Permission | Access Level | Purpose |
246
+ | --------------- | ------------ | --------------------------------- |
247
+ | Actions | Read-only | View workflow runs |
248
+ | Contents | Read-only | Read repository files |
249
+ | Issues | Read & write | Create/update issues |
250
+ | Pull requests | Read & write | Create/update PRs |
251
+ | Security events | Read-only | View security alerts |
252
+ | Workflows | Read-only | View workflow definitions |
253
+ | Metadata | Read-only | Access repository metadata (auto) |
254
+
255
+ **Optional permissions** (add if needed):
256
+
257
+ | Permission | Access Level | Purpose |
258
+ | -------------------- | ------------ | ------------------------------- |
259
+ | Code scanning alerts | Read-only | View code scanning results |
260
+ | Commit statuses | Read-only | Check CI/CD status |
261
+ | Dependabot alerts | Read-only | View dependency vulnerabilities |
262
+ | Deployments | Read-only | Monitor deployment status |
263
+ | Discussions | Read & write | Participate in discussions |
264
+
265
+ **After token creation:**
266
+
267
+ 1. Copy token immediately (shown only once)
268
+ 2. Store in 1Password or secure password manager
269
+ 3. Never commit token to version control
270
+ 4. Set calendar reminder 2 weeks before expiration
271
+
272
+ </details>
273
+
274
+ ## Manual Setup
275
+
276
+ If the installer cannot run or you prefer manual configuration:
277
+
278
+ <details>
279
+ <summary>Configure MCP Server</summary>
280
+
281
+ ### Configure MCP Server
282
+
283
+ **For Claude Code:**
284
+
285
+ Edit `~/.claude/config.json`:
286
+
287
+ ```json
288
+ {
289
+ "mcpServers": {
290
+ "github-mcp": {
291
+ "command": "npx",
292
+ "args": ["-y", "@github/github-mcp-server"],
293
+ "env": {
294
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
295
+ }
296
+ }
297
+ }
298
+ }
299
+ ```
300
+
301
+ **For Cursor:**
302
+
303
+ Add MCP server in Cursor settings:
304
+
305
+ 1. Open Settings → Features → MCP Servers
306
+ 2. Add new server:
307
+ - Name: `github-mcp`
308
+ - Command: `npx`
309
+ - Args: `-y @github/github-mcp-server`
310
+ - Environment: `GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_...`
311
+
312
+ **For Codex CLI:**
313
+
314
+ Edit `~/.codex/config.toml`:
315
+
316
+ ```toml
317
+ [[mcp_servers]]
318
+ name = "github-mcp"
319
+ command = "npx"
320
+ args = ["-y", "@github/github-mcp-server"]
321
+
322
+ [mcp_servers.env]
323
+ GITHUB_PERSONAL_ACCESS_TOKEN = "github_pat_..."
324
+ ```
325
+
326
+ </details>
327
+
328
+ <details>
329
+ <summary>Store Token in 1Password</summary>
330
+
331
+ ### Store Token in 1Password
332
+
333
+ **Create 1Password item:**
334
+
335
+ 1. Open 1Password
336
+ 2. Create new item → API Credential
337
+ 3. Configure fields:
338
+ - Title: `GitHub API Token (Read-Only)`
339
+ - Vault: `Private` (or your preferred vault)
340
+ - Field name: `token`
341
+ - Field value: Your GitHub fine-grained token
342
+
343
+ **Add metadata** (recommended):
344
+
345
+ - Username: Your GitHub username
346
+ - Website: `https://github.com/settings/tokens`
347
+ - Notes: Document token permissions and expiration date
348
+
349
+ **Example 1Password structure:**
350
+
351
+ ```text
352
+ Private/
353
+ └── GitHub/
354
+ ├── API Token (Read-Only)
355
+ │ ├── token: github_pat_...
356
+ │ ├── username: your-github-username
357
+ │ ├── expires: 2024-03-15
358
+ │ └── permissions: contents:read, issues:write, pull_requests:write
359
+ └── SSH Key (for direct pushes)
360
+ ```
361
+
362
+ </details>
363
+
364
+ <details>
365
+ <summary>Update MCP Configuration</summary>
366
+
367
+ ### Update MCP Configuration
368
+
369
+ Replace token with 1Password reference:
370
+
371
+ **Claude Code** (`~/.claude/config.json`):
372
+
373
+ ```json
374
+ {
375
+ "mcpServers": {
376
+ "github-mcp": {
377
+ "command": "npx",
378
+ "args": ["-y", "@github/github-mcp-server"],
379
+ "env": {
380
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "op://Private/GitHub/API Token (Read-Only)/token"
381
+ }
382
+ }
383
+ }
384
+ }
385
+ ```
386
+
387
+ **Benefits of 1Password references:**
388
+
389
+ - Token never stored in plain text
390
+ - Automatic rotation without config changes
391
+ - Biometric authentication required for access
392
+ - Audit trail of token usage
393
+
394
+ </details>
395
+
396
+ <details>
397
+ <summary>Verify Installation</summary>
398
+
399
+ ### Verify Installation
400
+
401
+ **Test MCP server connection:**
402
+
403
+ ```bash
404
+ # For Claude Code
405
+ claude mcp list
406
+ # Should show: github-mcp
407
+
408
+ claude mcp get github-mcp
409
+ # Should show configuration details
410
+ ```
411
+
412
+ **Test GitHub API access:**
413
+
414
+ ```bash
415
+ # Direct token test
416
+ curl -H "Authorization: Bearer github_pat_..." \
417
+ https://api.github.com/user
418
+ ```
419
+
420
+ **Test in AI assistant:**
421
+
422
+ Ask your AI assistant to perform a GitHub operation:
423
+
424
+ ```text
425
+ "List my GitHub repositories"
426
+ "Show recent issues in repository X"
427
+ "Create a test issue in repository Y"
428
+ ```
429
+
430
+ </details>
431
+
432
+ ## Token Management
433
+
434
+ <details>
435
+ <summary>Token Rotation</summary>
436
+
437
+ ### Token Rotation
438
+
439
+ Rotate tokens every 90 days or when:
440
+
441
+ - Team member leaves with token access
442
+ - Token may have been exposed in logs
443
+ - Security policy requires rotation
444
+ - Token permissions need to change
445
+
446
+ **Rotation process:**
447
+
448
+ 1. **Create new token** with same permissions
449
+ 2. **Store in 1Password** (update existing item or create new)
450
+ 3. **Test new token** with curl or AI assistant
451
+ 4. **Update MCP configuration** if using direct token (1Password refs auto-update)
452
+ 5. **Revoke old token** in GitHub settings
453
+ 6. **Verify functionality** after rotation
454
+
455
+ **Automated rotation with 1Password:**
456
+
457
+ When using `op://` references, update the token in 1Password:
458
+
459
+ 1. Edit 1Password item
460
+ 2. Replace token field value
461
+ 3. Save item
462
+ 4. No configuration changes needed (reference remains same)
463
+ 5. Next MCP server start uses new token automatically
464
+
465
+ </details>
466
+
467
+ <details>
468
+ <summary>Token Expiration</summary>
469
+
470
+ ### Token Expiration
471
+
472
+ **Before expiration:**
473
+
474
+ - Set calendar reminder 2 weeks before expiration date
475
+ - Create new token with same permissions
476
+ - Test new token before old token expires
477
+ - Update 1Password item or MCP configuration
478
+ - Document new expiration date
479
+
480
+ **After expiration:**
481
+
482
+ GitHub MCP operations will fail with 401 Unauthorized:
483
+
484
+ ```text
485
+ Error: GitHub API returned 401: Invalid or expired token.
486
+ Please create a new GitHub token.
487
+ ```
488
+
489
+ **Recovery steps:**
490
+
491
+ 1. Create new fine-grained token (see [Fine-Grained Token Creation](#fine-grained-token-creation))
492
+ 2. Update token in 1Password or MCP configuration
493
+ 3. Restart AI assistant to reload configuration
494
+ 4. Verify functionality with test operation
495
+
496
+ </details>
497
+
498
+ <details>
499
+ <summary>Emergency Revocation</summary>
500
+
501
+ ### Emergency Revocation
502
+
503
+ Revoke token immediately if:
504
+
505
+ - Token committed to public repository
506
+ - Token found in logs or error messages
507
+ - Suspicious activity on GitHub account
508
+ - Token compromised in security incident
509
+
510
+ **Revocation steps:**
511
+
512
+ 1. **Revoke in GitHub:**
513
+ - GitHub → Settings → Developer settings
514
+ - Personal access tokens → Fine-grained tokens
515
+ - Find token → Revoke
516
+
517
+ 2. **Create replacement token** (if needed for continued operation)
518
+
519
+ 3. **Update configuration:**
520
+ - Update 1Password item with new token
521
+ - Or update MCP configuration directly
522
+ - Restart AI assistant
523
+
524
+ 4. **Audit recent activity:**
525
+ - Check GitHub audit log for unauthorized actions
526
+ - Review recent PRs and issues created by token
527
+ - Verify no malicious changes were merged
528
+
529
+ **GitHub audit log:**
530
+
531
+ - Organization → Settings → Logs → Audit log
532
+ - Filter by token name or time range
533
+ - Look for unexpected API calls or repository changes
534
+
535
+ </details>
536
+
537
+ ## Security Model
538
+
539
+ <details>
540
+ <summary>Read-Only Contents Permission</summary>
541
+
542
+ ### Read-Only Contents Permission
543
+
544
+ **What read-only Contents permission allows:**
545
+
546
+ - Read file contents from all branches
547
+ - Clone repositories (read-only)
548
+ - View commit history
549
+ - Access repository metadata
550
+ - Read branch and tag information
551
+
552
+ **What read-only Contents permission prevents:**
553
+
554
+ - Push commits to any branch
555
+ - Create or delete branches
556
+ - Create or delete tags
557
+ - Force push or rewrite history
558
+ - Modify repository files directly
559
+
560
+ **Example: Attempting direct push fails:**
561
+
562
+ ```bash
563
+ $ git push origin feature-branch
564
+ remote: Permission denied to github-actions[bot].
565
+ fatal: unable to access 'https://github.com/user/repo.git/':
566
+ The requested URL returned error: 403
567
+ ```
568
+
569
+ This protection ensures all code changes go through pull request review.
570
+
571
+ </details>
572
+
573
+ <details>
574
+ <summary>PR-Based Workflow</summary>
575
+
576
+ ### PR-Based Workflow
577
+
578
+ **How PR creation works with limited permissions:**
579
+
580
+ 1. **AI reads repository** (Contents: read-only)
581
+ 2. **AI generates code changes** locally
582
+ 3. **AI creates pull request** (Pull requests: write)
583
+ 4. **Human reviews PR** in GitHub UI
584
+ 5. **Human approves and merges** (requires separate permission)
585
+
586
+ **Why this is secure:**
587
+
588
+ - Token cannot push code directly (no Contents write permission)
589
+ - Token cannot merge PRs (no Pull requests admin permission)
590
+ - Human review required for all code changes
591
+ - Git history shows PR-based changes, not direct commits
592
+ - Code review process enforced by permissions, not policy
593
+
594
+ **Example workflow:**
595
+
596
+ ```text
597
+ 1. Claude: "I'll create a PR to fix the authentication bug"
598
+ → Creates branch locally (if allowed) OR
599
+ → Creates PR from fork
600
+
601
+ 2. Claude: "PR #123 created for review"
602
+ → You review PR in GitHub
603
+
604
+ 3. You: Approve and merge PR
605
+ → Changes merged to main branch
606
+ → Token could not perform this action
607
+ ```
608
+
609
+ </details>
610
+
611
+ <details>
612
+ <summary>What You Can Do</summary>
613
+
614
+ ### What You Can Do
615
+
616
+ **Repository Operations:**
617
+
618
+ - Read all repository files and history
619
+ - Clone repositories (read-only)
620
+ - Search code across repositories
621
+ - View branch and tag information
622
+ - Check repository statistics
623
+
624
+ **Issue Management:**
625
+
626
+ - Create new issues
627
+ - Add labels, assignees, and milestones
628
+ - Comment on existing issues
629
+ - Close issues (if you created them)
630
+ - Search and filter issues
631
+
632
+ **Pull Requests:**
633
+
634
+ - Create pull requests
635
+ - Comment on PRs
636
+ - Request reviews
637
+ - Add labels and assignees
638
+ - View PR status checks
639
+
640
+ **CI/CD Monitoring:**
641
+
642
+ - View workflow run status
643
+ - Read workflow logs
644
+ - Check deployment status
645
+ - View commit status checks
646
+
647
+ **Security Monitoring:**
648
+
649
+ - Read code scanning alerts
650
+ - View Dependabot alerts
651
+ - Check secret scanning results
652
+ - Read security advisories
653
+
654
+ </details>
655
+
656
+ <details>
657
+ <summary>What You Cannot Do</summary>
658
+
659
+ ### What You Cannot Do
660
+
661
+ **Repository Modification:**
662
+
663
+ - Push commits directly to branches
664
+ - Create or delete branches
665
+ - Force push or rewrite history
666
+ - Modify repository settings
667
+ - Delete repositories
668
+
669
+ **Workflow Control:**
670
+
671
+ - Trigger workflow runs manually
672
+ - Cancel running workflows
673
+ - Approve workflow runs requiring approval
674
+ - Modify workflow files (read-only)
675
+
676
+ **PR Administration:**
677
+
678
+ - Approve pull requests (requires separate permission)
679
+ - Merge pull requests
680
+ - Close PRs you didn't create
681
+ - Override branch protection rules
682
+
683
+ **Security Configuration:**
684
+
685
+ - Modify security settings
686
+ - Disable security features
687
+ - Change alert settings
688
+ - Configure code scanning
689
+
690
+ </details>
691
+
692
+ <details>
693
+ <summary>Defense in Depth</summary>
694
+
695
+ ### Defense in Depth
696
+
697
+ **Multiple security layers:**
698
+
699
+ 1. **Token permissions** - Read-only contents prevents direct pushes
700
+ 2. **Branch protection** - Requires PR reviews even if permissions allowed direct push
701
+ 3. **Required reviews** - Humans must approve code changes
702
+ 4. **Status checks** - CI/CD must pass before merge
703
+ 5. **CODEOWNERS** - Specific reviewers required for sensitive files
704
+
705
+ **What happens if token is compromised:**
706
+
707
+ | Attack Scenario | With Read-Only Token | With Write Token |
708
+ | ------------------- | ---------------------------------- | ------------------------------ |
709
+ | Push malicious code | ❌ Blocked (no push permission) | ✅ Succeeds, bypasses review |
710
+ | Create malicious PR | ⚠️ Creates PR, requires review | ⚠️ Creates PR, requires review |
711
+ | Trigger workflows | ❌ Blocked (read-only Actions) | ✅ Can trigger workflows |
712
+ | Disable security | ❌ Blocked (read-only security) | ✅ Can disable alerts |
713
+ | Modify secrets | ❌ Blocked (no secrets permission) | ⚠️ Depends on permissions |
714
+
715
+ **Additional protections:**
716
+
717
+ - Audit log tracks all API calls
718
+ - Rate limiting prevents abuse
719
+ - IP allowlists restrict token usage
720
+ - Expiration dates limit exposure window
721
+
722
+ </details>
723
+
724
+ ## Common Operations
725
+
726
+ <details>
727
+ <summary>Repository Information</summary>
728
+
729
+ ### Repository Information
730
+
731
+ **List repositories:**
732
+
733
+ ```text
734
+ AI: "List all my GitHub repositories"
735
+ → Shows repositories you own or have access to
736
+ ```
737
+
738
+ **Get repository details:**
739
+
740
+ ```text
741
+ AI: "Show details for repository northbridge-security/ai-toolkit"
742
+ → Returns: name, description, stars, forks, language, last updated
743
+ ```
744
+
745
+ **View recent commits:**
746
+
747
+ ```text
748
+ AI: "Show the 10 most recent commits in ai-toolkit"
749
+ → Lists commits with author, message, SHA, date
750
+ ```
751
+
752
+ **Read file contents:**
753
+
754
+ ```text
755
+ AI: "Show me the contents of package.json in ai-toolkit"
756
+ → Returns file contents from main branch
757
+ ```
758
+
759
+ </details>
760
+
761
+ <details>
762
+ <summary>Issue Management</summary>
763
+
764
+ ### Issue Management
765
+
766
+ **List issues:**
767
+
768
+ ```text
769
+ AI: "Show open issues in ai-toolkit"
770
+ → Lists issues with title, number, labels, assignee
771
+ ```
772
+
773
+ **Create issue:**
774
+
775
+ ```text
776
+ AI: "Create an issue titled 'Bug: Login fails on Safari' with description..."
777
+ → Creates issue, returns issue number and URL
778
+ ```
779
+
780
+ **Add labels and assignees:**
781
+
782
+ ```text
783
+ AI: "Add label 'bug' and assign issue #42 to @username"
784
+ → Updates issue with label and assignee
785
+ ```
786
+
787
+ **Close issue:**
788
+
789
+ ```text
790
+ AI: "Close issue #42 with comment 'Fixed in PR #45'"
791
+ → Closes issue and adds comment
792
+ ```
793
+
794
+ </details>
795
+
796
+ <details>
797
+ <summary>Pull Request Workflow</summary>
798
+
799
+ ### Pull Request Workflow
800
+
801
+ **Create pull request:**
802
+
803
+ ```text
804
+ AI: "Create a PR to add GitHub Actions workflow"
805
+ → Creates PR with generated changes
806
+ → Returns PR number and URL for review
807
+ ```
808
+
809
+ **List pull requests:**
810
+
811
+ ```text
812
+ AI: "Show all open PRs in ai-toolkit"
813
+ → Lists PRs with title, number, author, status
814
+ ```
815
+
816
+ **Check PR status:**
817
+
818
+ ```text
819
+ AI: "What's the status of PR #123?"
820
+ → Shows: review status, CI checks, merge conflicts
821
+ ```
822
+
823
+ **Add PR comment:**
824
+
825
+ ```text
826
+ AI: "Comment on PR #123: 'Please add unit tests for the new function'"
827
+ → Adds comment to PR
828
+ ```
829
+
830
+ </details>
831
+
832
+ <details>
833
+ <summary>CI/CD Monitoring</summary>
834
+
835
+ ### CI/CD Monitoring
836
+
837
+ **View workflow runs:**
838
+
839
+ ```text
840
+ AI: "Show recent workflow runs for ai-toolkit"
841
+ → Lists workflow runs with status, duration, conclusion
842
+ ```
843
+
844
+ **Check workflow status:**
845
+
846
+ ```text
847
+ AI: "Did the latest CI workflow pass?"
848
+ → Shows: success/failure, failed jobs, error messages
849
+ ```
850
+
851
+ **View deployment status:**
852
+
853
+ ```text
854
+ AI: "What's the current deployment status?"
855
+ → Shows active deployments and their state
856
+ ```
857
+
858
+ </details>
859
+
860
+ ## Troubleshooting
861
+
862
+ <details>
863
+ <summary>Token Validation Fails</summary>
864
+
865
+ ### Token Validation Fails
866
+
867
+ **Error:** `Invalid or expired token. Please create a new GitHub token.`
868
+
869
+ **Possible causes:**
870
+
871
+ 1. Token expired (check expiration date in GitHub settings)
872
+ 2. Token revoked (check GitHub token list)
873
+ 3. Token copied incorrectly (missing characters or extra whitespace)
874
+ 4. 2FA required but not enabled on account
875
+
876
+ **Solutions:**
877
+
878
+ ```bash
879
+ # Verify token format
880
+ echo $GITHUB_PERSONAL_ACCESS_TOKEN | wc -c
881
+ # Fine-grained: ~255 characters (github_pat_...)
882
+ # Classic: ~40 characters (ghp_...)
883
+
884
+ # Test token directly
885
+ curl -H "Authorization: Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}" \
886
+ https://api.github.com/user
887
+
888
+ # Expected: JSON with user information
889
+ # If 401: Token invalid or expired
890
+ # If 403: Rate limited or insufficient permissions
891
+ ```
892
+
893
+ **Create new token** if validation continues to fail (see [Fine-Grained Token Creation](#fine-grained-token-creation))
894
+
895
+ </details>
896
+
897
+ <details>
898
+ <summary>MCP Server Not Found</summary>
899
+
900
+ ### MCP Server Not Found
901
+
902
+ **Error:** `MCP server "github-mcp" not found`
903
+
904
+ **Check MCP configuration:**
905
+
906
+ ```bash
907
+ # For Claude Code
908
+ claude mcp list
909
+ # Should show github-mcp in output
910
+
911
+ # View configuration
912
+ claude mcp get github-mcp
913
+ ```
914
+
915
+ **If not listed:**
916
+
917
+ ```bash
918
+ # Add GitHub MCP server
919
+ claude mcp add --scope user github-mcp \
920
+ --env GITHUB_PERSONAL_ACCESS_TOKEN="your_token" \
921
+ -- npx -y @github/github-mcp-server
922
+
923
+ # Verify installation
924
+ claude mcp list
925
+ ```
926
+
927
+ **Check configuration file:**
928
+
929
+ ```bash
930
+ # macOS/Linux
931
+ cat ~/.claude/config.json | jq '.mcpServers["github-mcp"]'
932
+
933
+ # Should show command, args, and env configuration
934
+ ```
935
+
936
+ **If configuration exists but server not loading:**
937
+
938
+ 1. Restart AI assistant
939
+ 2. Check Claude Code logs for errors
940
+ 3. Verify Node.js/npx is installed: `npx --version`
941
+ 4. Test manual server start: `npx @github/github-mcp-server`
942
+
943
+ </details>
944
+
945
+ <details>
946
+ <summary>Permission Denied</summary>
947
+
948
+ ### Permission Denied
949
+
950
+ **Error:** `Permission denied` or `403 Forbidden` when performing GitHub operations
951
+
952
+ **Check token permissions:**
953
+
954
+ 1. GitHub → Settings → Developer settings → Personal access tokens
955
+ 2. Click on your token
956
+ 3. Review "Repository permissions" section
957
+ 4. Verify required permissions are granted:
958
+ - Contents: Read-only (minimum)
959
+ - Issues: Read & write (for issue operations)
960
+ - Pull requests: Read & write (for PR operations)
961
+
962
+ **If permissions are correct but errors continue:**
963
+
964
+ ```bash
965
+ # Test specific permission
966
+ curl -H "Authorization: Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}" \
967
+ https://api.github.com/repos/OWNER/REPO/contents/README.md
968
+
969
+ # Expected: File contents
970
+ # If 404: Repository not found or token lacks access
971
+ # If 403: Token doesn't have Contents permission
972
+ ```
973
+
974
+ **Solutions:**
975
+
976
+ - Update token permissions in GitHub settings
977
+ - Create new token with correct permissions
978
+ - Verify repository access (token may not have access to private repos)
979
+ - Check organization settings (org may restrict fine-grained tokens)
980
+
981
+ </details>
982
+
983
+ <details>
984
+ <summary>Rate Limit Exceeded</summary>
985
+
986
+ ### Rate Limit Exceeded
987
+
988
+ **Error:** `API rate limit exceeded`
989
+
990
+ **GitHub rate limits:**
991
+
992
+ - Authenticated requests: 5,000 per hour
993
+ - Search API: 30 requests per minute
994
+ - GraphQL API: 5,000 points per hour
995
+
996
+ **Check current rate limit:**
997
+
998
+ ```bash
999
+ curl -H "Authorization: Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}" \
1000
+ https://api.github.com/rate_limit
1001
+ ```
1002
+
1003
+ **Response:**
1004
+
1005
+ ```json
1006
+ {
1007
+ "resources": {
1008
+ "core": {
1009
+ "limit": 5000,
1010
+ "remaining": 4999,
1011
+ "reset": 1234567890
1012
+ }
1013
+ }
1014
+ }
1015
+ ```
1016
+
1017
+ **If rate limited:**
1018
+
1019
+ 1. **Wait for reset** - `reset` field shows Unix timestamp for limit reset
1020
+ 2. **Reduce request frequency** - Batch operations when possible
1021
+ 3. **Use conditional requests** - Include `If-None-Match` headers for caching
1022
+ 4. **Optimize queries** - Request only needed data
1023
+
1024
+ **For persistent rate limit issues:**
1025
+
1026
+ - Consider GitHub Enterprise (higher limits)
1027
+ - Use multiple tokens with different scopes
1028
+ - Implement caching for frequently accessed data
1029
+ - Switch to GraphQL API (more efficient than REST)
1030
+
1031
+ </details>
1032
+
1033
+ ## External Resources
1034
+
1035
+ <details>
1036
+ <summary>Official Documentation</summary>
1037
+
1038
+ ### Official Documentation
1039
+
1040
+ - **GitHub MCP Server**: https://github.com/github/github-mcp-server
1041
+ - **Fine-Grained PATs**: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token
1042
+ - **GitHub API Reference**: https://docs.github.com/en/rest
1043
+ - **Token Permissions**: https://docs.github.com/en/rest/overview/permissions-required-for-fine-grained-personal-access-tokens
1044
+
1045
+ </details>
1046
+
1047
+ <details>
1048
+ <summary>Security Best Practices</summary>
1049
+
1050
+ ### Security Best Practices
1051
+
1052
+ - **Token Security**: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/token-expiration-and-revocation
1053
+ - **GitHub Security**: https://docs.github.com/en/code-security
1054
+ - **Audit Logs**: https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/reviewing-the-audit-log-for-your-organization
1055
+ - **Branch Protection**: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches
1056
+
1057
+ </details>
1058
+
1059
+ <details>
1060
+ <summary>Community Support</summary>
1061
+
1062
+ ### Community Support
1063
+
1064
+ - **GitHub MCP Issues**: https://github.com/github/github-mcp-server/issues
1065
+ - **MCP Specification**: https://modelcontextprotocol.io/
1066
+ - **AI Toolkit Issues**: https://github.com/northbridge-security/ai-toolkit/issues
1067
+ - **GitHub Community**: https://github.com/community
1068
+
1069
+ </details>
1070
+
1071
+ ---
1072
+
1073
+ For 1Password integration patterns, see [1Password Integration Guide](./1password.md)
1074
+
1075
+ For MCP configuration details, see [MCP Integration Guide](./mcp-integration.md)