webmcp-gen: Generate Chrome WebMCP Tool Definitions from TypeScript A developer released webmcp-gen, a build-time code generation tool that creates WebMCP tool definitions and handler stubs from TypeScript interfaces. The tool complements existing runtime and crawling approaches by enabling static generation for typed APIs, with baked-in security best practices. Version 1.2.0 includes fixes from a 4-agent security audit and Chrome 150 compatibility updates. Chrome 149 shipped WebMCP — a browser-native API that lets web pages expose structured tools to AI agents via navigator.modelContext . The ecosystem is forming fast: webmcp-core https://github.com/keak-ai/webmcp-core crawls live sites to auto-generate tool definitions, and @webmcp-registry/kit https://github.com/WebMCP-Registry/kit provides a runtime SDK with Zod-based defineTool . What's missing is build-time codegen from your existing TypeScript . If you already have typed interfaces for your API, you shouldn't have to rewrite them as Zod schemas or wait for a crawler to discover them. webmcp-gen fills that gap. Write your API as TypeScript interfaces, run one command, get spec-compliant WebMCP tool definitions + handler stubs with security best practices baked in. | Tool | Approach | When to use | |---|---|---| webmcp-core | Crawl a live URL | You have a site, want tools auto-discovered | @webmcp-registry/kit | Zod schemas at runtime | You want runtime registration + React hooks | webmcp-gen | TypeScript interfaces at build time | You have typed TS, want static JSON + stubs | They're complementary — different layers for different workflows. // api.ts / Search products by keyword. / interface SearchProducts { query: string; category?: "electronics" | "clothing" | "home"; limit?: number; } npx webmcp-gen --api api.ts Output: a .webmcp.json definition + a .handler.ts stub with navigator.modelContext.registerTool wired up and ready to implement. requestUserInteraction reminders for mutating tools readOnlyHint annotations for query-only toolsWebMCP allows AI agents to execute tools that affect live web applications. Google advises using human-in-the-loop hooks and protecting against indirect prompt injection. webmcp-gen bakes this into every generated handler stub — mutating tools get requestUserInteraction reminders, freeform inputs get sanitisation warnings. Safe defaults, not afterthoughts. npm install -g webmcp-gen Includes 4 starter templates CRUD, search, form handler, data transformer to get you going: webmcp-gen --template crud-api webmcp-gen --api crud-api.ts MIT licensed. Contributions welcome. The current npm version v1.2.0 has been through a 4-agent security audit covering line-by-line diff scanning, cross-file tracing, removed-behavior analysis, and dedicated security review. 10 findings were fixed before public announcement, including injection hardening in generated code, path traversal protection, and Chrome 150 compatibility the origin trial API moved from navigator.modelContext to document.modelContext . Full changelog in the README https://github.com/oliuntangled/webmcp-gen changelog . GitHub: oliuntangled/webmcp-gen https://github.com/oliuntangled/webmcp-gen npm: webmcp-gen https://www.npmjs.com/package/webmcp-gen Not affiliated with or endorsed by Google or the W3C. Built with AI assistance.