forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.ts
More file actions
50 lines (41 loc) · 1.31 KB
/
Copy pathcli.ts
File metadata and controls
50 lines (41 loc) · 1.31 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
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { Argv } from 'yargs';
import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
import { isTTY } from '../../utilities/tty';
import { createMcpServer } from './mcp-server';
const INTERACTIVE_MESSAGE = `
To start using the Angular CLI MCP Server, add this configuration to your host:
{
"mcpServers": {
"angular-cli": {
"command": "npx",
"args": ["@angular/cli", "mcp"]
}
}
}
Exact configuration may differ depending on the host.
`;
export default class McpCommandModule extends CommandModule implements CommandModuleImplementation {
command = 'mcp';
describe = false as const;
longDescriptionPath = undefined;
builder(localYargs: Argv): Argv {
return localYargs;
}
async run(): Promise<void> {
if (isTTY()) {
this.context.logger.info(INTERACTIVE_MESSAGE);
return;
}
const server = await createMcpServer({ workspace: this.context.workspace });
const transport = new StdioServerTransport();
await server.connect(transport);
}
}