Skip to content

refactor(@angular/cli): declaratively register MCP server tools #30858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

clydin
Copy link
Member

@clydin clydin commented Aug 8, 2025

Changes to a declarative approach for registering tools with the MCP server.
Previously, each tool was registered imperatively. This change refactors each tool to export a ToolDeclaration object, which encapsulates its name, description, schema, and factory function. A new central registerTools function now iterates over these declarations, simplifying the server setup and ensuring a consistent registration process.
This approach improves maintainability, readability, and type safety by co-locating all aspects of a tool's definition.

Introduces a --read-only flag to the ng mcp command. When this flag is present, the MCP server will only register tools that are explicitly marked as read-only.
This provides a way for host applications to connect to the Angular CLI MCP server with a restricted set of capabilities, ensuring that no tools capable of modifying the user's workspace are exposed.

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.

Introduces an --experimental-tool flag (with a -E alias) to the ng mcp command. This flag allows users to enable specific experimental tools by providing their names.
Experimental tools are kept separate from the main toolset and are only registered if explicitly enabled via this option. This provides a mechanism for safely developing and testing new tools without exposing them to all users by default.

REVIEWER NOTE: Use hide whitespace option

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 8, 2025
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/cli labels Aug 8, 2025
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 8, 2025
@clydin clydin force-pushed the mcp/declarative-registration branch 2 times, most recently from 481ce18 to 540b6f0 Compare August 9, 2025 00:08
clydin added 4 commits August 8, 2025 20:18
Changes to a declarative approach for registering tools with the MCP server.
Previously, each tool was registered imperatively. This change refactors each tool to export a `ToolDeclaration` object, which encapsulates its name, description, schema, and factory function. A new central `registerTools` function now iterates over these declarations, simplifying the server setup and ensuring a consistent registration process.
This approach improves maintainability, readability, and type safety by co-locating all aspects of a tool's definition.
This change introduces a `--read-only` flag to the `ng mcp` command. When this flag is present, the MCP server will only register tools that are explicitly marked as read-only.

This provides a way for host applications to connect to the Angular CLI MCP server with a restricted set of capabilities, ensuring that no tools capable of modifying the user's workspace are exposed.
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.
This change introduces an `--experimental-tool` flag (with a `-E` alias) to the `ng mcp` command. This flag allows users to enable specific experimental tools by providing their names.

Experimental tools are kept separate from the main toolset and are only registered if explicitly enabled via this option. This provides a mechanism for safely developing and testing new tools without exposing them to all users by default.
@clydin clydin force-pushed the mcp/declarative-registration branch from 540b6f0 to 2e9202a Compare August 9, 2025 00:18
This change moves the `find_examples` and `modernize` tools to the experimental toolset. They can now be enabled by passing the `--experimental-tool <tool_name>` flag to the `ng mcp` command.

For backward compatibility, the `find_examples` tool will also be enabled if the `NG_MCP_CODE_EXAMPLES=1` environment variable is set.
@clydin clydin force-pushed the mcp/declarative-registration branch from 2e9202a to 48c852a Compare August 9, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/cli detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant