@noushad999/github-mcp-server 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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +659 -0
  3. package/dist/github-client.d.ts +5 -0
  4. package/dist/github-client.d.ts.map +1 -0
  5. package/dist/github-client.js +53 -0
  6. package/dist/github-client.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 +73 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/middleware/tokenGuard.d.ts +2 -0
  12. package/dist/middleware/tokenGuard.d.ts.map +1 -0
  13. package/dist/middleware/tokenGuard.js +75 -0
  14. package/dist/middleware/tokenGuard.js.map +1 -0
  15. package/dist/tools/add_comment.d.ts +21 -0
  16. package/dist/tools/add_comment.d.ts.map +1 -0
  17. package/dist/tools/add_comment.js +24 -0
  18. package/dist/tools/add_comment.js.map +1 -0
  19. package/dist/tools/assign_issue.d.ts +24 -0
  20. package/dist/tools/assign_issue.d.ts.map +1 -0
  21. package/dist/tools/assign_issue.js +32 -0
  22. package/dist/tools/assign_issue.js.map +1 -0
  23. package/dist/tools/create_branch.d.ts +21 -0
  24. package/dist/tools/create_branch.d.ts.map +1 -0
  25. package/dist/tools/create_branch.js +28 -0
  26. package/dist/tools/create_branch.js.map +1 -0
  27. package/dist/tools/create_issue.d.ts +24 -0
  28. package/dist/tools/create_issue.d.ts.map +1 -0
  29. package/dist/tools/create_issue.js +29 -0
  30. package/dist/tools/create_issue.js.map +1 -0
  31. package/dist/tools/create_pr.d.ts +27 -0
  32. package/dist/tools/create_pr.d.ts.map +1 -0
  33. package/dist/tools/create_pr.js +31 -0
  34. package/dist/tools/create_pr.js.map +1 -0
  35. package/dist/tools/create_release.d.ts +33 -0
  36. package/dist/tools/create_release.d.ts.map +1 -0
  37. package/dist/tools/create_release.js +41 -0
  38. package/dist/tools/create_release.js.map +1 -0
  39. package/dist/tools/delete_branch.d.ts +21 -0
  40. package/dist/tools/delete_branch.d.ts.map +1 -0
  41. package/dist/tools/delete_branch.js +17 -0
  42. package/dist/tools/delete_branch.js.map +1 -0
  43. package/dist/tools/get_file.d.ts +21 -0
  44. package/dist/tools/get_file.d.ts.map +1 -0
  45. package/dist/tools/get_file.js +33 -0
  46. package/dist/tools/get_file.js.map +1 -0
  47. package/dist/tools/get_pr_diff.d.ts +18 -0
  48. package/dist/tools/get_pr_diff.d.ts.map +1 -0
  49. package/dist/tools/get_pr_diff.js +32 -0
  50. package/dist/tools/get_pr_diff.js.map +1 -0
  51. package/dist/tools/get_release.d.ts +18 -0
  52. package/dist/tools/get_release.d.ts.map +1 -0
  53. package/dist/tools/get_release.js +42 -0
  54. package/dist/tools/get_release.js.map +1 -0
  55. package/dist/tools/get_repo.d.ts +15 -0
  56. package/dist/tools/get_repo.d.ts.map +1 -0
  57. package/dist/tools/get_repo.js +35 -0
  58. package/dist/tools/get_repo.js.map +1 -0
  59. package/dist/tools/list_commits.d.ts +21 -0
  60. package/dist/tools/list_commits.d.ts.map +1 -0
  61. package/dist/tools/list_commits.js +31 -0
  62. package/dist/tools/list_commits.js.map +1 -0
  63. package/dist/tools/list_issues.d.ts +18 -0
  64. package/dist/tools/list_issues.d.ts.map +1 -0
  65. package/dist/tools/list_issues.js +34 -0
  66. package/dist/tools/list_issues.js.map +1 -0
  67. package/dist/tools/list_prs.d.ts +18 -0
  68. package/dist/tools/list_prs.d.ts.map +1 -0
  69. package/dist/tools/list_prs.js +31 -0
  70. package/dist/tools/list_prs.js.map +1 -0
  71. package/dist/tools/list_repos.d.ts +15 -0
  72. package/dist/tools/list_repos.d.ts.map +1 -0
  73. package/dist/tools/list_repos.js +33 -0
  74. package/dist/tools/list_repos.js.map +1 -0
  75. package/dist/tools/list_workflows.d.ts +15 -0
  76. package/dist/tools/list_workflows.d.ts.map +1 -0
  77. package/dist/tools/list_workflows.js +30 -0
  78. package/dist/tools/list_workflows.js.map +1 -0
  79. package/dist/tools/merge_pr.d.ts +24 -0
  80. package/dist/tools/merge_pr.d.ts.map +1 -0
  81. package/dist/tools/merge_pr.js +30 -0
  82. package/dist/tools/merge_pr.js.map +1 -0
  83. package/dist/tools/search_code.d.ts +15 -0
  84. package/dist/tools/search_code.d.ts.map +1 -0
  85. package/dist/tools/search_code.js +30 -0
  86. package/dist/tools/search_code.js.map +1 -0
  87. package/dist/tools/trigger_workflow.d.ts +28 -0
  88. package/dist/tools/trigger_workflow.d.ts.map +1 -0
  89. package/dist/tools/trigger_workflow.js +24 -0
  90. package/dist/tools/trigger_workflow.js.map +1 -0
  91. package/dist/utils/cache.d.ts +5 -0
  92. package/dist/utils/cache.d.ts.map +1 -0
  93. package/dist/utils/cache.js +36 -0
  94. package/dist/utils/cache.js.map +1 -0
  95. package/package.json +38 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 github-mcp-server contributors
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,659 @@
1
+ <div align="center">
2
+
3
+ # GitHub MCP Server
4
+
5
+ **Control GitHub entirely through Claude — in plain English.**
6
+
7
+ *Create PRs, manage issues, trigger workflows, cut releases, review diffs — without touching a browser.*
8
+
9
+ <img src="demo.svg" alt="GitHub MCP Server demo" width="700"/>
10
+
11
+ **26x smaller responses than the official GitHub MCP — your Claude context window goes further.**
12
+
13
+ [![npm](https://img.shields.io/badge/MCP-Compatible-orange?style=flat-square&logo=anthropic)](https://modelcontextprotocol.io)
14
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.8-3178c6?style=flat-square&logo=typescript)](https://www.typescriptlang.org)
15
+ [![License: MIT](https://img.shields.io/badge/License-MIT-22c55e?style=flat-square)](LICENSE)
16
+ [![Tests](https://img.shields.io/badge/Tests-49%2F49%20passing-22c55e?style=flat-square)](#testing)
17
+ [![Tools](https://img.shields.io/badge/Tools-19-6366f1?style=flat-square)](#available-tools)
18
+
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## What is this?
24
+
25
+ This is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that connects Claude directly to the GitHub API. Once installed, you can manage your entire GitHub workflow through natural conversation — no GUI, no copy-pasting URLs, no context switching.
26
+
27
+ **You type this in Claude:**
28
+ ```
29
+ Merge PR #47 with squash, delete the branch, then create a release v2.1.0 with those changes
30
+ ```
31
+
32
+ **Claude does all of it.** Three API calls. Done.
33
+
34
+ ---
35
+
36
+ ## Why this instead of the official GitHub MCP?
37
+
38
+ | | This Server | Official GitHub MCP |
39
+ |---|---|---|
40
+ | **Setup** | `npm install` + token | Docker required |
41
+ | **Response size** | ~320 avg tokens | 2000+ tokens (raw API) |
42
+ | **Token efficiency** | Null stripping, compactify | Raw JSON passthrough |
43
+ | **Caching** | 120s in-memory cache | No cache |
44
+ | **Tools** | 19 tools | ~30 tools |
45
+ | **Default branch** | Auto-detected | Hard-coded `main` |
46
+ | **Error messages** | Status codes included | Generic messages |
47
+ | **License** | MIT — use anywhere | MIT |
48
+
49
+ **Bottom line:** This server was built to be lean. Every response is stripped of nulls, truncated intelligently, and cached where it makes sense. Your Claude context window is treated as a precious resource.
50
+
51
+ ---
52
+
53
+ ## 60-Second Setup
54
+
55
+ ```bash
56
+ git clone https://github.com/noushad999/github-mcp-server.git
57
+ cd github-mcp-server
58
+ npm install && npm run build
59
+ echo "GITHUB_TOKEN=ghp_your_token" > .env
60
+ ```
61
+
62
+ **Claude Desktop** — edit `%APPDATA%\Claude\claude_desktop_config.json` (Windows) or `~/Library/Application Support/Claude/claude_desktop_config.json` (Mac):
63
+
64
+ ```json
65
+ {
66
+ "mcpServers": {
67
+ "github": {
68
+ "command": "node",
69
+ "args": ["C:/absolute/path/to/github-mcp-server/dist/index.js"],
70
+ "env": {
71
+ "GITHUB_TOKEN": "ghp_your_token_here"
72
+ }
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ **Claude Code (CLI):**
79
+ ```bash
80
+ claude mcp add github -- node /absolute/path/to/github-mcp-server/dist/index.js
81
+ ```
82
+
83
+ Restart Claude. You're done.
84
+
85
+ ---
86
+
87
+ ## Token Permissions Required
88
+
89
+ Go to [github.com/settings/tokens?type=beta](https://github.com/settings/tokens?type=beta) → Fine-grained token:
90
+
91
+ | Permission | Level | Used by |
92
+ |---|---|---|
93
+ | Contents | Read & Write | `get_file`, `create_branch`, `delete_branch` |
94
+ | Issues | Read & Write | `list_issues`, `create_issue`, `assign_issue`, `add_comment` |
95
+ | Pull requests | Read & Write | `list_prs`, `create_pr`, `merge_pr`, `get_pr_diff` |
96
+ | Actions | Read & Write | `list_workflows`, `trigger_workflow` |
97
+ | Metadata | Read | `list_repos`, `get_repo` |
98
+
99
+ ---
100
+
101
+ ## Available Tools
102
+
103
+ ### Repositories
104
+
105
+ #### `list_repos`
106
+ List repositories for any user or organization.
107
+ ```
108
+ "Show me all of vercel's public repos sorted by recent activity"
109
+ ```
110
+
111
+ | Param | Type | Required | Default |
112
+ |---|---|---|---|
113
+ | `owner` | string | yes | — |
114
+ | `type` | `owner` \| `member` | no | `owner` |
115
+
116
+ ---
117
+
118
+ #### `get_repo`
119
+ Get detailed stats for a specific repository.
120
+ ```
121
+ "Tell me about facebook/react — stars, forks, language, open issues"
122
+ ```
123
+
124
+ | Param | Type | Required |
125
+ |---|---|---|
126
+ | `owner` | string | yes |
127
+ | `repo` | string | yes |
128
+
129
+ ---
130
+
131
+ ### Issues
132
+
133
+ #### `list_issues`
134
+ List issues with labels and assignees.
135
+ ```
136
+ "Show all open bugs in my repo"
137
+ ```
138
+
139
+ | Param | Type | Required | Default |
140
+ |---|---|---|---|
141
+ | `owner` | string | yes | — |
142
+ | `repo` | string | yes | — |
143
+ | `state` | `open` \| `closed` \| `all` | no | `open` |
144
+
145
+ ---
146
+
147
+ #### `create_issue`
148
+ Create a new issue with labels.
149
+ ```
150
+ "Create an issue titled 'Login crashes on Safari' with labels bug and priority"
151
+ ```
152
+
153
+ | Param | Type | Required |
154
+ |---|---|---|
155
+ | `owner` | string | yes |
156
+ | `repo` | string | yes |
157
+ | `title` | string | yes |
158
+ | `body` | string | no |
159
+ | `labels` | string[] | no |
160
+
161
+ ---
162
+
163
+ #### `assign_issue`
164
+ Add or remove assignees on an issue or PR.
165
+ ```
166
+ "Assign issue #42 to alice and bob"
167
+ ```
168
+
169
+ | Param | Type | Required | Default |
170
+ |---|---|---|---|
171
+ | `owner` | string | yes | — |
172
+ | `repo` | string | yes | — |
173
+ | `issue_number` | number | yes | — |
174
+ | `assignees` | string[] | yes | — |
175
+ | `action` | `add` \| `remove` | no | `add` |
176
+
177
+ ---
178
+
179
+ ### Pull Requests
180
+
181
+ #### `list_prs`
182
+ List pull requests by state.
183
+ ```
184
+ "What PRs are currently open in vercel/next.js?"
185
+ ```
186
+
187
+ | Param | Type | Required | Default |
188
+ |---|---|---|---|
189
+ | `owner` | string | yes | — |
190
+ | `repo` | string | yes | — |
191
+ | `state` | `open` \| `closed` \| `all` | no | `open` |
192
+
193
+ ---
194
+
195
+ #### `create_pr`
196
+ Create a pull request. Automatically detects the repo's default branch if `base` is omitted.
197
+ ```
198
+ "Create a PR from feat/dark-mode to main titled 'Add dark mode support'"
199
+ ```
200
+
201
+ | Param | Type | Required | Default |
202
+ |---|---|---|---|
203
+ | `owner` | string | yes | — |
204
+ | `repo` | string | yes | — |
205
+ | `title` | string | yes | — |
206
+ | `body` | string | no | — |
207
+ | `head` | string | yes | — |
208
+ | `base` | string | no | repo default |
209
+
210
+ ---
211
+
212
+ #### `get_pr_diff`
213
+ Get the unified diff of a pull request — up to 200 lines.
214
+ ```
215
+ "Show me the diff for PR #88"
216
+ ```
217
+
218
+ | Param | Type | Required |
219
+ |---|---|---|
220
+ | `owner` | string | yes |
221
+ | `repo` | string | yes |
222
+ | `pull_number` | number | yes |
223
+
224
+ ---
225
+
226
+ #### `merge_pr`
227
+ Merge with your chosen strategy.
228
+ ```
229
+ "Squash-merge PR #47 with title 'feat: dark mode'"
230
+ ```
231
+
232
+ | Param | Type | Required | Default |
233
+ |---|---|---|---|
234
+ | `owner` | string | yes | — |
235
+ | `repo` | string | yes | — |
236
+ | `pull_number` | number | yes | — |
237
+ | `method` | `merge` \| `squash` \| `rebase` | no | `merge` |
238
+ | `commit_title` | string | no | — |
239
+
240
+ ---
241
+
242
+ ### Branches
243
+
244
+ #### `create_branch`
245
+ Create a branch from any base. Auto-detects default branch.
246
+ ```
247
+ "Create branch fix/header-overflow from main"
248
+ ```
249
+
250
+ | Param | Type | Required | Default |
251
+ |---|---|---|---|
252
+ | `owner` | string | yes | — |
253
+ | `repo` | string | yes | — |
254
+ | `branch` | string | yes | — |
255
+ | `base` | string | no | repo default |
256
+
257
+ ---
258
+
259
+ #### `delete_branch`
260
+ Delete a branch — typically after merging.
261
+ ```
262
+ "Delete the feat/dark-mode branch, it's been merged"
263
+ ```
264
+
265
+ | Param | Type | Required |
266
+ |---|---|---|
267
+ | `owner` | string | yes |
268
+ | `repo` | string | yes |
269
+ | `branch` | string | yes |
270
+
271
+ ---
272
+
273
+ ### Commits & Files
274
+
275
+ #### `list_commits`
276
+ View recent commit history with authors and timestamps.
277
+ ```
278
+ "Show the last 5 commits on the main branch"
279
+ ```
280
+
281
+ | Param | Type | Required | Default |
282
+ |---|---|---|---|
283
+ | `owner` | string | yes | — |
284
+ | `repo` | string | yes | — |
285
+ | `branch` | string | no | `main` |
286
+ | `per_page` | 1–10 | no | `10` |
287
+
288
+ ---
289
+
290
+ #### `get_file`
291
+ Read file content from any branch. Files over 100 lines are truncated.
292
+ ```
293
+ "Show me the contents of src/auth.ts on the dev branch"
294
+ ```
295
+
296
+ | Param | Type | Required | Default |
297
+ |---|---|---|---|
298
+ | `owner` | string | yes | — |
299
+ | `repo` | string | yes | — |
300
+ | `path` | string | yes | — |
301
+ | `branch` | string | no | `main` |
302
+
303
+ ---
304
+
305
+ #### `search_code`
306
+ Search code across GitHub.
307
+ ```
308
+ "Find all TypeScript files using useAuth hook"
309
+ ```
310
+
311
+ | Param | Type | Required | Default |
312
+ |---|---|---|---|
313
+ | `query` | string | yes | — |
314
+ | `per_page` | 1–10 | no | `10` |
315
+
316
+ > GitHub's code search API requires authentication and has a rate limit of ~10 requests/minute. Results are cached for 120s.
317
+
318
+ ---
319
+
320
+ ### Comments
321
+
322
+ #### `add_comment`
323
+ Comment on any issue or pull request.
324
+ ```
325
+ "Add a comment to PR #55 saying the deployment is ready for testing"
326
+ ```
327
+
328
+ | Param | Type | Required |
329
+ |---|---|---|
330
+ | `owner` | string | yes |
331
+ | `repo` | string | yes |
332
+ | `issue_number` | number | yes |
333
+ | `body` | string | yes |
334
+
335
+ ---
336
+
337
+ ### Releases
338
+
339
+ #### `get_release`
340
+ Get the latest release or look up a specific tag.
341
+ ```
342
+ "What's the latest release of vercel/next.js?"
343
+ ```
344
+
345
+ | Param | Type | Required | Default |
346
+ |---|---|---|---|
347
+ | `owner` | string | yes | — |
348
+ | `repo` | string | yes | — |
349
+ | `tag` | string | no | latest |
350
+
351
+ ---
352
+
353
+ #### `create_release`
354
+ Publish a new release with release notes.
355
+ ```
356
+ "Create release v2.1.0 on the main branch with the changelog I'll paste"
357
+ ```
358
+
359
+ | Param | Type | Required | Default |
360
+ |---|---|---|---|
361
+ | `owner` | string | yes | — |
362
+ | `repo` | string | yes | — |
363
+ | `tag_name` | string | yes | — |
364
+ | `name` | string | no | tag name |
365
+ | `body` | string | no | — |
366
+ | `draft` | boolean | no | `false` |
367
+ | `prerelease` | boolean | no | `false` |
368
+ | `target_commitish` | string | no | repo default |
369
+
370
+ ---
371
+
372
+ ### GitHub Actions
373
+
374
+ #### `list_workflows`
375
+ List all workflows in a repository.
376
+ ```
377
+ "What GitHub Actions workflows does this repo have?"
378
+ ```
379
+
380
+ | Param | Type | Required |
381
+ |---|---|---|
382
+ | `owner` | string | yes |
383
+ | `repo` | string | yes |
384
+
385
+ ---
386
+
387
+ #### `trigger_workflow`
388
+ Trigger a workflow dispatch event with optional inputs.
389
+ ```
390
+ "Trigger the deploy.yml workflow on the staging branch"
391
+ ```
392
+
393
+ | Param | Type | Required | Default |
394
+ |---|---|---|---|
395
+ | `owner` | string | yes | — |
396
+ | `repo` | string | yes | — |
397
+ | `workflow_id` | string \| number | yes | — |
398
+ | `ref` | string | no | repo default |
399
+ | `inputs` | object | no | `{}` |
400
+
401
+ ---
402
+
403
+ ## How It Works
404
+
405
+ ```
406
+ You (natural language)
407
+
408
+
409
+ Claude AI
410
+ │ MCP Protocol (stdio)
411
+
412
+ ┌──────────────────────────────────┐
413
+ │ github-mcp-server │
414
+ │ │
415
+ │ ┌─────────────────────────┐ │
416
+ │ │ 19 Tool Handlers │ │
417
+ │ └────────┬────────────────┘ │
418
+ │ │ │
419
+ │ ┌────────▼─────┐ ┌──────────┐ │
420
+ │ │ Token Guard │ │ Cache │ │
421
+ │ │ 4000 char │ │ 120s │ │
422
+ │ │ null strip │ │ 200 max │ │
423
+ │ └────────┬─────┘ └────┬─────┘ │
424
+ │ └──────┬───────┘ │
425
+ │ ▼ │
426
+ │ ┌──────────────────┐ │
427
+ │ │ GitHub Client │ │
428
+ │ │ Axios + Auth │ │
429
+ │ │ Status codes │ │
430
+ │ └──────────────────┘ │
431
+ └──────────────┬───────────────────┘
432
+ │ HTTPS
433
+
434
+ api.github.com
435
+ ```
436
+
437
+ ### Token Efficiency — Why It Matters
438
+
439
+ Every response the MCP server sends consumes your Claude context window. Bloated responses mean Claude forgets earlier parts of your conversation faster. This server aggressively minimizes response size:
440
+
441
+ **Raw GitHub API response** for a single repository:
442
+ ```json
443
+ {
444
+ "id": 1296269,
445
+ "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
446
+ "name": "Hello-World",
447
+ "full_name": "octocat/Hello-World",
448
+ "private": false,
449
+ "owner": {
450
+ "login": "octocat",
451
+ "id": 1,
452
+ "node_id": "MDQ6VXNlcjE=",
453
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
454
+ "gravatar_id": "",
455
+ "url": "https://api.github.com/users/octocat",
456
+ "html_url": "https://github.com/octocat",
457
+ "followers_url": "...",
458
+ ... 20 more owner fields
459
+ },
460
+ "html_url": "https://github.com/octocat/Hello-World",
461
+ "description": "This your first repo!",
462
+ ... 80+ more fields, mostly null
463
+ }
464
+ ```
465
+ **~2,400 tokens**
466
+
467
+ **This server's response:**
468
+ ```json
469
+ {
470
+ "name": "Hello-World",
471
+ "full_name": "octocat/Hello-World",
472
+ "description": "This your first repo!",
473
+ "stars": 2045,
474
+ "forks": 1731,
475
+ "language": "JavaScript",
476
+ "open_issues": 12,
477
+ "updated_at": "2024-01-15T10:30:00Z",
478
+ "html_url": "https://github.com/octocat/Hello-World"
479
+ }
480
+ ```
481
+ **~90 tokens — 26x smaller**
482
+
483
+ ---
484
+
485
+ ## Real-World Example Conversations
486
+
487
+ **Full PR workflow:**
488
+ ```
489
+ You: Show me open PRs in my-org/my-repo
490
+
491
+ Claude: Found 3 open PRs:
492
+ #88 — "Add OAuth2 support" by sarah_dev
493
+ #91 — "Fix memory leak in worker" by john_k
494
+ #94 — "Upgrade to Node 22" by bot
495
+
496
+ You: Show me the diff for #91
497
+
498
+ Claude: [shows unified diff of the memory leak fix]
499
+
500
+ You: Looks good. Merge it with squash, then delete the branch
501
+
502
+ Claude: Done — squash merged PR #91 (sha: a3f9c21), deleted branch fix/memory-leak
503
+
504
+ You: Now create a release v3.2.1 from main with changelog: "Fixed memory leak in background workers"
505
+
506
+ Claude: Release v3.2.1 published — https://github.com/my-org/my-repo/releases/tag/v3.2.1
507
+ ```
508
+ Four separate GitHub operations. One conversation.
509
+
510
+ ---
511
+
512
+ **Automated triage:**
513
+ ```
514
+ You: List open issues in my-org/api-server, assign the ones labeled "bug" to me
515
+
516
+ Claude: Found 4 open issues. 2 have the "bug" label (#34, #41).
517
+ Assigned #34 and #41 to you.
518
+ ```
519
+
520
+ ---
521
+
522
+ ## Testing
523
+
524
+ ```bash
525
+ npm run build
526
+ npx tsx tests/simulate-10-users.ts
527
+ ```
528
+
529
+ Expected output:
530
+ ```
531
+ ╔══════════════════════════════════════════════════════════╗
532
+ ║ GitHub MCP Server - 10 User Deployment Test ║
533
+ ║ 19 Tools · Full Coverage Simulation ║
534
+ ╚══════════════════════════════════════════════════════════╝
535
+ ...
536
+ ║ Total Tests: 49 ║
537
+ ║ Passed: 49 ║
538
+ ║ Failed: 0 ║
539
+ ║ Pass Rate: 100.0 % ║
540
+ ║ Null Fields Found: 0 ║
541
+ ║ Avg Response: 319 tokens ║
542
+ ╚══════════════════════════════════════════╝
543
+ 🎉 ALL TESTS PASSED! Ready for production.
544
+ ```
545
+
546
+ You can also inspect live with the MCP Inspector:
547
+ ```bash
548
+ npx @modelcontextprotocol/inspector node dist/index.js
549
+ ```
550
+
551
+ ---
552
+
553
+ ## Project Structure
554
+
555
+ ```
556
+ github-mcp-server/
557
+ ├── src/
558
+ │ ├── index.ts # MCP server entry, tool registration
559
+ │ ├── github-client.ts # Axios client + getDefaultBranch helper
560
+ │ ├── middleware/
561
+ │ │ └── tokenGuard.ts # Response trimmer: null strip, compactify, 4000 char limit
562
+ │ ├── utils/
563
+ │ │ └── cache.ts # 120s TTL in-memory cache, max 200 entries
564
+ │ └── tools/ # 19 tool handlers (one file each)
565
+ │ ├── list_repos.ts
566
+ │ ├── get_repo.ts
567
+ │ ├── list_issues.ts
568
+ │ ├── create_issue.ts
569
+ │ ├── assign_issue.ts
570
+ │ ├── list_prs.ts
571
+ │ ├── create_pr.ts
572
+ │ ├── get_pr_diff.ts
573
+ │ ├── merge_pr.ts
574
+ │ ├── create_branch.ts
575
+ │ ├── delete_branch.ts
576
+ │ ├── list_commits.ts
577
+ │ ├── get_file.ts
578
+ │ ├── search_code.ts
579
+ │ ├── add_comment.ts
580
+ │ ├── get_release.ts
581
+ │ ├── create_release.ts
582
+ │ ├── list_workflows.ts
583
+ │ └── trigger_workflow.ts
584
+ ├── tests/
585
+ │ └── simulate-10-users.ts # Full simulation test, 49 assertions
586
+ ├── dist/ # Compiled JS (after npm run build)
587
+ ├── package.json
588
+ ├── tsconfig.json
589
+ └── .env.example
590
+ ```
591
+
592
+ ---
593
+
594
+ ## Troubleshooting
595
+
596
+ **`GITHUB_TOKEN not set`**
597
+ ```bash
598
+ cat .env # make sure GITHUB_TOKEN=ghp_... is there
599
+ ```
600
+
601
+ **`GitHub API (403): Rate limited or insufficient permissions`**
602
+ - Fine-grained tokens need explicit repository access — check the permissions table above
603
+ - Code search has a stricter limit (~10 req/min) — wait 60s and retry
604
+
605
+ **`GitHub API (404): Resource not found`**
606
+ - Double-check the `owner` and `repo` spelling
607
+ - Private repos need your token to have access to them
608
+
609
+ **`GitHub API (422): Unprocessable`**
610
+ - Usually means a PR already exists for that branch, or a branch name is invalid
611
+
612
+ **`Command not found: node` in Claude Desktop**
613
+ - Use the full path: `C:\Program Files\nodejs\node.exe` (Windows) or run `which node` on Mac/Linux
614
+
615
+ ---
616
+
617
+ ## Contributing
618
+
619
+ Contributions are welcome. Each tool lives in its own file — adding a new one is straightforward:
620
+
621
+ 1. Create `src/tools/your_tool.ts` following the existing pattern (export `name`, `description`, `schema`, `handler`)
622
+ 2. Import and add it to the `tools` array in `src/index.ts`
623
+ 3. Add a mock simulator and test assertions in `tests/simulate-10-users.ts`
624
+ 4. Run `npm run build` and `npx tsx tests/simulate-10-users.ts` — all tests must pass
625
+
626
+ **Code conventions:**
627
+ - Zod schemas with `.describe()` on every field — Claude uses these
628
+ - `tokenGuard()` on every response
629
+ - `cacheGet`/`cacheSet` for all read operations
630
+ - `cacheDelete` for every state the write operation affects (`open`, `closed`, `all`)
631
+ - Use `getDefaultBranch()` instead of hard-coding `"main"`
632
+
633
+ ---
634
+
635
+ ## Roadmap
636
+
637
+ - [ ] `list_workflow_runs` — view CI status for a branch
638
+ - [ ] `get_commit` — detailed single commit with files changed
639
+ - [ ] `compare_branches` — diff between two branches
640
+ - [ ] `update_file` — commit a file change directly
641
+ - [ ] `add_label` / `remove_label` — label management
642
+
643
+ Open an issue if you want something added.
644
+
645
+ ---
646
+
647
+ ## License
648
+
649
+ MIT — do whatever you want with it.
650
+
651
+ ---
652
+
653
+ <div align="center">
654
+
655
+ Built for developers who'd rather talk to Claude than click through GitHub.
656
+
657
+ **[Report a bug](https://github.com/noushad999/github-mcp-server/issues) · [Request a feature](https://github.com/noushad999/github-mcp-server/issues)**
658
+
659
+ </div>
@@ -0,0 +1,5 @@
1
+ import { type AxiosInstance } from "axios";
2
+ export declare function getGitHubClient(): AxiosInstance;
3
+ /** Returns the repo's default branch, cached for 120 s. */
4
+ export declare function getDefaultBranch(owner: string, repo: string): Promise<string>;
5
+ //# sourceMappingURL=github-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-client.d.ts","sourceRoot":"","sources":["../src/github-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAKlD,wBAAgB,eAAe,IAAI,aAAa,CAsC/C;AAED,2DAA2D;AAC3D,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWnF"}