cd /news/developer-tools/webmcp-gen-generate-chrome-webmcp-to… · home topics developer-tools article
[ARTICLE · art-42376] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

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.

read2 min views1 publishedJun 28, 2026

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 crawls live sites to auto-generate tool definitions, and @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 toolsreadOnlyHint

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.

GitHub: oliuntangled/webmcp-gen

npm: webmcp-gen

Not affiliated with or endorsed by Google or the W3C. Built with AI assistance.

── more in #developer-tools 4 stories · sorted by recency
── more on @webmcp-gen 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/webmcp-gen-generate-…] indexed:0 read:2min 2026-06-28 ·