@rushstack/mcp-server 0.1.8 → 0.2.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 +24 -0
- package/CHANGELOG.md +15 -1
- package/dist/mcp-server.d.ts +61 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/index.d.ts +8 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -4
- package/lib/index.js.map +1 -1
- package/lib/pluginFramework/IRushMcpPlugin.d.ts +14 -0
- package/lib/pluginFramework/IRushMcpPlugin.d.ts.map +1 -0
- package/lib/pluginFramework/IRushMcpPlugin.js +5 -0
- package/lib/pluginFramework/IRushMcpPlugin.js.map +1 -0
- package/lib/pluginFramework/IRushMcpTool.d.ts +11 -0
- package/lib/pluginFramework/IRushMcpTool.d.ts.map +1 -0
- package/lib/pluginFramework/IRushMcpTool.js +5 -0
- package/lib/pluginFramework/IRushMcpTool.js.map +1 -0
- package/lib/pluginFramework/RushMcpPluginLoader.d.ts +57 -0
- package/lib/pluginFramework/RushMcpPluginLoader.d.ts.map +1 -0
- package/lib/pluginFramework/RushMcpPluginLoader.js +137 -0
- package/lib/pluginFramework/RushMcpPluginLoader.js.map +1 -0
- package/lib/pluginFramework/RushMcpPluginSession.d.ts +27 -0
- package/lib/pluginFramework/RushMcpPluginSession.d.ts.map +1 -0
- package/lib/pluginFramework/RushMcpPluginSession.js +66 -0
- package/lib/pluginFramework/RushMcpPluginSession.js.map +1 -0
- package/lib/pluginFramework/zodTypes.d.ts +9 -0
- package/lib/pluginFramework/zodTypes.d.ts.map +1 -0
- package/lib/pluginFramework/zodTypes.js +8 -0
- package/lib/pluginFramework/zodTypes.js.map +1 -0
- package/lib/schemas/rush-mcp-plugin.schema.json +21 -0
- package/lib/schemas/rush-mcp.schema.json +28 -0
- package/lib/server.d.ts +2 -0
- package/lib/server.d.ts.map +1 -1
- package/lib/server.js +5 -0
- package/lib/server.js.map +1 -1
- package/lib/start.js +48 -2
- package/lib/start.js.map +1 -1
- package/package.json +5 -3
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/mcp-server",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.2.1",
|
|
6
|
+
"tag": "@rushstack/mcp-server_v0.2.1",
|
|
7
|
+
"date": "Fri, 06 Jun 2025 08:20:18 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Fix some errors when loading plugins"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"version": "0.2.0",
|
|
18
|
+
"tag": "@rushstack/mcp-server_v0.2.0",
|
|
19
|
+
"date": "Fri, 06 Jun 2025 00:11:09 GMT",
|
|
20
|
+
"comments": {
|
|
21
|
+
"minor": [
|
|
22
|
+
{
|
|
23
|
+
"comment": "Introduce a plugin system for custom MCP tools"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
4
28
|
{
|
|
5
29
|
"version": "0.1.8",
|
|
6
30
|
"tag": "@rushstack/mcp-server_v0.1.8",
|
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, 06 Jun 2025 08:20:18 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.2.1
|
|
6
|
+
Fri, 06 Jun 2025 08:20:18 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Fix some errors when loading plugins
|
|
11
|
+
|
|
12
|
+
## 0.2.0
|
|
13
|
+
Fri, 06 Jun 2025 00:11:09 GMT
|
|
14
|
+
|
|
15
|
+
### Minor changes
|
|
16
|
+
|
|
17
|
+
- Introduce a plugin system for custom MCP tools
|
|
4
18
|
|
|
5
19
|
## 0.1.8
|
|
6
20
|
Thu, 29 May 2025 15:10:58 GMT
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API for use by MCP plugins.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types';
|
|
7
|
+
import type * as zodModule from 'zod';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare type CallToolResult = zodModule.infer<typeof CallToolResultSchema>;
|
|
13
|
+
|
|
14
|
+
export { CallToolResultSchema }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Each plugin gets its own session.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare interface IRegisterToolOptions {
|
|
22
|
+
toolName: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* MCP plugins should implement this interface.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare interface IRushMcpPlugin {
|
|
31
|
+
onInitializeAsync(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* MCP plugins should implement this interface.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare interface IRushMcpTool<TSchema extends zodModule.ZodObject<zodModule.ZodRawShape> = zodModule.ZodObject<zodModule.ZodRawShape>> {
|
|
39
|
+
readonly schema: TSchema;
|
|
40
|
+
executeAsync(input: zodModule.infer<TSchema>): Promise<CallToolResult>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The plugin's entry point should return this function as its default export.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare type RushMcpPluginFactory<TConfigFile = {}> = (session: RushMcpPluginSession, configFile: TConfigFile | undefined) => IRushMcpPlugin;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Each plugin gets its own session.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare abstract class RushMcpPluginSession {
|
|
55
|
+
readonly zod: typeof zodModule;
|
|
56
|
+
abstract registerTool(options: IRegisterToolOptions, tool: IRushMcpTool): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { zodModule }
|
|
60
|
+
|
|
61
|
+
export { }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.52.8"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* API for use by MCP plugins.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export * from './pluginFramework/IRushMcpPlugin';
|
|
6
|
+
export * from './pluginFramework/IRushMcpTool';
|
|
7
|
+
export { type IRegisterToolOptions, RushMcpPluginSession } from './pluginFramework/RushMcpPluginSession';
|
|
8
|
+
export * from './pluginFramework/zodTypes';
|
|
3
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,KAAK,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AACzG,cAAc,4BAA4B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -16,8 +16,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
exports.RushMcpPluginSession = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* API for use by MCP plugins.
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
__exportStar(require("./pluginFramework/IRushMcpPlugin"), exports);
|
|
25
|
+
__exportStar(require("./pluginFramework/IRushMcpTool"), exports);
|
|
26
|
+
var RushMcpPluginSession_1 = require("./pluginFramework/RushMcpPluginSession");
|
|
27
|
+
Object.defineProperty(exports, "RushMcpPluginSession", { enumerable: true, get: function () { return RushMcpPluginSession_1.RushMcpPluginSession; } });
|
|
28
|
+
__exportStar(require("./pluginFramework/zodTypes"), exports);
|
|
23
29
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;AAE3D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;AAE3D;;;GAGG;AAEH,mEAAiD;AACjD,iEAA+C;AAC/C,+EAAyG;AAArE,4HAAA,oBAAoB,OAAA;AACxD,6DAA2C","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 * from './pluginFramework/IRushMcpPlugin';\nexport * from './pluginFramework/IRushMcpTool';\nexport { type IRegisterToolOptions, RushMcpPluginSession } from './pluginFramework/RushMcpPluginSession';\nexport * from './pluginFramework/zodTypes';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RushMcpPluginSession } from './RushMcpPluginSession';
|
|
2
|
+
/**
|
|
3
|
+
* MCP plugins should implement this interface.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IRushMcpPlugin {
|
|
7
|
+
onInitializeAsync(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The plugin's entry point should return this function as its default export.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export type RushMcpPluginFactory<TConfigFile = {}> = (session: RushMcpPluginSession, configFile: TConfigFile | undefined) => IRushMcpPlugin;
|
|
14
|
+
//# sourceMappingURL=IRushMcpPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRushMcpPlugin.d.ts","sourceRoot":"","sources":["../../src/pluginFramework/IRushMcpPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;GAGG;AAEH,MAAM,MAAM,oBAAoB,CAAC,WAAW,GAAG,EAAE,IAAI,CACnD,OAAO,EAAE,oBAAoB,EAC7B,UAAU,EAAE,WAAW,GAAG,SAAS,KAChC,cAAc,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
//# sourceMappingURL=IRushMcpPlugin.js.map
|
|
@@ -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 */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type RushMcpPluginFactory<TConfigFile = {}> = (\n session: RushMcpPluginSession,\n configFile: TConfigFile | undefined\n) => IRushMcpPlugin;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as zod from 'zod';
|
|
2
|
+
import type { CallToolResult } from './zodTypes';
|
|
3
|
+
/**
|
|
4
|
+
* MCP plugins should implement this interface.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IRushMcpTool<TSchema extends zod.ZodObject<zod.ZodRawShape> = zod.ZodObject<zod.ZodRawShape>> {
|
|
8
|
+
readonly schema: TSchema;
|
|
9
|
+
executeAsync(input: zod.infer<TSchema>): Promise<CallToolResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IRushMcpTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRushMcpTool.d.ts","sourceRoot":"","sources":["../../src/pluginFramework/IRushMcpTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,GAAG,MAAM,KAAK,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,YAAY,CAC3B,OAAO,SAAS,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC;IAE/E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAClE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
//# sourceMappingURL=IRushMcpTool.js.map
|
|
@@ -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,57 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for @rushstack/mcp-server in a monorepo.
|
|
4
|
+
* Corresponds to the contents of common/config/rush-mcp/rush-mcp.json
|
|
5
|
+
*/
|
|
6
|
+
export interface IJsonRushMcpConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The list of plugins that @rushstack/mcp-server should load when processing this monorepo.
|
|
9
|
+
*/
|
|
10
|
+
mcpPlugins: IJsonRushMcpPlugin[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Describes a single MCP plugin entry.
|
|
14
|
+
*/
|
|
15
|
+
export interface IJsonRushMcpPlugin {
|
|
16
|
+
/**
|
|
17
|
+
* The name of an NPM package that appears in the package.json "dependencies" for the autoinstaller.
|
|
18
|
+
*/
|
|
19
|
+
packageName: string;
|
|
20
|
+
/**
|
|
21
|
+
* The name of a Rush autoinstaller with this package as its dependency.
|
|
22
|
+
* @rushstack/mcp-server will ensure this folder is installed before loading the plugin.
|
|
23
|
+
*/
|
|
24
|
+
autoinstaller: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Manifest file for a Rush MCP plugin.
|
|
28
|
+
* Every plugin package must contain a "rush-mcp-plugin.json" manifest in the top-level folder.
|
|
29
|
+
*/
|
|
30
|
+
export interface IJsonRushMcpPluginManifest {
|
|
31
|
+
/**
|
|
32
|
+
* A name that uniquely identifies your plugin.
|
|
33
|
+
* Generally this should match the NPM package name; two plugins with the same pluginName cannot be loaded together.
|
|
34
|
+
*/
|
|
35
|
+
pluginName: string;
|
|
36
|
+
/**
|
|
37
|
+
* Optional. Indicates that your plugin accepts a config file.
|
|
38
|
+
* The MCP server will load this schema file and provide it to the plugin.
|
|
39
|
+
* Path is typically `<rush-repo>/common/config/rush-mcp/<plugin-name>.json`.
|
|
40
|
+
*/
|
|
41
|
+
configFileSchema?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The module path to the plugin's entry point.
|
|
44
|
+
* Its default export must be a class implementing the MCP plugin interface.
|
|
45
|
+
*/
|
|
46
|
+
entryPoint: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class RushMcpPluginLoader {
|
|
49
|
+
private static readonly _rushMcpJsonSchema;
|
|
50
|
+
private static readonly _rushMcpPluginSchemaObject;
|
|
51
|
+
private readonly _rushWorkspacePath;
|
|
52
|
+
private readonly _mcpServer;
|
|
53
|
+
constructor(rushWorkspacePath: string, mcpServer: McpServer);
|
|
54
|
+
private static _formatError;
|
|
55
|
+
loadAsync(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=RushMcpPluginLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RushMcpPluginLoader.d.ts","sourceRoot":"","sources":["../../src/pluginFramework/RushMcpPluginLoader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAQtE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,UAAU,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CACa;IACvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CACO;IAEzD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;gBAEpB,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS;IAKlE,OAAO,CAAC,MAAM,CAAC,YAAY;IAId,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAgHxC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.RushMcpPluginLoader = void 0;
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
44
|
+
const Autoinstaller_1 = require("@rushstack/rush-sdk/lib/logic/Autoinstaller");
|
|
45
|
+
const RushGlobalFolder_1 = require("@rushstack/rush-sdk/lib/api/RushGlobalFolder");
|
|
46
|
+
const RushConfiguration_1 = require("@rushstack/rush-sdk/lib/api/RushConfiguration");
|
|
47
|
+
const RushMcpPluginSession_1 = require("./RushMcpPluginSession");
|
|
48
|
+
const rush_mcp_schema_json_1 = __importDefault(require("../schemas/rush-mcp.schema.json"));
|
|
49
|
+
const rush_mcp_plugin_schema_json_1 = __importDefault(require("../schemas/rush-mcp-plugin.schema.json"));
|
|
50
|
+
class RushMcpPluginLoader {
|
|
51
|
+
constructor(rushWorkspacePath, mcpServer) {
|
|
52
|
+
this._rushWorkspacePath = rushWorkspacePath;
|
|
53
|
+
this._mcpServer = mcpServer;
|
|
54
|
+
}
|
|
55
|
+
static _formatError(e) {
|
|
56
|
+
var _a;
|
|
57
|
+
return (_a = e.stack) !== null && _a !== void 0 ? _a : RushMcpPluginLoader._formatError(e);
|
|
58
|
+
}
|
|
59
|
+
async loadAsync() {
|
|
60
|
+
const rushMcpFilePath = path.join(this._rushWorkspacePath, 'common/config/rush-mcp/rush-mcp.json');
|
|
61
|
+
if (!(await node_core_library_1.FileSystem.existsAsync(rushMcpFilePath))) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const rushConfiguration = RushConfiguration_1.RushConfiguration.loadFromDefaultLocation({
|
|
65
|
+
startingFolder: this._rushWorkspacePath
|
|
66
|
+
});
|
|
67
|
+
const jsonRushMcpConfig = await node_core_library_1.JsonFile.loadAndValidateAsync(rushMcpFilePath, RushMcpPluginLoader._rushMcpJsonSchema);
|
|
68
|
+
if (jsonRushMcpConfig.mcpPlugins.length === 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const rushGlobalFolder = new RushGlobalFolder_1.RushGlobalFolder();
|
|
72
|
+
for (const jsonMcpPlugin of jsonRushMcpConfig.mcpPlugins) {
|
|
73
|
+
// Ensure the autoinstaller is installed
|
|
74
|
+
const autoinstaller = new Autoinstaller_1.Autoinstaller({
|
|
75
|
+
autoinstallerName: jsonMcpPlugin.autoinstaller,
|
|
76
|
+
rushConfiguration,
|
|
77
|
+
rushGlobalFolder,
|
|
78
|
+
restrictConsoleOutput: false
|
|
79
|
+
});
|
|
80
|
+
await autoinstaller.prepareAsync();
|
|
81
|
+
// Load the manifest
|
|
82
|
+
// Suppose the autoinstaller is "my-autoinstaller" and the package is "rush-mcp-example-plugin".
|
|
83
|
+
// Then the folder will be:
|
|
84
|
+
// "/path/to/my-repo/common/autoinstallers/my-autoinstaller/node_modules/rush-mcp-example-plugin"
|
|
85
|
+
const installedPluginPackageFolder = await node_core_library_1.Import.resolvePackageAsync({
|
|
86
|
+
baseFolderPath: autoinstaller.folderFullPath,
|
|
87
|
+
packageName: jsonMcpPlugin.packageName
|
|
88
|
+
});
|
|
89
|
+
const manifestFilePath = path.join(installedPluginPackageFolder, 'rush-mcp-plugin.json');
|
|
90
|
+
if (!(await node_core_library_1.FileSystem.existsAsync(manifestFilePath))) {
|
|
91
|
+
throw new Error('The "rush-mcp-plugin.json" manifest file was not found under ' + installedPluginPackageFolder);
|
|
92
|
+
}
|
|
93
|
+
const jsonManifest = await node_core_library_1.JsonFile.loadAndValidateAsync(manifestFilePath, RushMcpPluginLoader._rushMcpPluginSchemaObject);
|
|
94
|
+
let rushMcpPluginOptions = {};
|
|
95
|
+
if (jsonManifest.configFileSchema) {
|
|
96
|
+
const mcpPluginSchemaFilePath = path.resolve(installedPluginPackageFolder, jsonManifest.configFileSchema);
|
|
97
|
+
const mcpPluginSchema = await node_core_library_1.JsonSchema.fromFile(mcpPluginSchemaFilePath);
|
|
98
|
+
const rushMcpPluginOptionsFilePath = path.resolve(this._rushWorkspacePath, `common/config/rush-mcp/${jsonManifest.pluginName}.json`);
|
|
99
|
+
// Example: /path/to/my-repo/common/config/rush-mcp/rush-mcp-example-plugin.json
|
|
100
|
+
rushMcpPluginOptions = await node_core_library_1.JsonFile.loadAndValidateAsync(rushMcpPluginOptionsFilePath, mcpPluginSchema);
|
|
101
|
+
}
|
|
102
|
+
const fullEntryPointPath = path.join(installedPluginPackageFolder, jsonManifest.entryPoint);
|
|
103
|
+
let pluginFactory;
|
|
104
|
+
try {
|
|
105
|
+
const entryPointModule = require(fullEntryPointPath);
|
|
106
|
+
if (entryPointModule.default === undefined) {
|
|
107
|
+
throw new Error('The commonJS "default" export is missing');
|
|
108
|
+
}
|
|
109
|
+
pluginFactory = entryPointModule.default;
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
throw new Error(`Unable to load plugin entry point at ${fullEntryPointPath}:\n` +
|
|
113
|
+
RushMcpPluginLoader._formatError(e));
|
|
114
|
+
}
|
|
115
|
+
const session = new RushMcpPluginSession_1.RushMcpPluginSessionInternal(this._mcpServer);
|
|
116
|
+
let plugin;
|
|
117
|
+
try {
|
|
118
|
+
plugin = pluginFactory(session, rushMcpPluginOptions);
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
throw new Error(`Error invoking entry point for plugin ${jsonManifest.pluginName}:\n` +
|
|
122
|
+
RushMcpPluginLoader._formatError(e));
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
await plugin.onInitializeAsync();
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
throw new Error(`Error occurred in onInitializeAsync() for plugin ${jsonManifest.pluginName}:\n` +
|
|
129
|
+
RushMcpPluginLoader._formatError(e));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.RushMcpPluginLoader = RushMcpPluginLoader;
|
|
135
|
+
RushMcpPluginLoader._rushMcpJsonSchema = node_core_library_1.JsonSchema.fromLoadedObject(rush_mcp_schema_json_1.default);
|
|
136
|
+
RushMcpPluginLoader._rushMcpPluginSchemaObject = node_core_library_1.JsonSchema.fromLoadedObject(rush_mcp_plugin_schema_json_1.default);
|
|
137
|
+
//# 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 'path';\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';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\n\nimport type { IRushMcpPlugin, RushMcpPluginFactory } from './IRushMcpPlugin';\nimport { RushMcpPluginSessionInternal } from './RushMcpPluginSession';\n\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,27 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
2
|
+
import type { IRushMcpTool } from './IRushMcpTool';
|
|
3
|
+
import type { zodModule } from './zodTypes';
|
|
4
|
+
/**
|
|
5
|
+
* Each plugin gets its own session.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface IRegisterToolOptions {
|
|
10
|
+
toolName: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Each plugin gets its own session.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class RushMcpPluginSession {
|
|
19
|
+
readonly zod: typeof zodModule;
|
|
20
|
+
abstract registerTool(options: IRegisterToolOptions, tool: IRushMcpTool): void;
|
|
21
|
+
}
|
|
22
|
+
export declare class RushMcpPluginSessionInternal extends RushMcpPluginSession {
|
|
23
|
+
private readonly _mcpServer;
|
|
24
|
+
constructor(mcpServer: McpServer);
|
|
25
|
+
registerTool(options: IRegisterToolOptions, tool: IRushMcpTool): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=RushMcpPluginSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RushMcpPluginSession.d.ts","sourceRoot":"","sources":["../../src/pluginFramework/RushMcpPluginSession.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,8BAAsB,oBAAoB;IACxC,SAAgB,GAAG,EAAE,OAAO,SAAS,CAAO;aAC5B,YAAY,CAAC,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;CACtF;AAED,qBAAa,4BAA6B,SAAQ,oBAAoB;IACpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;gBAEpB,SAAS,EAAE,SAAS;IAKvB,YAAY,CAAC,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;CAYtF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.RushMcpPluginSessionInternal = exports.RushMcpPluginSession = void 0;
|
|
39
|
+
const zod = __importStar(require("zod"));
|
|
40
|
+
/**
|
|
41
|
+
* Each plugin gets its own session.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
class RushMcpPluginSession {
|
|
46
|
+
constructor() {
|
|
47
|
+
this.zod = zod;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.RushMcpPluginSession = RushMcpPluginSession;
|
|
51
|
+
class RushMcpPluginSessionInternal extends RushMcpPluginSession {
|
|
52
|
+
constructor(mcpServer) {
|
|
53
|
+
super();
|
|
54
|
+
this._mcpServer = mcpServer;
|
|
55
|
+
}
|
|
56
|
+
registerTool(options, tool) {
|
|
57
|
+
if (options.description) {
|
|
58
|
+
this._mcpServer.tool(options.toolName, options.description, tool.schema.shape, tool.executeAsync.bind(tool));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this._mcpServer.tool(options.toolName, tool.schema.shape, tool.executeAsync.bind(tool));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.RushMcpPluginSessionInternal = RushMcpPluginSessionInternal;
|
|
66
|
+
//# 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,yCAA2B;AAgB3B;;;;GAIG;AACH,MAAsB,oBAAoB;IAA1C;QACkB,QAAG,GAAqB,GAAG,CAAC;IAE9C,CAAC;CAAA;AAHD,oDAGC;AAED,MAAa,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;AApBD,oEAoBC","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,9 @@
|
|
|
1
|
+
import type * as zod from 'zod';
|
|
2
|
+
export type { zod as zodModule };
|
|
3
|
+
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types';
|
|
4
|
+
export { CallToolResultSchema };
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export type CallToolResult = zod.infer<typeof CallToolResultSchema>;
|
|
9
|
+
//# sourceMappingURL=zodTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodTypes.d.ts","sourceRoot":"","sources":["../../src/pluginFramework/zodTypes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,GAAG,MAAM,KAAK,CAAC;AAChC,YAAY,EAAE,GAAG,IAAI,SAAS,EAAE,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CallToolResultSchema = void 0;
|
|
6
|
+
const types_1 = require("@modelcontextprotocol/sdk/types");
|
|
7
|
+
Object.defineProperty(exports, "CallToolResultSchema", { enumerable: true, get: function () { return types_1.CallToolResultSchema; } });
|
|
8
|
+
//# 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;;;AAK3D,2DAAuE;AAE9D,qGAFA,4BAAoB,OAEA","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';\nexport type { zod as zodModule };\n\nimport { CallToolResultSchema } from '@modelcontextprotocol/sdk/types';\n\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
|
+
}
|
package/lib/server.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
export declare class RushMCPServer extends McpServer {
|
|
3
3
|
private _rushWorkspacePath;
|
|
4
4
|
private _tools;
|
|
5
|
+
private _pluginLoader;
|
|
5
6
|
constructor(rushWorkspacePath: string);
|
|
7
|
+
startAsync(): Promise<void>;
|
|
6
8
|
private _initializeTools;
|
|
7
9
|
private _registerTools;
|
|
8
10
|
}
|
package/lib/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAYpE,qBAAa,aAAc,SAAQ,SAAS;IAC1C,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,aAAa,CAAsB;gBAExB,iBAAiB,EAAE,MAAM;IAU/B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOxC,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,cAAc;CAOvB"}
|
package/lib/server.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.RushMCPServer = void 0;
|
|
6
6
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
7
7
|
const tools_1 = require("./tools");
|
|
8
|
+
const RushMcpPluginLoader_1 = require("./pluginFramework/RushMcpPluginLoader");
|
|
8
9
|
class RushMCPServer extends mcp_js_1.McpServer {
|
|
9
10
|
constructor(rushWorkspacePath) {
|
|
10
11
|
super({
|
|
@@ -13,8 +14,12 @@ class RushMCPServer extends mcp_js_1.McpServer {
|
|
|
13
14
|
});
|
|
14
15
|
this._tools = [];
|
|
15
16
|
this._rushWorkspacePath = rushWorkspacePath;
|
|
17
|
+
this._pluginLoader = new RushMcpPluginLoader_1.RushMcpPluginLoader(this._rushWorkspacePath, this);
|
|
18
|
+
}
|
|
19
|
+
async startAsync() {
|
|
16
20
|
this._initializeTools();
|
|
17
21
|
this._registerTools();
|
|
22
|
+
await this._pluginLoader.loadAsync();
|
|
18
23
|
}
|
|
19
24
|
_initializeTools() {
|
|
20
25
|
this._tools.push(new tools_1.RushConflictResolverTool());
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAoE;AACpE,mCAQiB;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAoE;AACpE,mCAQiB;AACjB,+EAA4E;AAE5E,MAAa,aAAc,SAAQ,kBAAS;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,yCAAmB,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,gCAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,8BAAsB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gCAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gCAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,oBAAY,EAAE,CAAC,CAAC;IACvC,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;AAtCD,sCAsCC","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';\nimport {\n type BaseTool,\n RushConflictResolverTool,\n RushMigrateProjectTool,\n RushCommandValidatorTool,\n RushWorkspaceDetailsTool,\n RushProjectDetailsTool,\n RushDocsTool\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 this._tools.push(new RushDocsTool());\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/start.js
CHANGED
|
@@ -1,16 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
4
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const process = __importStar(require("process"));
|
|
40
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
41
|
+
const loader_1 = require("@rushstack/rush-sdk/loader");
|
|
5
42
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
43
|
const log_1 = require("./utilities/log");
|
|
7
|
-
const server_1 = require("./server");
|
|
8
44
|
const main = async () => {
|
|
9
45
|
const rushWorkspacePath = process.argv[2];
|
|
10
46
|
if (!rushWorkspacePath) {
|
|
11
47
|
throw new Error('Please provide workspace root path as the first argument');
|
|
12
48
|
}
|
|
13
|
-
const
|
|
49
|
+
const rushWorkspaceFullPath = path.resolve(rushWorkspacePath);
|
|
50
|
+
if (!(await node_core_library_1.FileSystem.existsAsync(rushWorkspaceFullPath))) {
|
|
51
|
+
throw new Error('The specified workspace root path does not exist:\n ' + JSON.stringify(rushWorkspacePath));
|
|
52
|
+
}
|
|
53
|
+
// Load rush-sdk from the specified repository
|
|
54
|
+
await loader_1.RushSdkLoader.loadAsync({
|
|
55
|
+
rushJsonSearchFolder: rushWorkspaceFullPath
|
|
56
|
+
});
|
|
57
|
+
const RushMCPServerClass = (await Promise.resolve().then(() => __importStar(require('./server')))).RushMCPServer;
|
|
58
|
+
const server = new RushMCPServerClass(rushWorkspaceFullPath);
|
|
59
|
+
await server.startAsync();
|
|
14
60
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
15
61
|
await server.connect(transport);
|
|
16
62
|
(0, log_1.log)('Rush MCP Server running on stdio');
|
package/lib/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAC7B,iDAAmC;AACnC,oEAA0D;AAC1D,uDAA2D;AAC3D,wEAAiF;AAEjF,yCAAsC;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,8BAAU,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,sBAAa,CAAC,SAAS,CAAC;QAC5B,oBAAoB,EAAE,qBAAqB;KAC5C,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAyB,CAAC,wDAAa,UAAU,GAAC,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,+BAAoB,EAAE,CAAC;IACnE,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,IAAA,SAAG,EAAC,kCAAkC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,IAAA,SAAG,EAAC,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 'path';\nimport * as process from 'process';\nimport { FileSystem } from '@rushstack/node-core-library';\nimport { RushSdkLoader } from '@rushstack/rush-sdk/loader';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/mcp-server",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A Model Context Protocol server implementation for Rush",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rush",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"monorepo",
|
|
10
10
|
"server"
|
|
11
11
|
],
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"typings": "dist/mcp-server.d.ts",
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "https://github.com/microsoft/rushstack.git",
|
|
@@ -34,8 +36,8 @@
|
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"typescript": "~5.8.2",
|
|
36
38
|
"@types/node": "20.17.19",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
+
"@rushstack/heft": "0.73.6",
|
|
40
|
+
"local-node-rig": "1.0.0"
|
|
39
41
|
},
|
|
40
42
|
"scripts": {
|
|
41
43
|
"build": "heft build --clean",
|