Angular 21 & MCP: The End of 'Manual' Migrations?
Source: Dev.to
The Shift from Manual to Agentic Migrations
Historically, developers copied error messages or file contents into AI tools like ChatGPT, hoping the model could infer the project’s architecture. This approach was helpful but limited—AI had no direct access to the codebase.
With Angular 21, the Angular CLI itself becomes an MCP server (ng mcp). This protocol lets AI agents (e.g., Cursor, Windsurf, VS Code Copilot) interview the project, understand constraints, and run migrations that actually compile.
Before vs. After MCP
| Scenario | Traditional Approach | MCP‑Enabled Approach |
|---|---|---|
| Project discovery | Paste angular.json into chat. | AI asks the CLI: “List all projects in this workspace.” |
| Migration logic | Rigid ng update scripts that often break on custom architectures. | AI fetches real‑time data, runs context‑aware tools, and negotiates refactors. |
Setting Up the MCP Server
The Angular team baked MCP support directly into the CLI. In any Angular 21 workspace, run:
ng mcp
This command generates the configuration snippets required for your IDE; it does not start a daemon.
Example: Configuring Cursor
If you use Cursor, create or edit .cursor/mcp.json at the project root:
{
"mcpServers": {
"angular-cli": {
"command": "npx",
"args": ["-y", "@angular/cli", "mcp"]
}
}
}
Note
The-yflag prevents the “Press y to install” prompt from hanging the background process.
Why MCP Matters: Context‑Aware Migrations
Standard schematics follow a fixed “If A, then B” pattern. In complex enterprise codebases, they often break or produce code that requires manual rewrites. MCP exposes tools that let AI:
- Retrieve the latest Angular team recommendations (
get_best_practices). - Analyze dependency graphs for safe migrations (
onpush_zoneless_migration). - Query offline documentation (
search_documentation).
Example Workflow: Zoneless Migration
- User request: “Migrate
user-profile.tsto Zoneless. Check if it’s safe.” - AI actions:
- Calls
list_projectsto locate the component. - Reads the file and detects an
Observablesubscription inngOnInit. - Queries
get_best_practicesfor async handling in Zoneless.
- Calls
- AI recommendation:
“I detected an unmanaged subscription. In Zoneless, this won’t trigger a render. Convertuser$observableto a Signal usingtoSignal()before switching the change‑detection strategy.”
The AI doesn’t just apply a blind fix; it negotiates the refactor based on the framework’s internal logic.
Leveraging Documentation via MCP
AI agents no longer need to guess API signatures. They can query the local offline documentation index provided by the MCP server.
Prompt example (Cursor with MCP active):
“Refactor
dashboard.component.tsto align with Angular 21 best practices. Use theget_best_practicestool to verify the plan first.”
Resulting actions:
get_best_practicesreveals thatstandalone: true,inject(), and Signals are the recommended patterns.- The AI calls the experimental
modernizetool (v21) to run standard schematics. - Manual clean‑up:
- Convert
constructor(private http: HttpClient)toprivate http = inject(HttpClient). - Transform
BehaviorSubjectstate into a Signal.
- Convert
The final code looks as if it were written for Angular 21 from the start, not merely patched to run.
Future Outlook: Continuous Agentic Upgrades
This release signals a shift in how Google views the CLI—from a pure build tool to an interface for agents. Soon we may see background agents that:
- Open PRs automatically (e.g., “Refactored a
ControlValueAccessorto the new Signal Forms input API.”) - Update configuration files and verify tests after a new Angular version drops.
Recommendations for Teams Moving to Angular 21
- Install the MCP server (
ng mcp). - Configure your AI editor (e.g., Cursor) to use the generated MCP settings.
- Let the AI map your project and propose a migration plan.
- Review and merge the AI‑generated changes—code ownership remains yours, but the grunt work shifts to the machine.