@ldraney/github-mcp 0.1.0 → 0.2.0-beta.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 (78) hide show
  1. package/dist/index.js +8 -2
  2. package/dist/prompts/activity-summary.d.ts +10 -0
  3. package/dist/prompts/activity-summary.js +154 -0
  4. package/dist/server.d.ts +8 -1
  5. package/dist/server.js +20 -210
  6. package/dist/tools/categories/actions.d.ts +2 -5
  7. package/dist/tools/categories/actions.js +640 -369
  8. package/dist/tools/categories/activity.d.ts +2 -0
  9. package/dist/tools/categories/activity.js +534 -0
  10. package/dist/tools/categories/apps.d.ts +2 -0
  11. package/dist/tools/categories/apps.js +224 -0
  12. package/dist/tools/categories/billing.d.ts +2 -0
  13. package/dist/tools/categories/billing.js +145 -0
  14. package/dist/tools/categories/checks.d.ts +2 -0
  15. package/dist/tools/categories/checks.js +554 -0
  16. package/dist/tools/categories/codeScanning.d.ts +2 -0
  17. package/dist/tools/categories/codeScanning.js +375 -0
  18. package/dist/tools/categories/codeSecurity.d.ts +2 -0
  19. package/dist/tools/categories/codeSecurity.js +463 -0
  20. package/dist/tools/categories/codesOfConduct.d.ts +2 -0
  21. package/dist/tools/categories/codesOfConduct.js +45 -0
  22. package/dist/tools/categories/codespaces.d.ts +2 -0
  23. package/dist/tools/categories/codespaces.js +259 -0
  24. package/dist/tools/categories/copilot.d.ts +2 -0
  25. package/dist/tools/categories/copilot.js +187 -0
  26. package/dist/tools/categories/dependabot.d.ts +2 -0
  27. package/dist/tools/categories/dependabot.js +454 -0
  28. package/dist/tools/categories/emojis.d.ts +2 -0
  29. package/dist/tools/categories/emojis.js +22 -0
  30. package/dist/tools/categories/gists.d.ts +2 -5
  31. package/dist/tools/categories/gists.js +474 -285
  32. package/dist/tools/categories/git.d.ts +2 -0
  33. package/dist/tools/categories/git.js +520 -0
  34. package/dist/tools/categories/gitignore.d.ts +2 -0
  35. package/dist/tools/categories/gitignore.js +45 -0
  36. package/dist/tools/categories/index.d.ts +33 -0
  37. package/dist/tools/categories/index.js +33 -0
  38. package/dist/tools/categories/interactions.d.ts +2 -0
  39. package/dist/tools/categories/interactions.js +184 -0
  40. package/dist/tools/categories/issues.d.ts +2 -5
  41. package/dist/tools/categories/issues.js +692 -390
  42. package/dist/tools/categories/licenses.d.ts +2 -0
  43. package/dist/tools/categories/licenses.js +95 -0
  44. package/dist/tools/categories/markdown.d.ts +2 -0
  45. package/dist/tools/categories/markdown.js +64 -0
  46. package/dist/tools/categories/meta.d.ts +2 -0
  47. package/dist/tools/categories/meta.js +74 -0
  48. package/dist/tools/categories/migrations.d.ts +2 -0
  49. package/dist/tools/categories/migrations.js +290 -0
  50. package/dist/tools/categories/orgs.d.ts +2 -5
  51. package/dist/tools/categories/orgs.js +585 -417
  52. package/dist/tools/categories/packages.d.ts +2 -0
  53. package/dist/tools/categories/packages.js +918 -0
  54. package/dist/tools/categories/projects.d.ts +2 -0
  55. package/dist/tools/categories/projects.js +692 -0
  56. package/dist/tools/categories/pulls.d.ts +2 -5
  57. package/dist/tools/categories/pulls.js +715 -332
  58. package/dist/tools/categories/rateLimit.d.ts +2 -0
  59. package/dist/tools/categories/rateLimit.js +22 -0
  60. package/dist/tools/categories/reactions.d.ts +2 -0
  61. package/dist/tools/categories/reactions.js +385 -0
  62. package/dist/tools/categories/repos.d.ts +2 -5
  63. package/dist/tools/categories/repos.js +844 -366
  64. package/dist/tools/categories/search.d.ts +2 -5
  65. package/dist/tools/categories/search.js +294 -196
  66. package/dist/tools/categories/secretScanning.d.ts +2 -0
  67. package/dist/tools/categories/secretScanning.js +324 -0
  68. package/dist/tools/categories/securityAdvisories.d.ts +2 -0
  69. package/dist/tools/categories/securityAdvisories.js +407 -0
  70. package/dist/tools/categories/teams.d.ts +2 -0
  71. package/dist/tools/categories/teams.js +614 -0
  72. package/dist/tools/categories/users.d.ts +2 -5
  73. package/dist/tools/categories/users.js +474 -247
  74. package/dist/tools/generator.d.ts +35 -15
  75. package/dist/tools/generator.js +113 -57
  76. package/dist/tools/types.d.ts +63 -0
  77. package/dist/tools/types.js +17 -0
  78. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { Command } from 'commander';
3
3
  import { getToken, login, logout, getAuthStatus } from './auth/oauth-flow.js';
4
4
  import { startServer } from './server.js';
5
+ import { ToolGenerator } from './tools/generator.js';
5
6
  const program = new Command();
6
7
  program
7
8
  .name('github-mcp')
@@ -9,7 +10,8 @@ program
9
10
  .version('0.1.0');
10
11
  // Default command: start server
11
12
  program
12
- .action(async () => {
13
+ .option('-c, --categories <categories>', `Comma-separated list of tool categories to load (available: ${ToolGenerator.getAvailableCategories().join(', ')})`)
14
+ .action(async (options) => {
13
15
  try {
14
16
  let token = await getToken();
15
17
  if (!token) {
@@ -20,7 +22,11 @@ program
20
22
  console.error('Authentication failed. Cannot start server.');
21
23
  process.exit(1);
22
24
  }
23
- await startServer(token);
25
+ // Parse categories if provided
26
+ const categories = options.categories
27
+ ? options.categories.split(',').map((c) => c.trim())
28
+ : undefined;
29
+ await startServer(token, { categories });
24
30
  }
25
31
  catch (error) {
26
32
  console.error('Error:', error instanceof Error ? error.message : error);
@@ -0,0 +1,10 @@
1
+ import type { Prompt, GetPromptResult } from '@modelcontextprotocol/sdk/types.js';
2
+ /**
3
+ * Activity summary prompt definitions
4
+ */
5
+ export declare const activityPrompts: Prompt[];
6
+ /**
7
+ * Generate a prompt result for activity summaries
8
+ * These prompts instruct Claude to use the activity tools to fetch and summarize events
9
+ */
10
+ export declare function getActivityPrompt(name: string, args: Record<string, string>): GetPromptResult;
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Activity summary prompt definitions
3
+ */
4
+ export const activityPrompts = [
5
+ {
6
+ name: 'daily_summary',
7
+ description: 'Summarize GitHub activity from the last 24 hours for a repository',
8
+ arguments: [
9
+ {
10
+ name: 'owner',
11
+ description: 'Repository owner (username or organization)',
12
+ required: true,
13
+ },
14
+ {
15
+ name: 'repo',
16
+ description: 'Repository name',
17
+ required: true,
18
+ },
19
+ ],
20
+ },
21
+ {
22
+ name: 'weekly_summary',
23
+ description: 'Summarize GitHub activity from the last 7 days for a repository',
24
+ arguments: [
25
+ {
26
+ name: 'owner',
27
+ description: 'Repository owner (username or organization)',
28
+ required: true,
29
+ },
30
+ {
31
+ name: 'repo',
32
+ description: 'Repository name',
33
+ required: true,
34
+ },
35
+ ],
36
+ },
37
+ {
38
+ name: 'repo_activity',
39
+ description: 'Get recent activity summary for a repository (configurable timeframe)',
40
+ arguments: [
41
+ {
42
+ name: 'owner',
43
+ description: 'Repository owner (username or organization)',
44
+ required: true,
45
+ },
46
+ {
47
+ name: 'repo',
48
+ description: 'Repository name',
49
+ required: true,
50
+ },
51
+ {
52
+ name: 'days',
53
+ description: 'Number of days to look back (default: 7)',
54
+ required: false,
55
+ },
56
+ ],
57
+ },
58
+ ];
59
+ /**
60
+ * Generate a prompt result for activity summaries
61
+ * These prompts instruct Claude to use the activity tools to fetch and summarize events
62
+ */
63
+ export function getActivityPrompt(name, args) {
64
+ const owner = args.owner;
65
+ const repo = args.repo;
66
+ switch (name) {
67
+ case 'daily_summary':
68
+ return {
69
+ messages: [
70
+ {
71
+ role: 'user',
72
+ content: {
73
+ type: 'text',
74
+ text: `Please summarize the GitHub activity for ${owner}/${repo} from the last 24 hours.
75
+
76
+ Use the github_activity_list_repo_events tool to fetch recent events for this repository, then provide a summary that includes:
77
+
78
+ 1. **Commits**: Any push events with commit messages
79
+ 2. **Pull Requests**: Opened, closed, or merged PRs
80
+ 3. **Issues**: New issues or issue comments
81
+ 4. **Reviews**: PR reviews and review comments
82
+ 5. **Releases**: Any new releases or tags
83
+
84
+ Filter the events to only include those from the last 24 hours based on the created_at timestamp.
85
+
86
+ If there's no activity, say so clearly.`,
87
+ },
88
+ },
89
+ ],
90
+ };
91
+ case 'weekly_summary':
92
+ return {
93
+ messages: [
94
+ {
95
+ role: 'user',
96
+ content: {
97
+ type: 'text',
98
+ text: `Please summarize the GitHub activity for ${owner}/${repo} from the last 7 days.
99
+
100
+ Use the github_activity_list_repo_events tool to fetch recent events for this repository (you may need to paginate through results), then provide a comprehensive summary that includes:
101
+
102
+ 1. **Commits**: Push events with notable commit messages grouped by author
103
+ 2. **Pull Requests**: Opened, closed, or merged PRs with titles
104
+ 3. **Issues**: New issues, closed issues, and notable issue discussions
105
+ 4. **Reviews**: PR reviews and their outcomes
106
+ 5. **Releases**: Any new releases with version numbers
107
+ 6. **Contributors**: Active contributors during this period
108
+
109
+ Filter the events to only include those from the last 7 days based on the created_at timestamp.
110
+
111
+ Organize the summary by category and highlight the most significant changes.`,
112
+ },
113
+ },
114
+ ],
115
+ };
116
+ case 'repo_activity':
117
+ const days = parseInt(args.days) || 7;
118
+ return {
119
+ messages: [
120
+ {
121
+ role: 'user',
122
+ content: {
123
+ type: 'text',
124
+ text: `Please summarize the GitHub activity for ${owner}/${repo} from the last ${days} day(s).
125
+
126
+ Use the github_activity_list_repo_events tool to fetch recent events for this repository, then provide a summary that includes:
127
+
128
+ 1. **Overview**: Quick stats on total events by type
129
+ 2. **Commits**: Notable push events and commit activity
130
+ 3. **Pull Requests**: PR activity (opened, closed, merged)
131
+ 4. **Issues**: Issue activity (opened, closed, commented)
132
+ 5. **Other Events**: Any other notable activity (releases, forks, stars, etc.)
133
+
134
+ Filter the events to only include those from the last ${days} day(s) based on the created_at timestamp.
135
+
136
+ Present the information in a clear, scannable format.`,
137
+ },
138
+ },
139
+ ],
140
+ };
141
+ default:
142
+ return {
143
+ messages: [
144
+ {
145
+ role: 'user',
146
+ content: {
147
+ type: 'text',
148
+ text: `Unknown prompt: ${name}`,
149
+ },
150
+ },
151
+ ],
152
+ };
153
+ }
154
+ }
package/dist/server.d.ts CHANGED
@@ -1,4 +1,11 @@
1
+ /**
2
+ * Server startup options
3
+ */
4
+ export interface ServerOptions {
5
+ /** Categories to load (default: all) */
6
+ categories?: string[];
7
+ }
1
8
  /**
2
9
  * Start the MCP server with authenticated Octokit
3
10
  */
4
- export declare function startServer(token: string): Promise<void>;
11
+ export declare function startServer(token: string, options?: ServerOptions): Promise<void>;
package/dist/server.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
- import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
3
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
4
4
  import { Octokit } from '@octokit/rest';
5
+ import { createToolGenerator } from './tools/generator.js';
6
+ import { activityPrompts, getActivityPrompt } from './prompts/activity-summary.js';
5
7
  /**
6
8
  * Start the MCP server with authenticated Octokit
7
9
  */
8
- export async function startServer(token) {
10
+ export async function startServer(token, options = {}) {
9
11
  const octokit = new Octokit({ auth: token });
10
12
  // Verify token works
11
13
  try {
@@ -15,230 +17,38 @@ export async function startServer(token) {
15
17
  catch (error) {
16
18
  throw new Error('Failed to authenticate with GitHub. Token may be invalid.');
17
19
  }
20
+ // Initialize tool generator with specified categories
21
+ const generator = createToolGenerator(options.categories);
18
22
  const server = new Server({
19
23
  name: 'github-mcp',
20
24
  version: '0.1.0',
21
25
  }, {
22
26
  capabilities: {
23
27
  tools: {},
28
+ prompts: {},
24
29
  },
25
30
  });
26
31
  // List available tools
27
32
  server.setRequestHandler(ListToolsRequestSchema, async () => {
28
33
  return {
29
- tools: [
30
- {
31
- name: 'github_repos_list',
32
- description: 'List repositories for the authenticated user',
33
- inputSchema: {
34
- type: 'object',
35
- properties: {
36
- visibility: {
37
- type: 'string',
38
- enum: ['all', 'public', 'private'],
39
- description: 'Filter by visibility',
40
- },
41
- sort: {
42
- type: 'string',
43
- enum: ['created', 'updated', 'pushed', 'full_name'],
44
- description: 'Sort field',
45
- },
46
- per_page: {
47
- type: 'number',
48
- description: 'Results per page (max 100)',
49
- },
50
- },
51
- },
52
- },
53
- {
54
- name: 'github_repos_get',
55
- description: 'Get a repository by owner and name',
56
- inputSchema: {
57
- type: 'object',
58
- properties: {
59
- owner: {
60
- type: 'string',
61
- description: 'Repository owner',
62
- },
63
- repo: {
64
- type: 'string',
65
- description: 'Repository name',
66
- },
67
- },
68
- required: ['owner', 'repo'],
69
- },
70
- },
71
- {
72
- name: 'github_issues_list',
73
- description: 'List issues for a repository',
74
- inputSchema: {
75
- type: 'object',
76
- properties: {
77
- owner: {
78
- type: 'string',
79
- description: 'Repository owner',
80
- },
81
- repo: {
82
- type: 'string',
83
- description: 'Repository name',
84
- },
85
- state: {
86
- type: 'string',
87
- enum: ['open', 'closed', 'all'],
88
- description: 'Issue state filter',
89
- },
90
- per_page: {
91
- type: 'number',
92
- description: 'Results per page (max 100)',
93
- },
94
- },
95
- required: ['owner', 'repo'],
96
- },
97
- },
98
- {
99
- name: 'github_issues_create',
100
- description: 'Create a new issue',
101
- inputSchema: {
102
- type: 'object',
103
- properties: {
104
- owner: {
105
- type: 'string',
106
- description: 'Repository owner',
107
- },
108
- repo: {
109
- type: 'string',
110
- description: 'Repository name',
111
- },
112
- title: {
113
- type: 'string',
114
- description: 'Issue title',
115
- },
116
- body: {
117
- type: 'string',
118
- description: 'Issue body',
119
- },
120
- labels: {
121
- type: 'array',
122
- items: { type: 'string' },
123
- description: 'Labels to add',
124
- },
125
- },
126
- required: ['owner', 'repo', 'title'],
127
- },
128
- },
129
- {
130
- name: 'github_pulls_list',
131
- description: 'List pull requests for a repository',
132
- inputSchema: {
133
- type: 'object',
134
- properties: {
135
- owner: {
136
- type: 'string',
137
- description: 'Repository owner',
138
- },
139
- repo: {
140
- type: 'string',
141
- description: 'Repository name',
142
- },
143
- state: {
144
- type: 'string',
145
- enum: ['open', 'closed', 'all'],
146
- description: 'PR state filter',
147
- },
148
- per_page: {
149
- type: 'number',
150
- description: 'Results per page (max 100)',
151
- },
152
- },
153
- required: ['owner', 'repo'],
154
- },
155
- },
156
- {
157
- name: 'github_user_get',
158
- description: 'Get the authenticated user',
159
- inputSchema: {
160
- type: 'object',
161
- properties: {},
162
- },
163
- },
164
- ],
34
+ tools: generator.getTools(),
165
35
  };
166
36
  });
167
37
  // Handle tool calls
168
38
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
169
39
  const { name, arguments: args } = request.params;
170
- try {
171
- switch (name) {
172
- case 'github_repos_list': {
173
- const { data } = await octokit.repos.listForAuthenticatedUser({
174
- visibility: args?.visibility,
175
- sort: args?.sort,
176
- per_page: args?.per_page,
177
- });
178
- return {
179
- content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
180
- };
181
- }
182
- case 'github_repos_get': {
183
- const { data } = await octokit.repos.get({
184
- owner: args?.owner,
185
- repo: args?.repo,
186
- });
187
- return {
188
- content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
189
- };
190
- }
191
- case 'github_issues_list': {
192
- const { data } = await octokit.issues.listForRepo({
193
- owner: args?.owner,
194
- repo: args?.repo,
195
- state: args?.state,
196
- per_page: args?.per_page,
197
- });
198
- return {
199
- content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
200
- };
201
- }
202
- case 'github_issues_create': {
203
- const { data } = await octokit.issues.create({
204
- owner: args?.owner,
205
- repo: args?.repo,
206
- title: args?.title,
207
- body: args?.body,
208
- labels: args?.labels,
209
- });
210
- return {
211
- content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
212
- };
213
- }
214
- case 'github_pulls_list': {
215
- const { data } = await octokit.pulls.list({
216
- owner: args?.owner,
217
- repo: args?.repo,
218
- state: args?.state,
219
- per_page: args?.per_page,
220
- });
221
- return {
222
- content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
223
- };
224
- }
225
- case 'github_user_get': {
226
- const { data } = await octokit.users.getAuthenticated();
227
- return {
228
- content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
229
- };
230
- }
231
- default:
232
- throw new Error(`Unknown tool: ${name}`);
233
- }
234
- }
235
- catch (error) {
236
- const message = error instanceof Error ? error.message : String(error);
237
- return {
238
- content: [{ type: 'text', text: `Error: ${message}` }],
239
- isError: true,
240
- };
241
- }
40
+ return generator.executeTool(octokit, name, args ?? {});
41
+ });
42
+ // List available prompts
43
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
44
+ return {
45
+ prompts: activityPrompts,
46
+ };
47
+ });
48
+ // Handle prompt requests
49
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
50
+ const { name, arguments: args } = request.params;
51
+ return getActivityPrompt(name, args ?? {});
242
52
  });
243
53
  // Connect via stdio
244
54
  const transport = new StdioServerTransport();
@@ -1,5 +1,2 @@
1
- import { Octokit } from '@octokit/rest';
2
- import { Tool } from '@modelcontextprotocol/sdk/types.js';
3
- export declare const actionsTools: Tool[];
4
- export declare function handleActionsTool(octokit: Octokit, args: Record<string, unknown>): Promise<unknown>;
5
- //# sourceMappingURL=actions.d.ts.map
1
+ import type { ToolCategory } from '../types.js';
2
+ export declare const actionsCategory: ToolCategory;