@rushstack/mcp-server 0.3.14 → 0.4.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.
- package/CHANGELOG.json +52 -0
- package/CHANGELOG.md +15 -1
- package/bin/mcp-server +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-esm/index.js +5 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/pluginFramework/IRushMcpPlugin.js +4 -0
- package/lib-esm/pluginFramework/IRushMcpPlugin.js.map +1 -0
- package/lib-esm/pluginFramework/IRushMcpTool.js +4 -0
- package/lib-esm/pluginFramework/IRushMcpTool.js.map +1 -0
- package/lib-esm/pluginFramework/RushMcpPluginLoader.js +97 -0
- package/lib-esm/pluginFramework/RushMcpPluginLoader.js.map +1 -0
- package/lib-esm/pluginFramework/RushMcpPluginSession.js +28 -0
- package/lib-esm/pluginFramework/RushMcpPluginSession.js.map +1 -0
- package/lib-esm/pluginFramework/zodTypes.js +5 -0
- package/lib-esm/pluginFramework/zodTypes.js.map +1 -0
- package/lib-esm/schemas/rush-mcp-plugin.schema.json +21 -0
- package/lib-esm/schemas/rush-mcp.schema.json +28 -0
- package/lib-esm/server.js +35 -0
- package/lib-esm/server.js.map +1 -0
- package/lib-esm/start.js +33 -0
- package/lib-esm/start.js.map +1 -0
- package/lib-esm/tools/base.tool.js +29 -0
- package/lib-esm/tools/base.tool.js.map +1 -0
- package/lib-esm/tools/conflict-resolver.tool.js +48 -0
- package/lib-esm/tools/conflict-resolver.tool.js.map +1 -0
- package/lib-esm/tools/index.js +9 -0
- package/lib-esm/tools/index.js.map +1 -0
- package/lib-esm/tools/migrate-project.tool.js +93 -0
- package/lib-esm/tools/migrate-project.tool.js.map +1 -0
- package/lib-esm/tools/project-details.tool.js +50 -0
- package/lib-esm/tools/project-details.tool.js.map +1 -0
- package/lib-esm/tools/rush-command-validator.tool.js +81 -0
- package/lib-esm/tools/rush-command-validator.tool.js.map +1 -0
- package/lib-esm/tools/workspace-details.js +103 -0
- package/lib-esm/tools/workspace-details.js.map +1 -0
- package/lib-esm/utilities/command-runner.js +69 -0
- package/lib-esm/utilities/command-runner.js.map +1 -0
- package/lib-esm/utilities/common.js +10 -0
- package/lib-esm/utilities/common.js.map +1 -0
- package/lib-esm/utilities/log.js +8 -0
- package/lib-esm/utilities/log.js.map +1 -0
- package/package.json +36 -8
- /package/{lib → lib-commonjs}/index.js +0 -0
- /package/{lib → lib-commonjs}/index.js.map +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/IRushMcpPlugin.js +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/IRushMcpPlugin.js.map +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/IRushMcpTool.js +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/IRushMcpTool.js.map +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/RushMcpPluginLoader.js +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/RushMcpPluginLoader.js.map +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/RushMcpPluginSession.js +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/RushMcpPluginSession.js.map +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/zodTypes.js +0 -0
- /package/{lib → lib-commonjs}/pluginFramework/zodTypes.js.map +0 -0
- /package/{lib → lib-commonjs}/schemas/rush-mcp-plugin.schema.json +0 -0
- /package/{lib → lib-commonjs}/schemas/rush-mcp.schema.json +0 -0
- /package/{lib → lib-commonjs}/server.js +0 -0
- /package/{lib → lib-commonjs}/server.js.map +0 -0
- /package/{lib → lib-commonjs}/start.js +0 -0
- /package/{lib → lib-commonjs}/start.js.map +0 -0
- /package/{lib → lib-commonjs}/tools/base.tool.js +0 -0
- /package/{lib → lib-commonjs}/tools/base.tool.js.map +0 -0
- /package/{lib → lib-commonjs}/tools/conflict-resolver.tool.js +0 -0
- /package/{lib → lib-commonjs}/tools/conflict-resolver.tool.js.map +0 -0
- /package/{lib → lib-commonjs}/tools/index.js +0 -0
- /package/{lib → lib-commonjs}/tools/index.js.map +0 -0
- /package/{lib → lib-commonjs}/tools/migrate-project.tool.js +0 -0
- /package/{lib → lib-commonjs}/tools/migrate-project.tool.js.map +0 -0
- /package/{lib → lib-commonjs}/tools/project-details.tool.js +0 -0
- /package/{lib → lib-commonjs}/tools/project-details.tool.js.map +0 -0
- /package/{lib → lib-commonjs}/tools/rush-command-validator.tool.js +0 -0
- /package/{lib → lib-commonjs}/tools/rush-command-validator.tool.js.map +0 -0
- /package/{lib → lib-commonjs}/tools/workspace-details.js +0 -0
- /package/{lib → lib-commonjs}/tools/workspace-details.js.map +0 -0
- /package/{lib → lib-commonjs}/utilities/command-runner.js +0 -0
- /package/{lib → lib-commonjs}/utilities/command-runner.js.map +0 -0
- /package/{lib → lib-commonjs}/utilities/common.js +0 -0
- /package/{lib → lib-commonjs}/utilities/common.js.map +0 -0
- /package/{lib → lib-commonjs}/utilities/log.js +0 -0
- /package/{lib → lib-commonjs}/utilities/log.js.map +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts.map +0 -0
- /package/{lib → lib-dts}/pluginFramework/IRushMcpPlugin.d.ts +0 -0
- /package/{lib → lib-dts}/pluginFramework/IRushMcpPlugin.d.ts.map +0 -0
- /package/{lib → lib-dts}/pluginFramework/IRushMcpTool.d.ts +0 -0
- /package/{lib → lib-dts}/pluginFramework/IRushMcpTool.d.ts.map +0 -0
- /package/{lib → lib-dts}/pluginFramework/RushMcpPluginLoader.d.ts +0 -0
- /package/{lib → lib-dts}/pluginFramework/RushMcpPluginLoader.d.ts.map +0 -0
- /package/{lib → lib-dts}/pluginFramework/RushMcpPluginSession.d.ts +0 -0
- /package/{lib → lib-dts}/pluginFramework/RushMcpPluginSession.d.ts.map +0 -0
- /package/{lib → lib-dts}/pluginFramework/zodTypes.d.ts +0 -0
- /package/{lib → lib-dts}/pluginFramework/zodTypes.d.ts.map +0 -0
- /package/{lib → lib-dts}/server.d.ts +0 -0
- /package/{lib → lib-dts}/server.d.ts.map +0 -0
- /package/{lib → lib-dts}/start.d.ts +0 -0
- /package/{lib → lib-dts}/start.d.ts.map +0 -0
- /package/{lib → lib-dts}/tools/base.tool.d.ts +0 -0
- /package/{lib → lib-dts}/tools/base.tool.d.ts.map +0 -0
- /package/{lib → lib-dts}/tools/conflict-resolver.tool.d.ts +0 -0
- /package/{lib → lib-dts}/tools/conflict-resolver.tool.d.ts.map +0 -0
- /package/{lib → lib-dts}/tools/index.d.ts +0 -0
- /package/{lib → lib-dts}/tools/index.d.ts.map +0 -0
- /package/{lib → lib-dts}/tools/migrate-project.tool.d.ts +0 -0
- /package/{lib → lib-dts}/tools/migrate-project.tool.d.ts.map +0 -0
- /package/{lib → lib-dts}/tools/project-details.tool.d.ts +0 -0
- /package/{lib → lib-dts}/tools/project-details.tool.d.ts.map +0 -0
- /package/{lib → lib-dts}/tools/rush-command-validator.tool.d.ts +0 -0
- /package/{lib → lib-dts}/tools/rush-command-validator.tool.d.ts.map +0 -0
- /package/{lib → lib-dts}/tools/workspace-details.d.ts +0 -0
- /package/{lib → lib-dts}/tools/workspace-details.d.ts.map +0 -0
- /package/{lib → lib-dts}/utilities/command-runner.d.ts +0 -0
- /package/{lib → lib-dts}/utilities/command-runner.d.ts.map +0 -0
- /package/{lib → lib-dts}/utilities/common.d.ts +0 -0
- /package/{lib → lib-dts}/utilities/common.d.ts.map +0 -0
- /package/{lib → lib-dts}/utilities/log.d.ts +0 -0
- /package/{lib → lib-dts}/utilities/log.d.ts.map +0 -0
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/mcp-server",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.4.1",
|
|
6
|
+
"tag": "@rushstack/mcp-server_v0.4.1",
|
|
7
|
+
"date": "Fri, 20 Feb 2026 00:15:04 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/node-core-library\" to `5.20.1`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@rushstack/terminal\" to `0.22.1`"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"comment": "Updating dependency \"@rushstack/ts-command-line\" to `5.3.1`"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.2.1`"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"version": "0.4.0",
|
|
32
|
+
"tag": "@rushstack/mcp-server_v0.4.0",
|
|
33
|
+
"date": "Thu, 19 Feb 2026 00:04:53 GMT",
|
|
34
|
+
"comments": {
|
|
35
|
+
"minor": [
|
|
36
|
+
{
|
|
37
|
+
"comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"dependency": [
|
|
41
|
+
{
|
|
42
|
+
"comment": "Updating dependency \"@rushstack/node-core-library\" to `5.20.0`"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"comment": "Updating dependency \"@rushstack/terminal\" to `0.22.0`"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"comment": "Updating dependency \"@rushstack/ts-command-line\" to `5.3.0`"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.2.0`"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
4
56
|
{
|
|
5
57
|
"version": "0.3.14",
|
|
6
58
|
"tag": "@rushstack/mcp-server_v0.3.14",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @rushstack/mcp-server
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 20 Feb 2026 00:15:04 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.4.1
|
|
6
|
+
Fri, 20 Feb 2026 00:15:04 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Add `"node"` condition before `"import"` in the `"exports"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `"import"`. Fixes https://github.com/microsoft/rushstack/issues/5644.
|
|
11
|
+
|
|
12
|
+
## 0.4.0
|
|
13
|
+
Thu, 19 Feb 2026 00:04:53 GMT
|
|
14
|
+
|
|
15
|
+
### Minor changes
|
|
16
|
+
|
|
17
|
+
- Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
|
|
4
18
|
|
|
5
19
|
## 0.3.14
|
|
6
20
|
Sat, 07 Feb 2026 01:13:26 GMT
|
package/bin/mcp-server
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('../lib/start.js');
|
|
2
|
+
require('../lib-commonjs/start.js');
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib-esm/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
export { RushMcpPluginSession } from './pluginFramework/RushMcpPluginSession';
|
|
4
|
+
export { CallToolResultSchema } from './pluginFramework/zodTypes';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAS3D,OAAO,EAA6B,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AACzG,OAAO,EAAE,oBAAoB,EAAuC,MAAM,4BAA4B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * API for use by MCP plugins.\n * @packageDocumentation\n */\n\nexport { type IRushMcpPlugin, type RushMcpPluginFactory } from './pluginFramework/IRushMcpPlugin';\nexport type { IRushMcpTool } from './pluginFramework/IRushMcpTool';\nexport { type IRegisterToolOptions, RushMcpPluginSession } from './pluginFramework/RushMcpPluginSession';\nexport { CallToolResultSchema, type CallToolResult, type zodModule } from './pluginFramework/zodTypes';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRushMcpPlugin.js","sourceRoot":"","sources":["../../src/pluginFramework/IRushMcpPlugin.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { RushMcpPluginSession } from './RushMcpPluginSession';\n\n/**\n * MCP plugins should implement this interface.\n * @public\n */\nexport interface IRushMcpPlugin {\n onInitializeAsync(): Promise<void>;\n}\n\n/**\n * The plugin's entry point should return this function as its default export.\n * @public\n */\nexport type RushMcpPluginFactory<TConfigFile = {}> = (\n session: RushMcpPluginSession,\n configFile: TConfigFile | undefined\n) => IRushMcpPlugin;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRushMcpTool.js","sourceRoot":"","sources":["../../src/pluginFramework/IRushMcpTool.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as zod from 'zod';\n\nimport type { CallToolResult } from './zodTypes';\n\n/**\n * MCP plugins should implement this interface.\n * @public\n */\nexport interface IRushMcpTool<\n TSchema extends zod.ZodObject<zod.ZodRawShape> = zod.ZodObject<zod.ZodRawShape>\n> {\n readonly schema: TSchema;\n executeAsync(input: zod.infer<TSchema>): Promise<CallToolResult>;\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { FileSystem, Import, JsonFile, JsonSchema } from '@rushstack/node-core-library';
|
|
5
|
+
import { Autoinstaller } from '@rushstack/rush-sdk/lib/logic/Autoinstaller';
|
|
6
|
+
import { RushGlobalFolder } from '@rushstack/rush-sdk/lib/api/RushGlobalFolder';
|
|
7
|
+
import { RushConfiguration } from '@rushstack/rush-sdk/lib/api/RushConfiguration';
|
|
8
|
+
import { RushMcpPluginSessionInternal } from './RushMcpPluginSession';
|
|
9
|
+
import rushMcpJsonSchemaObject from '../schemas/rush-mcp.schema.json';
|
|
10
|
+
import rushMcpPluginSchemaObject from '../schemas/rush-mcp-plugin.schema.json';
|
|
11
|
+
export class RushMcpPluginLoader {
|
|
12
|
+
constructor(rushWorkspacePath, mcpServer) {
|
|
13
|
+
this._rushWorkspacePath = rushWorkspacePath;
|
|
14
|
+
this._mcpServer = mcpServer;
|
|
15
|
+
}
|
|
16
|
+
static _formatError(e) {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = e.stack) !== null && _a !== void 0 ? _a : RushMcpPluginLoader._formatError(e);
|
|
19
|
+
}
|
|
20
|
+
async loadAsync() {
|
|
21
|
+
const rushMcpFilePath = path.join(this._rushWorkspacePath, 'common/config/rush-mcp/rush-mcp.json');
|
|
22
|
+
if (!(await FileSystem.existsAsync(rushMcpFilePath))) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const rushConfiguration = RushConfiguration.loadFromDefaultLocation({
|
|
26
|
+
startingFolder: this._rushWorkspacePath
|
|
27
|
+
});
|
|
28
|
+
const jsonRushMcpConfig = await JsonFile.loadAndValidateAsync(rushMcpFilePath, RushMcpPluginLoader._rushMcpJsonSchema);
|
|
29
|
+
if (jsonRushMcpConfig.mcpPlugins.length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const rushGlobalFolder = new RushGlobalFolder();
|
|
33
|
+
for (const jsonMcpPlugin of jsonRushMcpConfig.mcpPlugins) {
|
|
34
|
+
// Ensure the autoinstaller is installed
|
|
35
|
+
const autoinstaller = new Autoinstaller({
|
|
36
|
+
autoinstallerName: jsonMcpPlugin.autoinstaller,
|
|
37
|
+
rushConfiguration,
|
|
38
|
+
rushGlobalFolder,
|
|
39
|
+
restrictConsoleOutput: false
|
|
40
|
+
});
|
|
41
|
+
await autoinstaller.prepareAsync();
|
|
42
|
+
// Load the manifest
|
|
43
|
+
// Suppose the autoinstaller is "my-autoinstaller" and the package is "rush-mcp-example-plugin".
|
|
44
|
+
// Then the folder will be:
|
|
45
|
+
// "/path/to/my-repo/common/autoinstallers/my-autoinstaller/node_modules/rush-mcp-example-plugin"
|
|
46
|
+
const installedPluginPackageFolder = await Import.resolvePackageAsync({
|
|
47
|
+
baseFolderPath: autoinstaller.folderFullPath,
|
|
48
|
+
packageName: jsonMcpPlugin.packageName
|
|
49
|
+
});
|
|
50
|
+
const manifestFilePath = path.join(installedPluginPackageFolder, 'rush-mcp-plugin.json');
|
|
51
|
+
if (!(await FileSystem.existsAsync(manifestFilePath))) {
|
|
52
|
+
throw new Error('The "rush-mcp-plugin.json" manifest file was not found under ' + installedPluginPackageFolder);
|
|
53
|
+
}
|
|
54
|
+
const jsonManifest = await JsonFile.loadAndValidateAsync(manifestFilePath, RushMcpPluginLoader._rushMcpPluginSchemaObject);
|
|
55
|
+
let rushMcpPluginOptions = {};
|
|
56
|
+
if (jsonManifest.configFileSchema) {
|
|
57
|
+
const mcpPluginSchemaFilePath = path.resolve(installedPluginPackageFolder, jsonManifest.configFileSchema);
|
|
58
|
+
const mcpPluginSchema = await JsonSchema.fromFile(mcpPluginSchemaFilePath);
|
|
59
|
+
const rushMcpPluginOptionsFilePath = path.resolve(this._rushWorkspacePath, `common/config/rush-mcp/${jsonManifest.pluginName}.json`);
|
|
60
|
+
// Example: /path/to/my-repo/common/config/rush-mcp/rush-mcp-example-plugin.json
|
|
61
|
+
rushMcpPluginOptions = await JsonFile.loadAndValidateAsync(rushMcpPluginOptionsFilePath, mcpPluginSchema);
|
|
62
|
+
}
|
|
63
|
+
const fullEntryPointPath = path.join(installedPluginPackageFolder, jsonManifest.entryPoint);
|
|
64
|
+
let pluginFactory;
|
|
65
|
+
try {
|
|
66
|
+
const entryPointModule = require(fullEntryPointPath);
|
|
67
|
+
if (entryPointModule.default === undefined) {
|
|
68
|
+
throw new Error('The commonJS "default" export is missing');
|
|
69
|
+
}
|
|
70
|
+
pluginFactory = entryPointModule.default;
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
throw new Error(`Unable to load plugin entry point at ${fullEntryPointPath}:\n` +
|
|
74
|
+
RushMcpPluginLoader._formatError(e));
|
|
75
|
+
}
|
|
76
|
+
const session = new RushMcpPluginSessionInternal(this._mcpServer);
|
|
77
|
+
let plugin;
|
|
78
|
+
try {
|
|
79
|
+
plugin = pluginFactory(session, rushMcpPluginOptions);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
throw new Error(`Error invoking entry point for plugin ${jsonManifest.pluginName}:\n` +
|
|
83
|
+
RushMcpPluginLoader._formatError(e));
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await plugin.onInitializeAsync();
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
throw new Error(`Error occurred in onInitializeAsync() for plugin ${jsonManifest.pluginName}:\n` +
|
|
90
|
+
RushMcpPluginLoader._formatError(e));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
RushMcpPluginLoader._rushMcpJsonSchema = JsonSchema.fromLoadedObject(rushMcpJsonSchemaObject);
|
|
96
|
+
RushMcpPluginLoader._rushMcpPluginSchemaObject = JsonSchema.fromLoadedObject(rushMcpPluginSchemaObject);
|
|
97
|
+
//# sourceMappingURL=RushMcpPluginLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RushMcpPluginLoader.js","sourceRoot":"","sources":["../../src/pluginFramework/RushMcpPluginLoader.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\n\nimport { FileSystem, Import, JsonFile, type JsonObject, JsonSchema } from '@rushstack/node-core-library';\nimport { Autoinstaller } from '@rushstack/rush-sdk/lib/logic/Autoinstaller';\nimport { RushGlobalFolder } from '@rushstack/rush-sdk/lib/api/RushGlobalFolder';\nimport { RushConfiguration } from '@rushstack/rush-sdk/lib/api/RushConfiguration';\n\nimport type { IRushMcpPlugin, RushMcpPluginFactory } from './IRushMcpPlugin';\nimport { RushMcpPluginSessionInternal } from './RushMcpPluginSession';\nimport rushMcpJsonSchemaObject from '../schemas/rush-mcp.schema.json';\nimport rushMcpPluginSchemaObject from '../schemas/rush-mcp-plugin.schema.json';\n\n/**\n * Configuration for @rushstack/mcp-server in a monorepo.\n * Corresponds to the contents of common/config/rush-mcp/rush-mcp.json\n */\nexport interface IJsonRushMcpConfig {\n /**\n * The list of plugins that @rushstack/mcp-server should load when processing this monorepo.\n */\n mcpPlugins: IJsonRushMcpPlugin[];\n}\n\n/**\n * Describes a single MCP plugin entry.\n */\nexport interface IJsonRushMcpPlugin {\n /**\n * The name of an NPM package that appears in the package.json \"dependencies\" for the autoinstaller.\n */\n packageName: string;\n\n /**\n * The name of a Rush autoinstaller with this package as its dependency.\n * @rushstack/mcp-server will ensure this folder is installed before loading the plugin.\n */\n autoinstaller: string;\n}\n\n/**\n * Manifest file for a Rush MCP plugin.\n * Every plugin package must contain a \"rush-mcp-plugin.json\" manifest in the top-level folder.\n */\nexport interface IJsonRushMcpPluginManifest {\n /**\n * A name that uniquely identifies your plugin.\n * Generally this should match the NPM package name; two plugins with the same pluginName cannot be loaded together.\n */\n pluginName: string;\n\n /**\n * Optional. Indicates that your plugin accepts a config file.\n * The MCP server will load this schema file and provide it to the plugin.\n * Path is typically `<rush-repo>/common/config/rush-mcp/<plugin-name>.json`.\n */\n configFileSchema?: string;\n\n /**\n * The module path to the plugin's entry point.\n * Its default export must be a class implementing the MCP plugin interface.\n */\n entryPoint: string;\n}\n\nexport class RushMcpPluginLoader {\n private static readonly _rushMcpJsonSchema: JsonSchema =\n JsonSchema.fromLoadedObject(rushMcpJsonSchemaObject);\n private static readonly _rushMcpPluginSchemaObject: JsonSchema =\n JsonSchema.fromLoadedObject(rushMcpPluginSchemaObject);\n\n private readonly _rushWorkspacePath: string;\n private readonly _mcpServer: McpServer;\n\n public constructor(rushWorkspacePath: string, mcpServer: McpServer) {\n this._rushWorkspacePath = rushWorkspacePath;\n this._mcpServer = mcpServer;\n }\n\n private static _formatError(e: Error): string {\n return e.stack ?? RushMcpPluginLoader._formatError(e);\n }\n\n public async loadAsync(): Promise<void> {\n const rushMcpFilePath: string = path.join(\n this._rushWorkspacePath,\n 'common/config/rush-mcp/rush-mcp.json'\n );\n\n if (!(await FileSystem.existsAsync(rushMcpFilePath))) {\n return;\n }\n\n const rushConfiguration: RushConfiguration = RushConfiguration.loadFromDefaultLocation({\n startingFolder: this._rushWorkspacePath\n });\n\n const jsonRushMcpConfig: IJsonRushMcpConfig = await JsonFile.loadAndValidateAsync(\n rushMcpFilePath,\n RushMcpPluginLoader._rushMcpJsonSchema\n );\n\n if (jsonRushMcpConfig.mcpPlugins.length === 0) {\n return;\n }\n\n const rushGlobalFolder: RushGlobalFolder = new RushGlobalFolder();\n\n for (const jsonMcpPlugin of jsonRushMcpConfig.mcpPlugins) {\n // Ensure the autoinstaller is installed\n const autoinstaller: Autoinstaller = new Autoinstaller({\n autoinstallerName: jsonMcpPlugin.autoinstaller,\n rushConfiguration,\n rushGlobalFolder,\n restrictConsoleOutput: false\n });\n await autoinstaller.prepareAsync();\n\n // Load the manifest\n\n // Suppose the autoinstaller is \"my-autoinstaller\" and the package is \"rush-mcp-example-plugin\".\n // Then the folder will be:\n // \"/path/to/my-repo/common/autoinstallers/my-autoinstaller/node_modules/rush-mcp-example-plugin\"\n const installedPluginPackageFolder: string = await Import.resolvePackageAsync({\n baseFolderPath: autoinstaller.folderFullPath,\n packageName: jsonMcpPlugin.packageName\n });\n\n const manifestFilePath: string = path.join(installedPluginPackageFolder, 'rush-mcp-plugin.json');\n if (!(await FileSystem.existsAsync(manifestFilePath))) {\n throw new Error(\n 'The \"rush-mcp-plugin.json\" manifest file was not found under ' + installedPluginPackageFolder\n );\n }\n\n const jsonManifest: IJsonRushMcpPluginManifest = await JsonFile.loadAndValidateAsync(\n manifestFilePath,\n RushMcpPluginLoader._rushMcpPluginSchemaObject\n );\n\n let rushMcpPluginOptions: JsonObject = {};\n if (jsonManifest.configFileSchema) {\n const mcpPluginSchemaFilePath: string = path.resolve(\n installedPluginPackageFolder,\n jsonManifest.configFileSchema\n );\n const mcpPluginSchema: JsonSchema = await JsonSchema.fromFile(mcpPluginSchemaFilePath);\n const rushMcpPluginOptionsFilePath: string = path.resolve(\n this._rushWorkspacePath,\n `common/config/rush-mcp/${jsonManifest.pluginName}.json`\n );\n // Example: /path/to/my-repo/common/config/rush-mcp/rush-mcp-example-plugin.json\n rushMcpPluginOptions = await JsonFile.loadAndValidateAsync(\n rushMcpPluginOptionsFilePath,\n mcpPluginSchema\n );\n }\n\n const fullEntryPointPath: string = path.join(installedPluginPackageFolder, jsonManifest.entryPoint);\n let pluginFactory: RushMcpPluginFactory;\n try {\n const entryPointModule: { default?: RushMcpPluginFactory } = require(fullEntryPointPath);\n if (entryPointModule.default === undefined) {\n throw new Error('The commonJS \"default\" export is missing');\n }\n pluginFactory = entryPointModule.default;\n } catch (e) {\n throw new Error(\n `Unable to load plugin entry point at ${fullEntryPointPath}:\\n` +\n RushMcpPluginLoader._formatError(e)\n );\n }\n\n const session: RushMcpPluginSessionInternal = new RushMcpPluginSessionInternal(this._mcpServer);\n\n let plugin: IRushMcpPlugin;\n try {\n plugin = pluginFactory(session, rushMcpPluginOptions);\n } catch (e) {\n throw new Error(\n `Error invoking entry point for plugin ${jsonManifest.pluginName}:\\n` +\n RushMcpPluginLoader._formatError(e)\n );\n }\n\n try {\n await plugin.onInitializeAsync();\n } catch (e) {\n throw new Error(\n `Error occurred in onInitializeAsync() for plugin ${jsonManifest.pluginName}:\\n` +\n RushMcpPluginLoader._formatError(e)\n );\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import * as zod from 'zod';
|
|
4
|
+
/**
|
|
5
|
+
* Each plugin gets its own session.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export class RushMcpPluginSession {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.zod = zod;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class RushMcpPluginSessionInternal extends RushMcpPluginSession {
|
|
15
|
+
constructor(mcpServer) {
|
|
16
|
+
super();
|
|
17
|
+
this._mcpServer = mcpServer;
|
|
18
|
+
}
|
|
19
|
+
registerTool(options, tool) {
|
|
20
|
+
if (options.description) {
|
|
21
|
+
this._mcpServer.tool(options.toolName, options.description, tool.schema.shape, tool.executeAsync.bind(tool));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this._mcpServer.tool(options.toolName, tool.schema.shape, tool.executeAsync.bind(tool));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=RushMcpPluginSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RushMcpPluginSession.js","sourceRoot":"","sources":["../../src/pluginFramework/RushMcpPluginSession.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAgB3B;;;;GAIG;AACH,MAAM,OAAgB,oBAAoB;IAA1C;QACkB,QAAG,GAAqB,GAAG,CAAC;IAE9C,CAAC;CAAA;AAED,MAAM,OAAO,4BAA6B,SAAQ,oBAAoB;IAGpE,YAAmB,SAAoB;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEe,YAAY,CAAC,OAA6B,EAAE,IAAkB;QAC5E,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAClB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,WAAW,EACnB,IAAI,CAAC,MAAM,CAAC,KAAK,EACjB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as zod from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\n\nimport type { IRushMcpTool } from './IRushMcpTool';\nimport type { zodModule } from './zodTypes';\n\n/**\n * Each plugin gets its own session.\n *\n * @public\n */\nexport interface IRegisterToolOptions {\n toolName: string;\n description?: string;\n}\n\n/**\n * Each plugin gets its own session.\n *\n * @public\n */\nexport abstract class RushMcpPluginSession {\n public readonly zod: typeof zodModule = zod;\n public abstract registerTool(options: IRegisterToolOptions, tool: IRushMcpTool): void;\n}\n\nexport class RushMcpPluginSessionInternal extends RushMcpPluginSession {\n private readonly _mcpServer: McpServer;\n\n public constructor(mcpServer: McpServer) {\n super();\n this._mcpServer = mcpServer;\n }\n\n public override registerTool(options: IRegisterToolOptions, tool: IRushMcpTool): void {\n if (options.description) {\n this._mcpServer.tool(\n options.toolName,\n options.description,\n tool.schema.shape,\n tool.executeAsync.bind(tool)\n );\n } else {\n this._mcpServer.tool(options.toolName, tool.schema.shape, tool.executeAsync.bind(tool));\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types';
|
|
4
|
+
export { CallToolResultSchema };
|
|
5
|
+
//# sourceMappingURL=zodTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodTypes.js","sourceRoot":"","sources":["../../src/pluginFramework/zodTypes.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as zod from 'zod';\nimport { CallToolResultSchema } from '@modelcontextprotocol/sdk/types';\n\nexport type { zod as zodModule };\nexport { CallToolResultSchema };\n\n/**\n * @public\n */\nexport type CallToolResult = zod.infer<typeof CallToolResultSchema>;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Rush MCP Plugin Manifest",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"pluginName": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "A name that uniquely identifies your plugin. Generally this should match the NPM package name; two plugins with the same pluginName cannot be loaded together."
|
|
9
|
+
},
|
|
10
|
+
"configFileSchema": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Optional. Indicates that your plugin accepts a config file. The MCP server will load this schema file and provide it to the plugin. Path is typically `<rush-repo>/common/config/rush-mcp/<plugin-name>.json`."
|
|
13
|
+
},
|
|
14
|
+
"entryPoint": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The module path to the plugin's entry point. Its default export must be a class implementing the MCP plugin interface."
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["pluginName", "entryPoint"],
|
|
20
|
+
"additionalProperties": false
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "rush-mcp.json Configuration Schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"mcpPlugins": {
|
|
7
|
+
"type": "array",
|
|
8
|
+
"description": "The list of plugins that `@rushstack/mcp-server` should load when processing this monorepo.",
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"packageName": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The name of an NPM package that appears in the package.json \"dependencies\" for the autoinstaller."
|
|
15
|
+
},
|
|
16
|
+
"autoinstaller": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The name of a Rush autoinstaller with this package as its dependency."
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": ["packageName", "autoinstaller"],
|
|
22
|
+
"additionalProperties": false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": ["mcpPlugins"],
|
|
27
|
+
"additionalProperties": false
|
|
28
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
import { RushConflictResolverTool, RushMigrateProjectTool, RushCommandValidatorTool, RushWorkspaceDetailsTool, RushProjectDetailsTool } from './tools';
|
|
5
|
+
import { RushMcpPluginLoader } from './pluginFramework/RushMcpPluginLoader';
|
|
6
|
+
export class RushMCPServer extends McpServer {
|
|
7
|
+
constructor(rushWorkspacePath) {
|
|
8
|
+
super({
|
|
9
|
+
name: 'rush',
|
|
10
|
+
version: '1.0.0'
|
|
11
|
+
});
|
|
12
|
+
this._tools = [];
|
|
13
|
+
this._rushWorkspacePath = rushWorkspacePath;
|
|
14
|
+
this._pluginLoader = new RushMcpPluginLoader(this._rushWorkspacePath, this);
|
|
15
|
+
}
|
|
16
|
+
async startAsync() {
|
|
17
|
+
this._initializeTools();
|
|
18
|
+
this._registerTools();
|
|
19
|
+
await this._pluginLoader.loadAsync();
|
|
20
|
+
}
|
|
21
|
+
_initializeTools() {
|
|
22
|
+
this._tools.push(new RushConflictResolverTool());
|
|
23
|
+
this._tools.push(new RushMigrateProjectTool(this._rushWorkspacePath));
|
|
24
|
+
this._tools.push(new RushCommandValidatorTool());
|
|
25
|
+
this._tools.push(new RushWorkspaceDetailsTool());
|
|
26
|
+
this._tools.push(new RushProjectDetailsTool());
|
|
27
|
+
}
|
|
28
|
+
_registerTools() {
|
|
29
|
+
process.chdir(this._rushWorkspacePath);
|
|
30
|
+
for (const tool of this._tools) {
|
|
31
|
+
tool.register(this);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAEL,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,MAAM,OAAO,aAAc,SAAQ,SAAS;IAK1C,YAAmB,iBAAyB;QAC1C,KAAK,CAAC;YACJ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAPG,WAAM,GAAe,EAAE,CAAC;QAS9B,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;QAC5C,IAAI,CAAC,aAAa,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;IACvC,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;IACjD,CAAC;IAEO,cAAc;QACpB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEvC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport {\n type BaseTool,\n RushConflictResolverTool,\n RushMigrateProjectTool,\n RushCommandValidatorTool,\n RushWorkspaceDetailsTool,\n RushProjectDetailsTool\n} from './tools';\nimport { RushMcpPluginLoader } from './pluginFramework/RushMcpPluginLoader';\n\nexport class RushMCPServer extends McpServer {\n private _rushWorkspacePath: string;\n private _tools: BaseTool[] = [];\n private _pluginLoader: RushMcpPluginLoader;\n\n public constructor(rushWorkspacePath: string) {\n super({\n name: 'rush',\n version: '1.0.0'\n });\n\n this._rushWorkspacePath = rushWorkspacePath;\n this._pluginLoader = new RushMcpPluginLoader(this._rushWorkspacePath, this);\n }\n\n public async startAsync(): Promise<void> {\n this._initializeTools();\n this._registerTools();\n\n await this._pluginLoader.loadAsync();\n }\n\n private _initializeTools(): void {\n this._tools.push(new RushConflictResolverTool());\n this._tools.push(new RushMigrateProjectTool(this._rushWorkspacePath));\n this._tools.push(new RushCommandValidatorTool());\n this._tools.push(new RushWorkspaceDetailsTool());\n this._tools.push(new RushProjectDetailsTool());\n }\n\n private _registerTools(): void {\n process.chdir(this._rushWorkspacePath);\n\n for (const tool of this._tools) {\n tool.register(this);\n }\n }\n}\n"]}
|
package/lib-esm/start.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import * as process from 'node:process';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { FileSystem } from '@rushstack/node-core-library';
|
|
7
|
+
import { RushSdkLoader } from '@rushstack/rush-sdk/loader';
|
|
8
|
+
import { log } from './utilities/log';
|
|
9
|
+
const main = async () => {
|
|
10
|
+
const rushWorkspacePath = process.argv[2];
|
|
11
|
+
if (!rushWorkspacePath) {
|
|
12
|
+
throw new Error('Please provide workspace root path as the first argument');
|
|
13
|
+
}
|
|
14
|
+
const rushWorkspaceFullPath = path.resolve(rushWorkspacePath);
|
|
15
|
+
if (!(await FileSystem.existsAsync(rushWorkspaceFullPath))) {
|
|
16
|
+
throw new Error('The specified workspace root path does not exist:\n ' + JSON.stringify(rushWorkspacePath));
|
|
17
|
+
}
|
|
18
|
+
// Load rush-sdk from the specified repository
|
|
19
|
+
await RushSdkLoader.loadAsync({
|
|
20
|
+
rushJsonSearchFolder: rushWorkspaceFullPath
|
|
21
|
+
});
|
|
22
|
+
const RushMCPServerClass = (await import('./server')).RushMCPServer;
|
|
23
|
+
const server = new RushMCPServerClass(rushWorkspaceFullPath);
|
|
24
|
+
await server.startAsync();
|
|
25
|
+
const transport = new StdioServerTransport();
|
|
26
|
+
await server.connect(transport);
|
|
27
|
+
log('Rush MCP Server running on stdio');
|
|
28
|
+
};
|
|
29
|
+
main().catch((error) => {
|
|
30
|
+
log('Fatal error running server:', error instanceof Error ? error.message : error);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGtC,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IACrC,MAAM,iBAAiB,GAAuB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,qBAAqB,GAAW,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtE,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CACb,uDAAuD,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAC5F,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,MAAM,aAAa,CAAC,SAAS,CAAC;QAC5B,oBAAoB,EAAE,qBAAqB;KAC5C,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAyB,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC;IAE1F,MAAM,MAAM,GAAkB,IAAI,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;IAC5E,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAyB,IAAI,oBAAoB,EAAE,CAAC;IACnE,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,GAAG,CAAC,6BAA6B,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\nimport * as process from 'node:process';\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\n\nimport { FileSystem } from '@rushstack/node-core-library';\nimport { RushSdkLoader } from '@rushstack/rush-sdk/loader';\n\nimport { log } from './utilities/log';\nimport type { RushMCPServer } from './server';\n\nconst main = async (): Promise<void> => {\n const rushWorkspacePath: string | undefined = process.argv[2];\n if (!rushWorkspacePath) {\n throw new Error('Please provide workspace root path as the first argument');\n }\n\n const rushWorkspaceFullPath: string = path.resolve(rushWorkspacePath);\n\n if (!(await FileSystem.existsAsync(rushWorkspaceFullPath))) {\n throw new Error(\n 'The specified workspace root path does not exist:\\n ' + JSON.stringify(rushWorkspacePath)\n );\n }\n\n // Load rush-sdk from the specified repository\n await RushSdkLoader.loadAsync({\n rushJsonSearchFolder: rushWorkspaceFullPath\n });\n\n const RushMCPServerClass: typeof RushMCPServer = (await import('./server')).RushMCPServer;\n\n const server: RushMCPServer = new RushMCPServerClass(rushWorkspaceFullPath);\n await server.startAsync();\n const transport: StdioServerTransport = new StdioServerTransport();\n await server.connect(transport);\n\n log('Rush MCP Server running on stdio');\n};\n\nmain().catch((error) => {\n log('Fatal error running server:', error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
export class BaseTool {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this._options = options;
|
|
6
|
+
}
|
|
7
|
+
register(server) {
|
|
8
|
+
// TODO: remove ts-ignore
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
server.tool(this._options.name, this._options.description, this._options.schema, async (...args) => {
|
|
11
|
+
try {
|
|
12
|
+
const result = await this.executeAsync(...args);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return {
|
|
17
|
+
isError: true,
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: 'text',
|
|
21
|
+
text: error instanceof Error ? error.message : error
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=base.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.tool.js","sourceRoot":"","sources":["../../src/tools/base.tool.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AA4B3D,MAAM,OAAgB,QAAQ;IAG5B,YAAsB,OAA+B;QACnD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAIM,QAAQ,CAAC,MAAiB;QAC/B,yBAAyB;QACzB,aAAa;QACb,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE;YACjG,IAAI,CAAC;gBACH,MAAM,MAAM,GAAmB,MAAM,IAAI,CAAC,YAAY,CAAC,GAAI,IAAuC,CAAC,CAAC;gBACpG,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;yBACrD;qBACF;iBACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol';\nimport type {\n CallToolResultSchema,\n ServerNotification,\n ServerRequest\n} from '@modelcontextprotocol/sdk/types';\nimport type { z, ZodRawShape, ZodTypeAny } from 'zod';\n\nexport type CallToolResult = z.infer<typeof CallToolResultSchema>;\n\ntype ToolCallback<Args extends undefined | ZodRawShape = undefined> = Args extends ZodRawShape\n ? (\n args: z.objectOutputType<Args, ZodTypeAny>,\n extra: RequestHandlerExtra<ServerRequest, ServerNotification>\n ) => CallToolResult | Promise<CallToolResult>\n : (\n extra: RequestHandlerExtra<ServerRequest, ServerNotification>\n ) => CallToolResult | Promise<CallToolResult>;\n\nexport interface IBaseToolOptions<Args extends ZodRawShape = ZodRawShape> {\n name: string;\n description: string;\n schema: Args;\n}\n\nexport abstract class BaseTool<Args extends ZodRawShape = ZodRawShape> {\n private _options: IBaseToolOptions<Args>;\n\n protected constructor(options: IBaseToolOptions<Args>) {\n this._options = options;\n }\n\n protected abstract executeAsync(...args: Parameters<ToolCallback<Args>>): ReturnType<ToolCallback<Args>>;\n\n public register(server: McpServer): void {\n // TODO: remove ts-ignore\n // @ts-ignore\n server.tool(this._options.name, this._options.description, this._options.schema, async (...args) => {\n try {\n const result: CallToolResult = await this.executeAsync(...(args as Parameters<ToolCallback<Args>>));\n return result;\n } catch (error: unknown) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: error instanceof Error ? error.message : error\n }\n ]\n };\n }\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { CommandRunner } from '../utilities/command-runner';
|
|
5
|
+
import { getRushConfiguration } from '../utilities/common';
|
|
6
|
+
import { BaseTool } from './base.tool';
|
|
7
|
+
export class RushConflictResolverTool extends BaseTool {
|
|
8
|
+
constructor() {
|
|
9
|
+
super({
|
|
10
|
+
name: 'rush_pnpm_lock_file_conflict_resolver',
|
|
11
|
+
description: 'If a user requests to resolve a pnpm-lock.yaml file conflict, use this tool to automatically fix the conflict directly.',
|
|
12
|
+
schema: {
|
|
13
|
+
lockfilePath: z.string().describe('The path to the pnpm-lock.yaml file, should pass absolute path')
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_tryGetSubspaceNameFromLockfilePath(lockfilePath, rushConfiguration) {
|
|
18
|
+
for (const subspace of rushConfiguration.subspaces) {
|
|
19
|
+
const folderPath = subspace.getSubspaceConfigFolderPath();
|
|
20
|
+
if (lockfilePath.startsWith(folderPath)) {
|
|
21
|
+
return subspace.subspaceName;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
async executeAsync({ lockfilePath }) {
|
|
27
|
+
const rushConfiguration = await getRushConfiguration();
|
|
28
|
+
const subspaceName = this._tryGetSubspaceNameFromLockfilePath(lockfilePath, rushConfiguration);
|
|
29
|
+
if (!subspaceName) {
|
|
30
|
+
throw new Error('subspace name not found');
|
|
31
|
+
}
|
|
32
|
+
const options = {
|
|
33
|
+
stdio: 'inherit',
|
|
34
|
+
currentWorkingDirectory: rushConfiguration.rushJsonFolder
|
|
35
|
+
};
|
|
36
|
+
await CommandRunner.runGitCommandAsync(['checkout', '--theirs', lockfilePath], options);
|
|
37
|
+
await CommandRunner.runRushCommandAsync(['update', '--subspace', subspaceName], options);
|
|
38
|
+
return {
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: 'Conflict resolved successfully'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=conflict-resolver.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-resolver.tool.js","sourceRoot":"","sources":["../../src/tools/conflict-resolver.tool.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAuB,MAAM,aAAa,CAAC;AAE5D,MAAM,OAAO,wBAAyB,SAAQ,QAAQ;IACpD;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,uCAAuC;YAC7C,WAAW,EACT,yHAAyH;YAC3H,MAAM,EAAE;gBACN,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;aACpG;SACF,CAAC,CAAC;IACL,CAAC;IAEO,mCAAmC,CACzC,YAAoB,EACpB,iBAAoC;QAEpC,KAAK,MAAM,QAAQ,IAAI,iBAAiB,CAAC,SAAS,EAAE,CAAC;YACnD,MAAM,UAAU,GAAW,QAAQ,CAAC,2BAA2B,EAAE,CAAC;YAClE,IAAI,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxC,OAAO,QAAQ,CAAC,YAAY,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,EAAE,YAAY,EAA4B;QAClE,MAAM,iBAAiB,GAAsB,MAAM,oBAAoB,EAAE,CAAC;QAC1E,MAAM,YAAY,GAAkB,IAAI,CAAC,mCAAmC,CAC1E,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,OAAO,GAAgC;YAC3C,KAAK,EAAE,SAAS;YAChB,uBAAuB,EAAE,iBAAiB,CAAC,cAAc;SAC1D,CAAC;QACF,MAAM,aAAa,CAAC,kBAAkB,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QACxF,MAAM,aAAa,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QAEzF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,gCAAgC;iBACvC;aACF;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { z } from 'zod';\n\nimport type { RushConfiguration } from '@rushstack/rush-sdk';\nimport type { IExecutableSpawnSyncOptions } from '@rushstack/node-core-library';\n\nimport { CommandRunner } from '../utilities/command-runner';\nimport { getRushConfiguration } from '../utilities/common';\nimport { BaseTool, type CallToolResult } from './base.tool';\n\nexport class RushConflictResolverTool extends BaseTool {\n public constructor() {\n super({\n name: 'rush_pnpm_lock_file_conflict_resolver',\n description:\n 'If a user requests to resolve a pnpm-lock.yaml file conflict, use this tool to automatically fix the conflict directly.',\n schema: {\n lockfilePath: z.string().describe('The path to the pnpm-lock.yaml file, should pass absolute path')\n }\n });\n }\n\n private _tryGetSubspaceNameFromLockfilePath(\n lockfilePath: string,\n rushConfiguration: RushConfiguration\n ): string | null {\n for (const subspace of rushConfiguration.subspaces) {\n const folderPath: string = subspace.getSubspaceConfigFolderPath();\n if (lockfilePath.startsWith(folderPath)) {\n return subspace.subspaceName;\n }\n }\n return null;\n }\n\n public async executeAsync({ lockfilePath }: { lockfilePath: string }): Promise<CallToolResult> {\n const rushConfiguration: RushConfiguration = await getRushConfiguration();\n const subspaceName: string | null = this._tryGetSubspaceNameFromLockfilePath(\n lockfilePath,\n rushConfiguration\n );\n if (!subspaceName) {\n throw new Error('subspace name not found');\n }\n\n const options: IExecutableSpawnSyncOptions = {\n stdio: 'inherit',\n currentWorkingDirectory: rushConfiguration.rushJsonFolder\n };\n await CommandRunner.runGitCommandAsync(['checkout', '--theirs', lockfilePath], options);\n await CommandRunner.runRushCommandAsync(['update', '--subspace', subspaceName], options);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Conflict resolved successfully'\n }\n ]\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
export { BaseTool } from './base.tool';
|
|
4
|
+
export { RushMigrateProjectTool } from './migrate-project.tool';
|
|
5
|
+
export { RushProjectDetailsTool } from './project-details.tool';
|
|
6
|
+
export { RushCommandValidatorTool } from './rush-command-validator.tool';
|
|
7
|
+
export { RushWorkspaceDetailsTool } from './workspace-details';
|
|
8
|
+
export { RushConflictResolverTool } from './conflict-resolver.tool';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,QAAQ,EAA8C,MAAM,aAAa,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport { BaseTool, type IBaseToolOptions, type CallToolResult } from './base.tool';\nexport { RushMigrateProjectTool } from './migrate-project.tool';\nexport { RushProjectDetailsTool } from './project-details.tool';\nexport { RushCommandValidatorTool } from './rush-command-validator.tool';\nexport { RushWorkspaceDetailsTool } from './workspace-details';\nexport { RushConflictResolverTool } from './conflict-resolver.tool';\n"]}
|