@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.
- package/dist/index.js +8 -2
- package/dist/prompts/activity-summary.d.ts +10 -0
- package/dist/prompts/activity-summary.js +154 -0
- package/dist/server.d.ts +8 -1
- package/dist/server.js +20 -210
- package/dist/tools/categories/actions.d.ts +2 -5
- package/dist/tools/categories/actions.js +640 -369
- package/dist/tools/categories/activity.d.ts +2 -0
- package/dist/tools/categories/activity.js +534 -0
- package/dist/tools/categories/apps.d.ts +2 -0
- package/dist/tools/categories/apps.js +224 -0
- package/dist/tools/categories/billing.d.ts +2 -0
- package/dist/tools/categories/billing.js +145 -0
- package/dist/tools/categories/checks.d.ts +2 -0
- package/dist/tools/categories/checks.js +554 -0
- package/dist/tools/categories/codeScanning.d.ts +2 -0
- package/dist/tools/categories/codeScanning.js +375 -0
- package/dist/tools/categories/codeSecurity.d.ts +2 -0
- package/dist/tools/categories/codeSecurity.js +463 -0
- package/dist/tools/categories/codesOfConduct.d.ts +2 -0
- package/dist/tools/categories/codesOfConduct.js +45 -0
- package/dist/tools/categories/codespaces.d.ts +2 -0
- package/dist/tools/categories/codespaces.js +259 -0
- package/dist/tools/categories/copilot.d.ts +2 -0
- package/dist/tools/categories/copilot.js +187 -0
- package/dist/tools/categories/dependabot.d.ts +2 -0
- package/dist/tools/categories/dependabot.js +454 -0
- package/dist/tools/categories/emojis.d.ts +2 -0
- package/dist/tools/categories/emojis.js +22 -0
- package/dist/tools/categories/gists.d.ts +2 -5
- package/dist/tools/categories/gists.js +474 -285
- package/dist/tools/categories/git.d.ts +2 -0
- package/dist/tools/categories/git.js +520 -0
- package/dist/tools/categories/gitignore.d.ts +2 -0
- package/dist/tools/categories/gitignore.js +45 -0
- package/dist/tools/categories/index.d.ts +33 -0
- package/dist/tools/categories/index.js +33 -0
- package/dist/tools/categories/interactions.d.ts +2 -0
- package/dist/tools/categories/interactions.js +184 -0
- package/dist/tools/categories/issues.d.ts +2 -5
- package/dist/tools/categories/issues.js +692 -390
- package/dist/tools/categories/licenses.d.ts +2 -0
- package/dist/tools/categories/licenses.js +95 -0
- package/dist/tools/categories/markdown.d.ts +2 -0
- package/dist/tools/categories/markdown.js +64 -0
- package/dist/tools/categories/meta.d.ts +2 -0
- package/dist/tools/categories/meta.js +74 -0
- package/dist/tools/categories/migrations.d.ts +2 -0
- package/dist/tools/categories/migrations.js +290 -0
- package/dist/tools/categories/orgs.d.ts +2 -5
- package/dist/tools/categories/orgs.js +585 -417
- package/dist/tools/categories/packages.d.ts +2 -0
- package/dist/tools/categories/packages.js +918 -0
- package/dist/tools/categories/projects.d.ts +2 -0
- package/dist/tools/categories/projects.js +692 -0
- package/dist/tools/categories/pulls.d.ts +2 -5
- package/dist/tools/categories/pulls.js +715 -332
- package/dist/tools/categories/rateLimit.d.ts +2 -0
- package/dist/tools/categories/rateLimit.js +22 -0
- package/dist/tools/categories/reactions.d.ts +2 -0
- package/dist/tools/categories/reactions.js +385 -0
- package/dist/tools/categories/repos.d.ts +2 -5
- package/dist/tools/categories/repos.js +844 -366
- package/dist/tools/categories/search.d.ts +2 -5
- package/dist/tools/categories/search.js +294 -196
- package/dist/tools/categories/secretScanning.d.ts +2 -0
- package/dist/tools/categories/secretScanning.js +324 -0
- package/dist/tools/categories/securityAdvisories.d.ts +2 -0
- package/dist/tools/categories/securityAdvisories.js +407 -0
- package/dist/tools/categories/teams.d.ts +2 -0
- package/dist/tools/categories/teams.js +614 -0
- package/dist/tools/categories/users.d.ts +2 -5
- package/dist/tools/categories/users.js +474 -247
- package/dist/tools/generator.d.ts +35 -15
- package/dist/tools/generator.js +113 -57
- package/dist/tools/types.d.ts +63 -0
- package/dist/tools/types.js +17 -0
- package/package.json +1 -1
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
import { Octokit } from '@octokit/rest';
|
|
2
|
-
import {
|
|
1
|
+
import type { Octokit } from '@octokit/rest';
|
|
2
|
+
import type { MCPToolDefinition, ToolResult } from './types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Tool generator that manages tool loading and execution
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
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
|
-
*
|
|
36
|
+
* Create and initialize a tool generator
|
|
37
|
+
* @param categories - Optional array of category names to load
|
|
9
38
|
*/
|
|
10
|
-
export declare function
|
|
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;
|
package/dist/tools/generator.js
CHANGED
|
@@ -1,69 +1,125 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
*
|
|
4
|
+
* All available tool categories
|
|
27
5
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
*
|
|
42
|
+
* Default categories to load if none specified
|
|
46
43
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
*
|
|
53
|
+
* Tool generator that manages tool loading and execution
|
|
52
54
|
*/
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
*
|
|
118
|
+
* Create and initialize a tool generator
|
|
119
|
+
* @param categories - Optional array of category names to load
|
|
65
120
|
*/
|
|
66
|
-
export function
|
|
67
|
-
|
|
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
|
+
}
|