npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

webmcp-kit

v0.1.1

Published

Build and test WebMCP tools — in any browser

Readme

webmcp-kit

npm version npm downloads bundle size license: MIT types: TypeScript

Type-safe WebMCP tools with Zod.

What is WebMCP?

WebMCP is a browser API that lets websites expose tools to AI agent, developed under the WebML working group.

The API adds navigator.modelContext, which websites use to register tools that agents can discover and call. Think of it like making your site's functionality available to AI assistants.

Major browsers are starting to experiment with implementations.

What does webmcp-kit do?

webmcp-kit wraps the raw WebMCP API to make building tools easier:

  • Zod schemas: Define inputs once, get JSON Schema conversion and TypeScript inference
  • Built-in validation: Inputs are validated against your schema before execute runs
  • Less boilerplate: Feature detection, response formatting, and registration handled for you
  • Automatic feature detection: Works when the API exists, falls back gracefully when it doesn't
  • Dev panel: Test and debug tools in the browser without needing a real agent
import { defineTool } from 'webmcp-kit';
import { z } from 'zod';

const addToCart = defineTool({
  name: 'addToCart',
  description: 'Add a product to cart',
  inputSchema: z.object({
    productId: z.string(),
    quantity: z.number().min(1),
  }),
  execute: async ({ productId, quantity }) => {
    // productId and quantity are typed
    return `Added ${quantity}x ${productId}`;
  },
});

addToCart.register();

Install

npm install webmcp-kit zod

Requires Zod v4.

Usage

Define a Tool

import { defineTool } from 'webmcp-kit';
import { z } from 'zod';

const searchProducts = defineTool({
  name: 'searchProducts',
  description: 'Search the product catalog',
  inputSchema: z.object({
    query: z.string().describe('Search query'),
    limit: z.number().optional().default(10),
  }),
  execute: async ({ query, limit }) => {
    const results = await db.products.search(query, limit);
    return JSON.stringify(results);
  },
});

searchProducts.register();

The schema is converted to JSON Schema for the WebMCP API. Your execute function receives typed inputs.

User Interaction

Tools can request confirmation or input from the user:

const checkout = defineTool({
  name: 'checkout',
  description: 'Complete purchase',
  inputSchema: z.object({ cartId: z.string() }),
  execute: async ({ cartId }, agent) => {
    const { confirmed } = await agent.requestUserInteraction({
      prompt: 'Confirm purchase?',
      type: 'confirmation',
    });

    if (!confirmed) return 'Cancelled';

    await processOrder(cartId);
    return 'Order placed';
  },
});

Response Helpers

import { textContent, jsonContent, errorContent } from 'webmcp-kit';

// String responses are auto-wrapped, but you can be explicit:
return textContent('Done');
return jsonContent({ status: 'ok' });
return errorContent('Something went wrong');

Dev Panel

Test tools without a real agent:

import { enableDevMode } from 'webmcp-kit/devtools';

enableDevMode();

This injects a panel that lists your tools, generates input forms from schemas, and lets you execute them.

API

defineTool(options)

const tool = defineTool({
  name: string,
  description: string,
  inputSchema: ZodSchema,
  execute: (input, agent) => Promise<string | ToolResponse>,
  annotations?: ToolAnnotations,
});

tool.register();   // Add to navigator.modelContext
tool.unregister(); // Remove from navigator.modelContext
tool.execute(input); // Call directly (for testing)

enableDevMode()

import { enableDevMode } from 'webmcp-kit/devtools';

enableDevMode();

How It Works

defineTool() creates a tool object. When you call .register():

  1. It checks if navigator.modelContext exists
  2. If yes, registers with the native API
  3. If no, registers with an internal mock (so the dev panel still works)

Your code doesn't change based on environment. When browsers ship WebMCP support, the same code will use the real API.

Examples

See examples/pizza-shop for a working demo, with dev mode enabled. It shows a pizza ordering flow with multiple tools (getMenu, addToCart, checkout) and includes setup instructions for testing with native WebMCP.

Support

If you find webmcp-kit useful:

  • Star the repo: It helps others discover the project
  • Report issues: Found a bug or have a feature request? Open an issue

License

MIT