-
Notifications
You must be signed in to change notification settings - Fork 683
Expand file tree
/
Copy pathserver.ts
More file actions
55 lines (45 loc) · 1.57 KB
/
server.ts
File metadata and controls
55 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import {
type BaseTool,
RushBuildStatusTool,
RushConflictResolverTool,
RushMigrateProjectTool,
RushCommandValidatorTool,
RushWorkspaceDetailsTool,
RushProjectDetailsTool
} from './tools';
import { RushMcpPluginLoader } from './pluginFramework/RushMcpPluginLoader';
export class RushMCPServer extends McpServer {
private _rushWorkspacePath: string;
private _tools: BaseTool[] = [];
private _pluginLoader: RushMcpPluginLoader;
public constructor(rushWorkspacePath: string) {
super({
name: 'rush',
version: '1.0.0'
});
this._rushWorkspacePath = rushWorkspacePath;
this._pluginLoader = new RushMcpPluginLoader(this._rushWorkspacePath, this);
}
public async startAsync(): Promise<void> {
this._initializeTools();
this._registerTools();
await this._pluginLoader.loadAsync();
}
private _initializeTools(): void {
this._tools.push(new RushBuildStatusTool());
this._tools.push(new RushConflictResolverTool());
this._tools.push(new RushMigrateProjectTool(this._rushWorkspacePath));
this._tools.push(new RushCommandValidatorTool());
this._tools.push(new RushWorkspaceDetailsTool());
this._tools.push(new RushProjectDetailsTool());
}
private _registerTools(): void {
process.chdir(this._rushWorkspacePath);
for (const tool of this._tools) {
tool.register(this);
}
}
}