r/angular • • 1h ago

Make Your Angular App Agent-Ready with WebMCP

https://anastasios.theodosiou.me/blog/angular-webmcp-agent-ready-apps?utm_source=reddit&utm_medium=social&utm_campaign=article_share

've been experimenting with Angular 22's experimental WebMCP support and wanted to understand how it works in practice.

The idea behind WebMCP is quite interesting. Instead of relying on the DOM or screenshots to interact with a web application, AI agents can discover and call tools explicitly exposed by the application itself.

To explore this, I built a small Angular todo application exposing seven tools and documented the implementation in a new article.

I cover:
- Application-wide and component-scoped tools
- Integration with Signal Forms
- Dependency injection and tool lifecycle
- Input validation and security considerations
- Unit testing with Vitest and the WebMCP polyfill

Both the specification and Angular's implementation are still experimental, but I think it's worth exploring what this could mean for the way we design frontend applications.

I've shared the implementation details, code examples and demo repository in the article.
Link in the first comment.

#Angular #WebMCP #TypeScript #FrontendDevelopment

0 Upvotes

2 comments sorted by

2

u/GeromeGrignon 1h ago

I don't get why you use 'installWebMCP' with the poly fill.

2

u/anastheo 1h ago

Good question! installWebMCP() is one of the two documented options. The other is the side-effect import u/w3c/webmcp-polyfill/auto. I went with the explicit call to make it visible in the article when the polyfill gets installed (before bootstrap, so tools register against a ready document.modelContext). It also keeps main.ts and the Vitest setup consistent, since there I need to set isSecureContext first.

That said, you're right that it's not ideal for production: a static import always ships the polyfill. The README recommends a conditional import, e.g. if (isSecureContext && !('modelContext' in document)) await import('@w3c/webmcp-polyfill/auto');. I'll update the article to show that. Thanks!