@ama-mcp/github 13.3.0-prerelease.11
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/LICENSE +26 -0
- package/README.md +17 -0
- package/package.json +165 -0
- package/src/find-repositories-using-library/index.d.ts +40 -0
- package/src/find-repositories-using-library/index.d.ts.map +1 -0
- package/src/find-repositories-using-library/index.js +206 -0
- package/src/find-repositories-using-library/index.js.map +1 -0
- package/src/public_api.d.ts +4 -0
- package/src/public_api.d.ts.map +1 -0
- package/src/public_api.js +7 -0
- package/src/public_api.js.map +1 -0
- package/src/release-notes/index.d.ts +24 -0
- package/src/release-notes/index.d.ts.map +1 -0
- package/src/release-notes/index.js +92 -0
- package/src/release-notes/index.js.map +1 -0
- package/src/supported-releases/index.d.ts +20 -0
- package/src/supported-releases/index.d.ts.map +1 -0
- package/src/supported-releases/index.js +49 -0
- package/src/supported-releases/index.js.map +1 -0
- package/src/utils.d.ts +17 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +3 -0
- package/src/utils.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright Amadeus SAS
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
4
|
+
are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation and/or
|
|
11
|
+
other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software without
|
|
15
|
+
specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
21
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
23
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
24
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<h1 align="center">Otter MCP</h1>
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<br />
|
|
7
|
+
<br />
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
This module provides a set of MCP tools to retrieve information from GitHub.
|
|
12
|
+
|
|
13
|
+
## Tools
|
|
14
|
+
|
|
15
|
+
- [get_repositories_using_<library_name>](./src/find-repositories-using-library/README.md)
|
|
16
|
+
- [get_release_notes_<library_name>](./src/release-notes/README.md)
|
|
17
|
+
- [get_supported_releases_<library_name>](./src/supported-releases/README.md)
|
package/package.json
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ama-mcp/github",
|
|
3
|
+
"version": "13.3.0-prerelease.11",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "This module provides a set of MCP tools to retrieve information from GitHub",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"mcp",
|
|
10
|
+
"github",
|
|
11
|
+
"otter",
|
|
12
|
+
"otter-module"
|
|
13
|
+
],
|
|
14
|
+
"module": "src/public_api.js",
|
|
15
|
+
"typings": "src/public_api.d.ts",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": {
|
|
19
|
+
"default": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
".": {
|
|
22
|
+
"typings": "./src/public_api.d.ts",
|
|
23
|
+
"default": "./src/public_api.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"nx": "nx",
|
|
28
|
+
"ng": "yarn nx",
|
|
29
|
+
"build": "yarn nx build ama-mcp-github",
|
|
30
|
+
"compile": "tsc -b ./tsconfig.build.json && yarn cpy package.json dist && patch-package-json-main"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@ama-mcp/core": "^13.3.0-prerelease.11",
|
|
34
|
+
"@modelcontextprotocol/sdk": "~1.19.0",
|
|
35
|
+
"@octokit/rest": "^22.0.0",
|
|
36
|
+
"zod": "~3.25.76"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"tslib": "^2.6.2"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@ama-mcp/core": "^13.3.0-prerelease.11",
|
|
43
|
+
"@angular/common": "~20.3.0",
|
|
44
|
+
"@angular/compiler": "~20.3.0",
|
|
45
|
+
"@angular/compiler-cli": "~20.3.0",
|
|
46
|
+
"@angular/core": "~20.3.0",
|
|
47
|
+
"@angular/platform-browser": "~20.3.0",
|
|
48
|
+
"@angular/platform-browser-dynamic": "~20.3.0",
|
|
49
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
50
|
+
"@modelcontextprotocol/sdk": "~1.19.0",
|
|
51
|
+
"@nx/eslint": "~21.6.0",
|
|
52
|
+
"@nx/eslint-plugin": "~21.6.0",
|
|
53
|
+
"@nx/jest": "~21.6.0",
|
|
54
|
+
"@nx/js": "~21.6.0",
|
|
55
|
+
"@o3r/build-helpers": "^13.3.0-prerelease.11",
|
|
56
|
+
"@o3r/eslint-config": "^13.3.0-prerelease.11",
|
|
57
|
+
"@o3r/eslint-plugin": "^13.3.0-prerelease.11",
|
|
58
|
+
"@o3r/test-helpers": "^13.3.0-prerelease.11",
|
|
59
|
+
"@octokit/rest": "~22.0.0",
|
|
60
|
+
"@stylistic/eslint-plugin": "~5.4.0",
|
|
61
|
+
"@types/jest": "~29.5.2",
|
|
62
|
+
"@types/node": "~22.18.0",
|
|
63
|
+
"@typescript-eslint/parser": "~8.46.0",
|
|
64
|
+
"angular-eslint": "~20.3.0",
|
|
65
|
+
"cpy-cli": "^6.0.0",
|
|
66
|
+
"eslint": "~9.37.0",
|
|
67
|
+
"eslint-import-resolver-node": "~0.3.9",
|
|
68
|
+
"eslint-import-resolver-typescript": "~4.4.0",
|
|
69
|
+
"eslint-plugin-import": "~2.32.0",
|
|
70
|
+
"eslint-plugin-import-newlines": "~1.4.0",
|
|
71
|
+
"eslint-plugin-jest": "~29.0.0",
|
|
72
|
+
"eslint-plugin-jsdoc": "~54.7.0",
|
|
73
|
+
"eslint-plugin-prefer-arrow": "~1.2.3",
|
|
74
|
+
"eslint-plugin-unicorn": "~60.0.0",
|
|
75
|
+
"eslint-plugin-unused-imports": "~4.2.0",
|
|
76
|
+
"globals": "^16.0.0",
|
|
77
|
+
"jest": "~29.7.0",
|
|
78
|
+
"jest-environment-jsdom": "~29.7.0",
|
|
79
|
+
"jest-junit": "~16.0.0",
|
|
80
|
+
"jest-preset-angular": "~14.6.0",
|
|
81
|
+
"jest-util": "~29.7.0",
|
|
82
|
+
"jsonc-eslint-parser": "~2.4.0",
|
|
83
|
+
"nx": "~21.6.0",
|
|
84
|
+
"rxjs": "^7.8.1",
|
|
85
|
+
"ts-jest": "~29.4.0",
|
|
86
|
+
"ts-node": "~10.9.2",
|
|
87
|
+
"type-fest": "^4.30.1",
|
|
88
|
+
"typescript": "~5.9.2",
|
|
89
|
+
"typescript-eslint": "~8.46.0",
|
|
90
|
+
"zod": "~3.25.76",
|
|
91
|
+
"zone.js": "~0.15.0"
|
|
92
|
+
},
|
|
93
|
+
"engines": {
|
|
94
|
+
"node": "^20.19.0 || ^22.17.0 || ^24.0.0"
|
|
95
|
+
},
|
|
96
|
+
"contributors": [
|
|
97
|
+
{
|
|
98
|
+
"name": "Yannick Adam",
|
|
99
|
+
"url": "https://github.com/yannickadam",
|
|
100
|
+
"email": "yannickadam@users.noreply.github.com"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "Kilian Panot",
|
|
104
|
+
"url": "https://github.com/kpanot",
|
|
105
|
+
"email": "kpanot@users.noreply.github.com"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "Jeremy Bourgeois",
|
|
109
|
+
"url": "https://github.com/jbourgeois-1A",
|
|
110
|
+
"email": "jbourgeois-1A@users.noreply.github.com"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "Pierre Henri Ginoux",
|
|
114
|
+
"url": "https://github.com/pginoux-1A",
|
|
115
|
+
"email": "pginoux-1A@users.noreply.github.com"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "Mircea Vasile Rednic",
|
|
119
|
+
"url": "https://github.com/mrednic-1A",
|
|
120
|
+
"email": "mrednic-1A@users.noreply.github.com"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "Stephane Dalle",
|
|
124
|
+
"url": "https://github.com/sdalle-1A",
|
|
125
|
+
"email": "sdalle-1A@users.noreply.github.com"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "Nicolas Hoffmann",
|
|
129
|
+
"url": "https://github.com/nhoffmann-1A",
|
|
130
|
+
"email": "nhoffmann-1A@users.noreply.github.com"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "Victor Scaiceanu",
|
|
134
|
+
"url": "https://github.com/vscaiceanu-1a",
|
|
135
|
+
"email": "vscaiceanu-1A@users.noreply.github.com"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "Florian Paul",
|
|
139
|
+
"url": "https://github.com/fpaul-1A",
|
|
140
|
+
"email": "fpaul-1A@users.noreply.github.com"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "Corinne Paulve",
|
|
144
|
+
"url": "https://github.com/cpaulve-1A",
|
|
145
|
+
"email": "cpaulve-1A@users.noreply.github.com"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"name": "Matthieu Crouzet",
|
|
149
|
+
"url": "https://github.com/matthieu-crouzet",
|
|
150
|
+
"email": "matthieu-crouzet@users.noreply.github.com"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "Salome Do",
|
|
154
|
+
"url": "https://github.com/sdo-1A",
|
|
155
|
+
"email": "sdo-1A@users.noreply.github.com"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"bugs": "https://github.com/AmadeusITGroup/otter/issues",
|
|
159
|
+
"repository": {
|
|
160
|
+
"type": "git",
|
|
161
|
+
"url": "git+https://github.com/AmadeusITGroup/otter.git"
|
|
162
|
+
},
|
|
163
|
+
"license": "BSD-3-Clause",
|
|
164
|
+
"homepage": "https://amadeusitgroup.github.io/otter/"
|
|
165
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Logger, type ToolDefinition } from '@ama-mcp/core';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import type { GithubToolOptions } from '../utils';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the tool get_repositories_using_library
|
|
6
|
+
*/
|
|
7
|
+
export interface GetRepositoriesUsingLibraryOptions extends GithubToolOptions, ToolDefinition {
|
|
8
|
+
/**
|
|
9
|
+
* Scopes to look for when searching for repositories
|
|
10
|
+
* (e.g. for @ama-mcp/github, the scope is ama-mcp)
|
|
11
|
+
* Limit to 10 scopes to avoid hitting GitHub search API rate limit
|
|
12
|
+
* @example ['ama-mcp', 'o3r']
|
|
13
|
+
*/
|
|
14
|
+
scopes: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Name of the library to look for in the dependencies
|
|
17
|
+
* @example 'Otter'
|
|
18
|
+
*/
|
|
19
|
+
libraryName: string;
|
|
20
|
+
/**
|
|
21
|
+
* Path to cache the results
|
|
22
|
+
*/
|
|
23
|
+
cachePath?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to use the cached results if available
|
|
26
|
+
*/
|
|
27
|
+
disableCache?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum age in days of the cache for a repository to be considered valid
|
|
30
|
+
*/
|
|
31
|
+
cacheMaxAge?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register the tool to get repositories using a configured library.
|
|
35
|
+
* @param server
|
|
36
|
+
* @param options
|
|
37
|
+
* @param logger
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerGetRepositoriesUsingLibraryTool(server: McpServer, options: GetRepositoriesUsingLibraryOptions, logger?: Logger): void;
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/find-repositories-using-library/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,SAAS,EACV,MAAM,yCAAyC,CAAC;AAOjD,OAAO,KAAK,EACV,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,kCAAmC,SAAQ,iBAAiB,EAAE,cAAc;IAC3F;;;;;OAKG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA+KD;;;;;GAKG;AACH,wBAAgB,uCAAuC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,kCAAkC,EAAE,MAAM,CAAC,EAAE,MAAM,QAoDtI"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGetRepositoriesUsingLibraryTool = registerGetRepositoriesUsingLibraryTool;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const core_1 = require("@ama-mcp/core");
|
|
8
|
+
const rest_1 = require("@octokit/rest");
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
async function listRepos(octokit, options, logger) {
|
|
11
|
+
// We use several requests and not only one with OR
|
|
12
|
+
// because GitHub search API has some limitations in the query length and complexity
|
|
13
|
+
// Note: We can do only 10 searches per minute,
|
|
14
|
+
// so we should found another solution if we have more than 10 scopes to look for.
|
|
15
|
+
const search = (await Promise.allSettled(options.scopes
|
|
16
|
+
.map(async (scope) => {
|
|
17
|
+
const repos = (await octokit.paginate(octokit.search.code, { q: `@${scope}/ filename:package.json`, per_page: 100 }))
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Naming convention from GitHub API
|
|
19
|
+
.map(({ repository: { name, full_name, fork, archived, default_branch } }) => ({ name, full_name, fork, archived, default_branch }))
|
|
20
|
+
.filter((repo) => !repo.archived && !repo.fork);
|
|
21
|
+
logger?.info?.(`Found ${repos.length} repositories with references to @${scope} in package.json`);
|
|
22
|
+
return repos;
|
|
23
|
+
}))).filter((result) => result.status === 'fulfilled')
|
|
24
|
+
.flatMap((result) => result.value);
|
|
25
|
+
// Deduplicate repositories in case of multiple scopes matching the same repository
|
|
26
|
+
const repositories = Array.from(new Map(search.map((repo) => [repo.full_name, repo])).values());
|
|
27
|
+
logger?.info?.(`Found ${repositories.length} repositories with references to ${options.libraryName}`);
|
|
28
|
+
return repositories;
|
|
29
|
+
}
|
|
30
|
+
function findPackageJsonFiles(octokit) {
|
|
31
|
+
return async (repository) => {
|
|
32
|
+
const [owner, repo] = repository.full_name.split('/');
|
|
33
|
+
const { data: { commit: { sha } } } = await octokit.repos.getBranch({
|
|
34
|
+
owner,
|
|
35
|
+
repo,
|
|
36
|
+
branch: repository.default_branch || 'main'
|
|
37
|
+
});
|
|
38
|
+
const { data: { tree } } = await octokit.git.getTree({
|
|
39
|
+
owner,
|
|
40
|
+
repo,
|
|
41
|
+
tree_sha: sha
|
|
42
|
+
});
|
|
43
|
+
return tree.filter((t) => t.type === 'blob' && t.path.endsWith('package.json'));
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function dependsOnLibrary(octokit, options) {
|
|
47
|
+
return async (repository, packageJsonPath) => {
|
|
48
|
+
const [owner, repo] = repository.full_name.split('/');
|
|
49
|
+
const { data } = await octokit.repos.getContent({
|
|
50
|
+
owner,
|
|
51
|
+
repo,
|
|
52
|
+
path: packageJsonPath
|
|
53
|
+
});
|
|
54
|
+
if (Array.isArray(data) || data.type !== 'file' || data.encoding !== 'base64') {
|
|
55
|
+
throw new Error('Unexpected content response structure');
|
|
56
|
+
}
|
|
57
|
+
const content = Buffer.from(data.content, 'base64').toString('utf8');
|
|
58
|
+
const packageJson = JSON.parse(content);
|
|
59
|
+
const scopeRegex = new RegExp(`^@(?:${options.scopes.join('|')})/`);
|
|
60
|
+
return [
|
|
61
|
+
...Object.keys(packageJson.devDependencies || {}),
|
|
62
|
+
...Object.keys(packageJson.dependencies || {})
|
|
63
|
+
].some((dep) => scopeRegex.test(dep));
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const DEFAULT_AMA_MCP_CACHE_MAX_AGE = 90;
|
|
67
|
+
const convertDaysToMs = (days) => days * 1000 * 60 * 60 * 24;
|
|
68
|
+
function validateCache(cachedRepos, options, logger) {
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
const maxAge = convertDaysToMs(options.cacheMaxAge || DEFAULT_AMA_MCP_CACHE_MAX_AGE);
|
|
71
|
+
Object.entries(cachedRepos).forEach(([repo, { when }]) => {
|
|
72
|
+
const whenDate = new Date(when);
|
|
73
|
+
if (Number.isNaN(whenDate.getTime()) || (now - whenDate.getTime()) > maxAge) {
|
|
74
|
+
logger.info?.(`Cache for repository ${repo} is outdated or invalid, removing it`);
|
|
75
|
+
delete cachedRepos[repo];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async function findRepositoriesUsingLibrary(octokit, reposUsingLibrary, options, logger = core_1.logger) {
|
|
80
|
+
const { cachePath = (0, node_path_1.resolve)('.cache', '@ama-mcp', `repos-using-${options.libraryName.toLowerCase().replaceAll(/\s+/g, '-')}.json`), disableCache = false } = options;
|
|
81
|
+
let cachedRepos = {};
|
|
82
|
+
if (disableCache) {
|
|
83
|
+
logger?.info?.('Ignoring cached repositories as caching is disabled');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
try {
|
|
87
|
+
cachedRepos = JSON.parse(await (0, promises_1.readFile)(cachePath, { encoding: 'utf8' }));
|
|
88
|
+
validateCache(cachedRepos, options, logger);
|
|
89
|
+
reposUsingLibrary.push(...Object.entries(cachedRepos).filter(([, usesLibrary]) => usesLibrary).map(([repo]) => repo));
|
|
90
|
+
logger?.info?.(`Loaded ${Object.keys(cachedRepos).length} cached repositories, ${reposUsingLibrary.length} of them using ${options.libraryName} dependencies.`);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
logger?.info?.(`No cache file found, starting fresh search for repositories using ${options.libraryName} dependencies.`, e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const repositories = (await listRepos(octokit, options)).filter((r) => !cachedRepos[r.full_name]?.dependsOn);
|
|
97
|
+
const findPackageJsonFilesInRepo = findPackageJsonFiles(octokit);
|
|
98
|
+
const dependsOnLibraryInRepo = dependsOnLibrary(octokit, options);
|
|
99
|
+
await Promise.allSettled(repositories.map(async (repository) => {
|
|
100
|
+
logger?.debug?.(`Checking repository ${repository.full_name}...`);
|
|
101
|
+
const packageJsonFiles = [];
|
|
102
|
+
try {
|
|
103
|
+
packageJsonFiles.push(...await findPackageJsonFilesInRepo(repository));
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
logger?.warn?.(`Failed to list package.json files in repository ${repository.full_name}`, e);
|
|
107
|
+
}
|
|
108
|
+
if (packageJsonFiles.length === 0) {
|
|
109
|
+
logger?.info?.(`No package.json files found in repository ${repository.full_name}`);
|
|
110
|
+
cachedRepos[repository.full_name] = {
|
|
111
|
+
dependsOn: false,
|
|
112
|
+
when: new Date().toISOString()
|
|
113
|
+
};
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
await Promise.any(packageJsonFiles.map(async (packageJsonFile) => {
|
|
118
|
+
let depFound = false;
|
|
119
|
+
try {
|
|
120
|
+
depFound = await dependsOnLibraryInRepo(repository, packageJsonFile.path);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
logger?.error?.(`Failed to check package.json file at ${packageJsonFile.path} in repository ${repository.full_name}`, e);
|
|
124
|
+
}
|
|
125
|
+
if (depFound) {
|
|
126
|
+
reposUsingLibrary.push(repository.full_name);
|
|
127
|
+
logger?.info?.(`Repository ${repository.full_name} uses ${options.libraryName} dependencies`);
|
|
128
|
+
cachedRepos[repository.full_name] = {
|
|
129
|
+
dependsOn: true,
|
|
130
|
+
when: new Date().toISOString()
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
throw new Error(`No ${options.libraryName} dependencies found in this package.json`);
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
catch { }
|
|
139
|
+
cachedRepos[repository.full_name] ||= {
|
|
140
|
+
dependsOn: false,
|
|
141
|
+
when: new Date().toISOString()
|
|
142
|
+
};
|
|
143
|
+
}));
|
|
144
|
+
logger?.info?.(`Found ${reposUsingLibrary.length} repositories using ${options.libraryName} dependencies`);
|
|
145
|
+
if (disableCache) {
|
|
146
|
+
logger?.info?.('Not updating cache as caching is disabled');
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const cacheFolderPath = (0, node_path_1.dirname)(cachePath);
|
|
150
|
+
if (!(0, node_fs_1.existsSync)((0, node_path_1.dirname)(cacheFolderPath))) {
|
|
151
|
+
await (0, promises_1.mkdir)(cacheFolderPath, { recursive: true });
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
await (0, promises_1.writeFile)(cachePath, JSON.stringify(cachedRepos));
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
logger?.error?.('Failed to update cache', e);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Register the tool to get repositories using a configured library.
|
|
163
|
+
* @param server
|
|
164
|
+
* @param options
|
|
165
|
+
* @param logger
|
|
166
|
+
*/
|
|
167
|
+
function registerGetRepositoriesUsingLibraryTool(server, options, logger) {
|
|
168
|
+
const { githubToken, libraryName, toolName = `get_repositories_using_${options.libraryName.toLowerCase().replaceAll(/\s+/g, '_')}`, toolTitle = `Get repositories using ${options.libraryName} dependencies`, toolDescription = `List all repositories that use ${options.libraryName} dependencies (${options.scopes.map((scope) => `@${scope}`).join(' or ')}) in their package.json files.` } = options;
|
|
169
|
+
if (!githubToken) {
|
|
170
|
+
logger?.error?.(`Missing githubToken for ${toolName}`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const octokit = new rest_1.Octokit({ auth: githubToken });
|
|
174
|
+
let isLookingForRepos = true;
|
|
175
|
+
const reposUsingLibrary = [];
|
|
176
|
+
findRepositoriesUsingLibrary(octokit, reposUsingLibrary, options).catch((e) => {
|
|
177
|
+
logger?.error?.(`Error finding repositories using ${libraryName}:`, e);
|
|
178
|
+
});
|
|
179
|
+
isLookingForRepos = false;
|
|
180
|
+
server.registerTool(toolName, {
|
|
181
|
+
title: toolTitle,
|
|
182
|
+
description: toolDescription,
|
|
183
|
+
annotations: {
|
|
184
|
+
readOnlyHint: true,
|
|
185
|
+
openWorldHint: false
|
|
186
|
+
},
|
|
187
|
+
outputSchema: {
|
|
188
|
+
repositories: zod_1.z.array(zod_1.z.string()).describe(`List of repositories depending on ${libraryName}`)
|
|
189
|
+
}
|
|
190
|
+
}, () => ({
|
|
191
|
+
content: [
|
|
192
|
+
{
|
|
193
|
+
type: 'text',
|
|
194
|
+
text: (isLookingForRepos ? 'I did not finish to look for repositories. For the moment:\n' : '')
|
|
195
|
+
+ reposUsingLibrary.length
|
|
196
|
+
? `The following repositories use ${libraryName} dependencies:\n`
|
|
197
|
+
+ reposUsingLibrary.sort().map((repo) => `- ${repo}`).join('\n')
|
|
198
|
+
: `No repositories found using ${libraryName} dependencies.`
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
structuredContent: {
|
|
202
|
+
repositories: reposUsingLibrary
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/find-repositories-using-library/index.ts"],"names":[],"mappings":";;AA+OA,0FAoDC;AAnSD,qCAEiB;AACjB,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CAAC,CAAC,EAAE,CAAC;sBAC3F,iBAAiB,CAAC,MAAM;oBAC1B,CAAC,CAAC,kCAAkC,WAAW,kBAAkB;0BAC/D,iBAAiB,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;oBAChE,CAAC,CAAC,+BAA+B,WAAW,gBAAgB;aAC/D;SACF;QACD,iBAAiB,EAAE;YACjB,YAAY,EAAE,iBAAiB;SAChC;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_api.d.ts","sourceRoot":"","sources":["../../src/public_api.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./find-repositories-using-library/index"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./release-notes/index"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./supported-releases/index"), exports);
|
|
7
|
+
//# sourceMappingURL=public_api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_api.js","sourceRoot":"","sources":["../../src/public_api.ts"],"names":[],"mappings":";;;AAAA,kFAAwD;AACxD,gEAAsC;AACtC,qEAA2C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Logger, ToolDefinition } from '@ama-mcp/core';
|
|
2
|
+
import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import type { GitHubRepositoryToolOptions } from '../utils';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the tool to get release notes
|
|
6
|
+
*/
|
|
7
|
+
export interface ReleaseNotesToolOptions extends GitHubRepositoryToolOptions, ToolDefinition {
|
|
8
|
+
/**
|
|
9
|
+
* Optional library name
|
|
10
|
+
*/
|
|
11
|
+
libraryName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* URI prefix for the resources
|
|
14
|
+
*/
|
|
15
|
+
uriPrefix?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Register the release notes tool and resources.
|
|
19
|
+
* @param server
|
|
20
|
+
* @param options
|
|
21
|
+
* @param logger
|
|
22
|
+
*/
|
|
23
|
+
export declare function registerReleaseNotes(server: McpServer, options: ReleaseNotesToolOptions, logger?: Logger): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/release-notes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAEX,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,yCAAyC,CAAC;AAQjD,OAAO,KAAK,EACV,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,2BAA2B,EAAE,cAAc;IAC1F;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgGD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,GAAE,MAAsB,iBAe7H"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerReleaseNotes = registerReleaseNotes;
|
|
4
|
+
const core_1 = require("@ama-mcp/core");
|
|
5
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
6
|
+
const rest_1 = require("@octokit/rest");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const getDefaultUriPrefix = (options) => options.libraryName || options.repo;
|
|
9
|
+
const getUri = (uriPrefix, tagName) => `${uriPrefix}://release-notes/${tagName}`;
|
|
10
|
+
const formatContent = (releaseNote) => `# ${releaseNote.tag_name}\n\n${releaseNote.body}`;
|
|
11
|
+
async function getReleaseNotes(octokit, options) {
|
|
12
|
+
const { owner, repo, uriPrefix = getDefaultUriPrefix(options) } = options;
|
|
13
|
+
const minorsReleaseNotes = (await octokit.paginate(octokit.repos.listReleases, { owner, repo }))
|
|
14
|
+
.filter((release) => /^v\d+\.\d+\.0$/.test(release.tag_name));
|
|
15
|
+
const releaseNotes = new Map(minorsReleaseNotes.map((releaseNote) => [releaseNote.tag_name, releaseNote]));
|
|
16
|
+
releaseNotes.forEach((value) => core_1.resourceRegistry.set(getUri(uriPrefix, value.tag_name), formatContent(value)));
|
|
17
|
+
return releaseNotes;
|
|
18
|
+
}
|
|
19
|
+
function registerReleaseNotesResources(server, releaseNotes, options) {
|
|
20
|
+
const { libraryName = `${options.owner}/${options.repo}`, uriPrefix = getDefaultUriPrefix(options) } = options;
|
|
21
|
+
server.registerResource(`${libraryName} release notes`, new mcp_js_1.ResourceTemplate(getUri(uriPrefix, '{tagName}'), {
|
|
22
|
+
list: undefined,
|
|
23
|
+
complete: {
|
|
24
|
+
tagName: (value) => {
|
|
25
|
+
const tagNames = Array.from(releaseNotes.keys());
|
|
26
|
+
return tagNames.filter((tagName) => tagName.startsWith(value));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}), {
|
|
30
|
+
description: `${libraryName}'s release notes`,
|
|
31
|
+
mimeType: 'text/markdown'
|
|
32
|
+
}, (uri, { tagName }) => ({
|
|
33
|
+
contents: (Array.isArray(tagName) ? tagName : [tagName])
|
|
34
|
+
.filter((tag) => !!releaseNotes.get(tag))
|
|
35
|
+
.map((tag) => ({
|
|
36
|
+
uri: uri.href,
|
|
37
|
+
text: core_1.resourceRegistry.get(getUri(uriPrefix, tag)),
|
|
38
|
+
mimeType: 'text/markdown'
|
|
39
|
+
}))
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
function registerReleaseNotesTool(server, releaseNotes, options) {
|
|
43
|
+
const libraryName = options.libraryName || `${options.owner}/${options.repo}`;
|
|
44
|
+
const { toolName = `get_release_notes_${libraryName.toLowerCase().replaceAll(/\s+/g, '_')}`, toolDescription = `Get the release notes for the ${libraryName} releases`, toolTitle = `Get ${libraryName} release notes`, uriPrefix = getDefaultUriPrefix(options) } = options;
|
|
45
|
+
server.registerTool(toolName, {
|
|
46
|
+
title: toolTitle,
|
|
47
|
+
description: toolDescription,
|
|
48
|
+
annotations: {
|
|
49
|
+
readOnlyHint: true,
|
|
50
|
+
openWorldHint: false
|
|
51
|
+
},
|
|
52
|
+
inputSchema: {
|
|
53
|
+
version: zod_1.z.string().optional()
|
|
54
|
+
.describe('The version of the release notes to get, if not provided all release notes will be returned. Format to use is vX.Y.0, e.g. v13.1.0')
|
|
55
|
+
}
|
|
56
|
+
}, ({ version }) => {
|
|
57
|
+
const targetedReleaseNote = version && releaseNotes.get(version);
|
|
58
|
+
return {
|
|
59
|
+
content: (targetedReleaseNote ? [targetedReleaseNote] : Array.from(releaseNotes.values()))
|
|
60
|
+
.flatMap((releaseNote) => {
|
|
61
|
+
const uri = getUri(uriPrefix, releaseNote.tag_name);
|
|
62
|
+
return [{
|
|
63
|
+
type: 'text',
|
|
64
|
+
text: core_1.resourceRegistry.get(uri) || 'Not found'
|
|
65
|
+
}, {
|
|
66
|
+
type: 'resource_link',
|
|
67
|
+
name: `Release note ${releaseNote.tag_name}`,
|
|
68
|
+
uri
|
|
69
|
+
}];
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Register the release notes tool and resources.
|
|
76
|
+
* @param server
|
|
77
|
+
* @param options
|
|
78
|
+
* @param logger
|
|
79
|
+
*/
|
|
80
|
+
async function registerReleaseNotes(server, options, logger = core_1.logger) {
|
|
81
|
+
const { githubToken, libraryName = `${options.owner}/${options.repo}` } = options;
|
|
82
|
+
if (!githubToken) {
|
|
83
|
+
logger.error?.(`Missing githubToken for release notes tool and resources for ${libraryName}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const octokit = new rest_1.Octokit({ auth: githubToken });
|
|
87
|
+
const releaseNotes = await getReleaseNotes(octokit, options);
|
|
88
|
+
logger.info?.(`Found ${releaseNotes.size} release notes for ${libraryName}`, releaseNotes);
|
|
89
|
+
registerReleaseNotesResources(server, releaseNotes, options);
|
|
90
|
+
registerReleaseNotesTool(server, releaseNotes, options);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/release-notes/index.ts"],"names":[],"mappings":";;AAwIA,oDAeC;AAvJD,wCAKuB;AACvB,oEAGiD;AACjD,wCAGuB;AACvB,6BAEa;AAoBb,MAAM,mBAAmB,GAAG,CAAC,OAAgC,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;AACtG,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CAAC,GAAG,SAAS,oBAAoB,OAAO,EAAE,CAAC;AACjG,MAAM,aAAa,GAAG,CAAC,WAAoF,EAAE,EAAE,CAAC,KAAK,WAAW,CAAC,QAAQ,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;AAEnK,KAAK,UAAU,eAAe,CAAC,OAAgB,EAAE,OAAgC;IAC/E,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,mBAAmB,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC;IAC1E,MAAM,kBAAkB,GAAG,CAAC,MAAM,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,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7D,MAAM,CAAC,IAAI,EAAE,CAAC,SAAS,YAAY,CAAC,IAAI,sBAAsB,WAAW,EAAE,EAAE,YAAY,CAAC,CAAC;IAC3F,6BAA6B,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAC7D,wBAAwB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Logger, type ToolDefinition } from '@ama-mcp/core';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import type { GitHubRepositoryToolOptions } from '../utils';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the tool to get supported releases
|
|
6
|
+
*/
|
|
7
|
+
export interface SupportedReleasesOptions extends ToolDefinition, GitHubRepositoryToolOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Optional library name
|
|
10
|
+
*/
|
|
11
|
+
libraryName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Register the supported releases tool.
|
|
15
|
+
* @param server
|
|
16
|
+
* @param options
|
|
17
|
+
* @param logger
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerSupportedReleasesTool(server: McpServer, options: SupportedReleasesOptions, logger?: Logger): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/supported-releases/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,SAAS,EACV,MAAM,yCAAyC,CAAC;AAOjD,OAAO,KAAK,EACV,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,cAAc,EAAE,2BAA2B;IAC3F;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD;;;;;GAKG;AACH,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCvJ"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSupportedReleasesTool = registerSupportedReleasesTool;
|
|
4
|
+
const core_1 = require("@ama-mcp/core");
|
|
5
|
+
const rest_1 = require("@octokit/rest");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
async function getSupportedReleases(octokit, options, logger) {
|
|
8
|
+
const { owner, repo } = options;
|
|
9
|
+
const supportedReleases = (await octokit.paginate(octokit.repos.listBranches, { owner, repo }))
|
|
10
|
+
.filter((branch) => /^release\/\d+\.\d+$/.test(branch.name))
|
|
11
|
+
.map((branch) => branch.name.replace('release/', ''));
|
|
12
|
+
logger.info?.(`Supported releases:\n${supportedReleases.map((r) => ` - ${r}`).join('\n')}`);
|
|
13
|
+
return supportedReleases;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Register the supported releases tool.
|
|
17
|
+
* @param server
|
|
18
|
+
* @param options
|
|
19
|
+
* @param logger
|
|
20
|
+
*/
|
|
21
|
+
async function registerSupportedReleasesTool(server, options, logger = core_1.logger) {
|
|
22
|
+
const { githubToken, libraryName = `${options.owner}/${options.repo}`, toolName = `get_supported_releases_${libraryName.toLowerCase().replaceAll(/\s+/g, '_')}`, toolDescription = `Get the list of supported releases for ${libraryName}`, toolTitle = `Get Supported Releases for ${libraryName}` } = options;
|
|
23
|
+
if (!githubToken) {
|
|
24
|
+
logger.error?.(`Missing githubToken for ${toolName}`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const octokit = new rest_1.Octokit({ auth: githubToken });
|
|
28
|
+
const supportedReleases = await getSupportedReleases(octokit, options, logger);
|
|
29
|
+
server.registerTool(toolName, {
|
|
30
|
+
title: toolTitle,
|
|
31
|
+
description: toolDescription,
|
|
32
|
+
outputSchema: {
|
|
33
|
+
releases: zod_1.z.array(zod_1.z.string()).describe('List of supported releases')
|
|
34
|
+
}
|
|
35
|
+
}, () => {
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: `The supported releases for ${libraryName} are: \n${supportedReleases.map((r) => ` - ${r}`).join('\n')}`
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
structuredContent: {
|
|
44
|
+
releases: supportedReleases
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/supported-releases/index.ts"],"names":[],"mappings":";;AA4CA,sEAuCC;AAnFD,wCAIuB;AAIvB,wCAEuB;AACvB,6BAEa;AAeb,KAAK,UAAU,oBAAoB,CAAC,OAAgB,EAAE,OAAiC,EAAE,MAAc;IACrG,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,iBAAiB,GAAG,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;SAC5F,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3D,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CA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E,8BAA8B,WAAW,WAAW,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;iBAChH;aACF;YACD,iBAAiB,EAAE;gBACjB,QAAQ,EAAE,iBAAiB;aAC5B;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface GithubToolOptions {
|
|
2
|
+
/**
|
|
3
|
+
* GitHub authentication token
|
|
4
|
+
*/
|
|
5
|
+
githubToken: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GitHubRepositoryToolOptions extends GithubToolOptions {
|
|
8
|
+
/**
|
|
9
|
+
* GitHub repository owner
|
|
10
|
+
*/
|
|
11
|
+
owner: string;
|
|
12
|
+
/**
|
|
13
|
+
* GitHub repository name
|
|
14
|
+
*/
|
|
15
|
+
repo: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/src/utils.js
ADDED
package/src/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":""}
|