@ldraney/github-mcp 0.1.0 → 0.2.0-beta.1

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 (84) 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/prompts/code-review.d.ts +9 -0
  5. package/dist/prompts/code-review.js +145 -0
  6. package/dist/prompts/issue-triage.d.ts +9 -0
  7. package/dist/prompts/issue-triage.js +202 -0
  8. package/dist/prompts/release-notes.d.ts +9 -0
  9. package/dist/prompts/release-notes.js +236 -0
  10. package/dist/server.d.ts +8 -1
  11. package/dist/server.js +36 -210
  12. package/dist/tools/categories/actions.d.ts +2 -5
  13. package/dist/tools/categories/actions.js +640 -369
  14. package/dist/tools/categories/activity.d.ts +2 -0
  15. package/dist/tools/categories/activity.js +534 -0
  16. package/dist/tools/categories/apps.d.ts +2 -0
  17. package/dist/tools/categories/apps.js +224 -0
  18. package/dist/tools/categories/billing.d.ts +2 -0
  19. package/dist/tools/categories/billing.js +145 -0
  20. package/dist/tools/categories/checks.d.ts +2 -0
  21. package/dist/tools/categories/checks.js +554 -0
  22. package/dist/tools/categories/codeScanning.d.ts +2 -0
  23. package/dist/tools/categories/codeScanning.js +375 -0
  24. package/dist/tools/categories/codeSecurity.d.ts +2 -0
  25. package/dist/tools/categories/codeSecurity.js +463 -0
  26. package/dist/tools/categories/codesOfConduct.d.ts +2 -0
  27. package/dist/tools/categories/codesOfConduct.js +45 -0
  28. package/dist/tools/categories/codespaces.d.ts +2 -0
  29. package/dist/tools/categories/codespaces.js +259 -0
  30. package/dist/tools/categories/copilot.d.ts +2 -0
  31. package/dist/tools/categories/copilot.js +187 -0
  32. package/dist/tools/categories/dependabot.d.ts +2 -0
  33. package/dist/tools/categories/dependabot.js +454 -0
  34. package/dist/tools/categories/emojis.d.ts +2 -0
  35. package/dist/tools/categories/emojis.js +22 -0
  36. package/dist/tools/categories/gists.d.ts +2 -5
  37. package/dist/tools/categories/gists.js +474 -285
  38. package/dist/tools/categories/git.d.ts +2 -0
  39. package/dist/tools/categories/git.js +520 -0
  40. package/dist/tools/categories/gitignore.d.ts +2 -0
  41. package/dist/tools/categories/gitignore.js +45 -0
  42. package/dist/tools/categories/index.d.ts +33 -0
  43. package/dist/tools/categories/index.js +33 -0
  44. package/dist/tools/categories/interactions.d.ts +2 -0
  45. package/dist/tools/categories/interactions.js +184 -0
  46. package/dist/tools/categories/issues.d.ts +2 -5
  47. package/dist/tools/categories/issues.js +692 -390
  48. package/dist/tools/categories/licenses.d.ts +2 -0
  49. package/dist/tools/categories/licenses.js +95 -0
  50. package/dist/tools/categories/markdown.d.ts +2 -0
  51. package/dist/tools/categories/markdown.js +64 -0
  52. package/dist/tools/categories/meta.d.ts +2 -0
  53. package/dist/tools/categories/meta.js +74 -0
  54. package/dist/tools/categories/migrations.d.ts +2 -0
  55. package/dist/tools/categories/migrations.js +290 -0
  56. package/dist/tools/categories/orgs.d.ts +2 -5
  57. package/dist/tools/categories/orgs.js +585 -417
  58. package/dist/tools/categories/packages.d.ts +2 -0
  59. package/dist/tools/categories/packages.js +918 -0
  60. package/dist/tools/categories/projects.d.ts +2 -0
  61. package/dist/tools/categories/projects.js +692 -0
  62. package/dist/tools/categories/pulls.d.ts +2 -5
  63. package/dist/tools/categories/pulls.js +715 -332
  64. package/dist/tools/categories/rateLimit.d.ts +2 -0
  65. package/dist/tools/categories/rateLimit.js +22 -0
  66. package/dist/tools/categories/reactions.d.ts +2 -0
  67. package/dist/tools/categories/reactions.js +385 -0
  68. package/dist/tools/categories/repos.d.ts +2 -5
  69. package/dist/tools/categories/repos.js +844 -366
  70. package/dist/tools/categories/search.d.ts +2 -5
  71. package/dist/tools/categories/search.js +294 -196
  72. package/dist/tools/categories/secretScanning.d.ts +2 -0
  73. package/dist/tools/categories/secretScanning.js +324 -0
  74. package/dist/tools/categories/securityAdvisories.d.ts +2 -0
  75. package/dist/tools/categories/securityAdvisories.js +407 -0
  76. package/dist/tools/categories/teams.d.ts +2 -0
  77. package/dist/tools/categories/teams.js +614 -0
  78. package/dist/tools/categories/users.d.ts +2 -5
  79. package/dist/tools/categories/users.js +474 -247
  80. package/dist/tools/generator.d.ts +35 -15
  81. package/dist/tools/generator.js +113 -57
  82. package/dist/tools/types.d.ts +63 -0
  83. package/dist/tools/types.js +17 -0
  84. package/package.json +1 -1
@@ -1,19 +1,39 @@
1
- import { Octokit } from '@octokit/rest';
2
- import { Tool } from '@modelcontextprotocol/sdk/types.js';
1
+ import type { Octokit } from '@octokit/rest';
2
+ import type { MCPToolDefinition, ToolResult } from './types.js';
3
3
  /**
4
- * Register tools with optional category filtering
4
+ * Tool generator that manages tool loading and execution
5
5
  */
6
- export declare function registerTools(octokit: Octokit, enabledCategories?: string[]): void;
6
+ export declare class ToolGenerator {
7
+ private handlers;
8
+ private definitions;
9
+ private loadedCategories;
10
+ /**
11
+ * Load specified categories (or defaults if none specified)
12
+ * @param categoryNames - Array of category names to load
13
+ */
14
+ loadCategories(categoryNames?: string[]): void;
15
+ /**
16
+ * Get all tool definitions for MCP ListTools response
17
+ */
18
+ getTools(): MCPToolDefinition[];
19
+ /**
20
+ * Execute a tool by name
21
+ * @param octokit - Authenticated Octokit instance
22
+ * @param name - Tool name
23
+ * @param args - Tool arguments
24
+ */
25
+ executeTool(octokit: Octokit, name: string, args: Record<string, unknown>): Promise<ToolResult>;
26
+ /**
27
+ * Get list of available category names
28
+ */
29
+ static getAvailableCategories(): string[];
30
+ /**
31
+ * Get count of loaded tools
32
+ */
33
+ getToolCount(): number;
34
+ }
7
35
  /**
8
- * Get all registered tool definitions
36
+ * Create and initialize a tool generator
37
+ * @param categories - Optional array of category names to load
9
38
  */
10
- export declare function getToolDefinitions(): Tool[];
11
- /**
12
- * Handle a tool call
13
- */
14
- export declare function handleToolCall(name: string, args: Record<string, unknown>): Promise<unknown>;
15
- /**
16
- * Get list of available categories
17
- */
18
- export declare function getAvailableCategories(): string[];
19
- //# sourceMappingURL=generator.d.ts.map
39
+ export declare function createToolGenerator(categories?: string[]): ToolGenerator;
@@ -1,69 +1,125 @@
1
- import { reposTools, handleReposTool } from './categories/repos.js';
2
- import { issuesTools, handleIssuesTool } from './categories/issues.js';
3
- import { pullsTools, handlePullsTool } from './categories/pulls.js';
4
- import { usersTools, handleUsersTool } from './categories/users.js';
5
- import { actionsTools, handleActionsTool } from './categories/actions.js';
6
- import { gistsTools, handleGistsTool } from './categories/gists.js';
7
- import { orgsTools, handleOrgsTool } from './categories/orgs.js';
8
- import { searchTools, handleSearchTool } from './categories/search.js';
9
- // Store octokit instance for tool handlers
10
- let octokitInstance = null;
11
- // All available tool categories
12
- const CATEGORIES = {
13
- repos: { tools: reposTools, handler: handleReposTool },
14
- issues: { tools: issuesTools, handler: handleIssuesTool },
15
- pulls: { tools: pullsTools, handler: handlePullsTool },
16
- users: { tools: usersTools, handler: handleUsersTool },
17
- actions: { tools: actionsTools, handler: handleActionsTool },
18
- gists: { tools: gistsTools, handler: handleGistsTool },
19
- orgs: { tools: orgsTools, handler: handleOrgsTool },
20
- search: { tools: searchTools, handler: handleSearchTool },
21
- };
22
- // Active tools after filtering by enabled categories
23
- let activeTools = [];
24
- let activeHandlers = new Map();
1
+ import { errorResult } from './types.js';
2
+ import { reposCategory, issuesCategory, pullsCategory, usersCategory, actionsCategory, searchCategory, orgsCategory, gistsCategory, checksCategory, projectsCategory, teamsCategory, activityCategory, gitCategory, reactionsCategory, packagesCategory, dependabotCategory, secretScanningCategory, codeScanningCategory, codeSecurityCategory, securityAdvisoriesCategory, appsCategory, billingCategory, codespacesCategory, copilotCategory, migrationsCategory, interactionsCategory, rateLimitCategory, markdownCategory, metaCategory, emojisCategory, gitignoreCategory, licensesCategory, codesOfConductCategory, } from './categories/index.js';
25
3
  /**
26
- * Register tools with optional category filtering
4
+ * All available tool categories
27
5
  */
28
- export function registerTools(octokit, enabledCategories) {
29
- octokitInstance = octokit;
30
- activeTools = [];
31
- activeHandlers.clear();
32
- const categoriesToLoad = enabledCategories
33
- ? enabledCategories.filter((c) => c in CATEGORIES)
34
- : Object.keys(CATEGORIES);
35
- for (const category of categoriesToLoad) {
36
- const { tools, handler } = CATEGORIES[category];
37
- for (const tool of tools) {
38
- activeTools.push(tool);
39
- activeHandlers.set(tool.name, handler);
40
- }
41
- }
42
- console.error(`Registered ${activeTools.length} tools from ${categoriesToLoad.length} categories`);
43
- }
6
+ const ALL_CATEGORIES = {
7
+ repos: reposCategory,
8
+ issues: issuesCategory,
9
+ pulls: pullsCategory,
10
+ users: usersCategory,
11
+ actions: actionsCategory,
12
+ search: searchCategory,
13
+ orgs: orgsCategory,
14
+ gists: gistsCategory,
15
+ checks: checksCategory,
16
+ projects: projectsCategory,
17
+ teams: teamsCategory,
18
+ activity: activityCategory,
19
+ git: gitCategory,
20
+ reactions: reactionsCategory,
21
+ packages: packagesCategory,
22
+ dependabot: dependabotCategory,
23
+ secretScanning: secretScanningCategory,
24
+ codeScanning: codeScanningCategory,
25
+ codeSecurity: codeSecurityCategory,
26
+ securityAdvisories: securityAdvisoriesCategory,
27
+ apps: appsCategory,
28
+ billing: billingCategory,
29
+ codespaces: codespacesCategory,
30
+ copilot: copilotCategory,
31
+ migrations: migrationsCategory,
32
+ interactions: interactionsCategory,
33
+ rateLimit: rateLimitCategory,
34
+ markdown: markdownCategory,
35
+ meta: metaCategory,
36
+ emojis: emojisCategory,
37
+ gitignore: gitignoreCategory,
38
+ licenses: licensesCategory,
39
+ codesOfConduct: codesOfConductCategory,
40
+ };
44
41
  /**
45
- * Get all registered tool definitions
42
+ * Default categories to load if none specified
46
43
  */
47
- export function getToolDefinitions() {
48
- return activeTools;
49
- }
44
+ const DEFAULT_CATEGORIES = [
45
+ 'repos', 'issues', 'pulls', 'users', 'actions', 'search', 'orgs',
46
+ 'gists', 'checks', 'projects', 'teams', 'activity', 'git',
47
+ 'reactions', 'packages', 'dependabot', 'secretScanning', 'codeScanning',
48
+ 'codeSecurity', 'securityAdvisories', 'apps', 'billing', 'codespaces',
49
+ 'copilot', 'migrations', 'interactions', 'rateLimit', 'markdown',
50
+ 'meta', 'emojis', 'gitignore', 'licenses', 'codesOfConduct',
51
+ ];
50
52
  /**
51
- * Handle a tool call
53
+ * Tool generator that manages tool loading and execution
52
54
  */
53
- export async function handleToolCall(name, args) {
54
- if (!octokitInstance) {
55
- throw new Error('Tools not initialized. Call registerTools first.');
55
+ export class ToolGenerator {
56
+ handlers = new Map();
57
+ definitions = [];
58
+ loadedCategories = [];
59
+ /**
60
+ * Load specified categories (or defaults if none specified)
61
+ * @param categoryNames - Array of category names to load
62
+ */
63
+ loadCategories(categoryNames) {
64
+ const names = categoryNames ?? DEFAULT_CATEGORIES;
65
+ for (const name of names) {
66
+ const category = ALL_CATEGORIES[name];
67
+ if (!category) {
68
+ console.error(`Warning: Unknown category "${name}", skipping`);
69
+ continue;
70
+ }
71
+ for (const tool of category.tools) {
72
+ this.handlers.set(tool.definition.name, tool.handler);
73
+ this.definitions.push(tool.definition);
74
+ }
75
+ this.loadedCategories.push(name);
76
+ }
77
+ console.error(`Loaded ${this.definitions.length} tools from categories: ${this.loadedCategories.join(', ')}`);
78
+ }
79
+ /**
80
+ * Get all tool definitions for MCP ListTools response
81
+ */
82
+ getTools() {
83
+ return this.definitions;
84
+ }
85
+ /**
86
+ * Execute a tool by name
87
+ * @param octokit - Authenticated Octokit instance
88
+ * @param name - Tool name
89
+ * @param args - Tool arguments
90
+ */
91
+ async executeTool(octokit, name, args) {
92
+ const handler = this.handlers.get(name);
93
+ if (!handler) {
94
+ return errorResult(`Unknown tool: ${name}`);
95
+ }
96
+ try {
97
+ return await handler(octokit, args);
98
+ }
99
+ catch (error) {
100
+ const message = error instanceof Error ? error.message : String(error);
101
+ return errorResult(message);
102
+ }
103
+ }
104
+ /**
105
+ * Get list of available category names
106
+ */
107
+ static getAvailableCategories() {
108
+ return Object.keys(ALL_CATEGORIES);
56
109
  }
57
- const handler = activeHandlers.get(name);
58
- if (!handler) {
59
- throw new Error(`Unknown tool: ${name}`);
110
+ /**
111
+ * Get count of loaded tools
112
+ */
113
+ getToolCount() {
114
+ return this.definitions.length;
60
115
  }
61
- return handler(octokitInstance, args);
62
116
  }
63
117
  /**
64
- * Get list of available categories
118
+ * Create and initialize a tool generator
119
+ * @param categories - Optional array of category names to load
65
120
  */
66
- export function getAvailableCategories() {
67
- return Object.keys(CATEGORIES);
121
+ export function createToolGenerator(categories) {
122
+ const generator = new ToolGenerator();
123
+ generator.loadCategories(categories);
124
+ return generator;
68
125
  }
69
- //# sourceMappingURL=generator.js.map
@@ -0,0 +1,63 @@
1
+ import type { Octokit } from '@octokit/rest';
2
+ /**
3
+ * Standardized response format for tool execution
4
+ * Compatible with MCP SDK's CallToolResult
5
+ */
6
+ export interface ToolResult {
7
+ [key: string]: unknown;
8
+ content: Array<{
9
+ type: 'text';
10
+ text: string;
11
+ }>;
12
+ isError?: boolean;
13
+ }
14
+ /**
15
+ * Function signature for tool handlers
16
+ */
17
+ export type ToolHandler = (octokit: Octokit, args: Record<string, unknown>) => Promise<ToolResult>;
18
+ /**
19
+ * JSON Schema for tool input validation
20
+ */
21
+ export interface ToolInputSchema {
22
+ type: 'object';
23
+ properties: Record<string, {
24
+ type: string;
25
+ description?: string;
26
+ enum?: string[];
27
+ items?: {
28
+ type: string;
29
+ };
30
+ }>;
31
+ required?: string[];
32
+ }
33
+ /**
34
+ * MCP tool definition (what gets sent to the client)
35
+ */
36
+ export interface MCPToolDefinition {
37
+ name: string;
38
+ description: string;
39
+ inputSchema: ToolInputSchema;
40
+ }
41
+ /**
42
+ * Tool definition bundled with its handler
43
+ */
44
+ export interface GitHubToolDefinition {
45
+ definition: MCPToolDefinition;
46
+ handler: ToolHandler;
47
+ }
48
+ /**
49
+ * A category of related tools
50
+ */
51
+ export interface ToolCategory {
52
+ name: string;
53
+ description: string;
54
+ tools: GitHubToolDefinition[];
55
+ }
56
+ /**
57
+ * Helper to create a successful tool result
58
+ */
59
+ export declare function successResult(data: unknown): ToolResult;
60
+ /**
61
+ * Helper to create an error tool result
62
+ */
63
+ export declare function errorResult(message: string): ToolResult;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Helper to create a successful tool result
3
+ */
4
+ export function successResult(data) {
5
+ return {
6
+ content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
7
+ };
8
+ }
9
+ /**
10
+ * Helper to create an error tool result
11
+ */
12
+ export function errorResult(message) {
13
+ return {
14
+ content: [{ type: 'text', text: `Error: ${message}` }],
15
+ isError: true,
16
+ };
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldraney/github-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-beta.1",
4
4
  "description": "GitHub MCP server with OAuth and 800+ API endpoints",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",