Skip to content

Commit 8605249

Browse files
committed
feat(@angular/cli): add --local-only option to mcp command
This change introduces a `--local-only` flag to the `ng mcp` command. When this flag is present, the MCP server will only register tools that are explicitly marked as `isLocalOnly`. This provides a way for host applications to connect to the Angular CLI MCP server in an offline or restricted environment, ensuring that no tools that require internet access are exposed.
1 parent 1ba216a commit 8605249

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

packages/angular/cli/src/commands/mcp/cli.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,32 @@ export default class McpCommandModule extends CommandModule implements CommandMo
3333
longDescriptionPath = undefined;
3434

3535
builder(localYargs: Argv): Argv {
36-
return localYargs.option('read-only', {
37-
type: 'boolean',
38-
default: false,
39-
describe: 'Only register read-only tools.',
40-
});
36+
return localYargs
37+
.option('read-only', {
38+
type: 'boolean',
39+
default: false,
40+
describe: 'Only register read-only tools.',
41+
})
42+
.option('local-only', {
43+
type: 'boolean',
44+
default: false,
45+
describe: 'Only register tools that do not require internet access.',
46+
});
4147
}
4248

43-
async run(options: { readOnly: boolean }): Promise<void> {
49+
async run(options: { readOnly: boolean; localOnly: boolean }): Promise<void> {
4450
if (isTTY()) {
4551
this.context.logger.info(INTERACTIVE_MESSAGE);
4652

4753
return;
4854
}
4955

5056
const server = await createMcpServer(
51-
{ workspace: this.context.workspace, readOnly: options.readOnly },
57+
{
58+
workspace: this.context.workspace,
59+
readOnly: options.readOnly,
60+
localOnly: options.localOnly,
61+
},
5262
this.context.logger,
5363
);
5464
const transport = new StdioServerTransport();

packages/angular/cli/src/commands/mcp/mcp-server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export async function createMcpServer(
2222
context: {
2323
workspace?: AngularWorkspace;
2424
readOnly?: boolean;
25+
localOnly?: boolean;
2526
},
2627
logger: { warn(text: string): void },
2728
): Promise<McpServer> {
@@ -56,6 +57,10 @@ export async function createMcpServer(
5657
toolDeclarations = toolDeclarations.filter((tool) => tool.isReadOnly);
5758
}
5859

60+
if (context.localOnly) {
61+
toolDeclarations = toolDeclarations.filter((tool) => tool.isLocalOnly);
62+
}
63+
5964
await registerTools(
6065
server,
6166
{

0 commit comments

Comments
 (0)