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-instrument-vite

v0.2.4

Published

Vite Plugin for Zero-Config WebMCP Auto-Instrumentation

Readme

webmcp-instrument-vite

Vite plugin for zero-config WebMCP auto-instrumentation.

Scans your components at build time, proposes MCP tools, and injects them as a virtual module — so AI assistants can interact with your app out of the box.

Install

npm install webmcp-instrument-vite -D
npm install webmcp-instrument-runtime

Setup

1. Configure Vite

// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import webmcp from 'webmcp-instrument-vite'

export default defineConfig({
  plugins: [react(), webmcp()]
})

2. Import the Runtime

To ensure tools are correctly registered (especially outside of browsers that natively support navigator.modelContext), import the runtime in your app's main entry file (e.g., main.tsx or index.js):

// src/main.tsx
import { createRoot } from 'react-dom/client'
import 'webmcp-instrument-runtime' // <-- Add this!
import App from './App'

createRoot(document.getElementById('root')).render(<App />)

Options

| Option | Type | Default | Description | | --------- | ------------------ | ---------------------------------------------- | ------------------------------------------------------------------ | | include | string[] | ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.vue'] | Glob patterns for component files to scan | | inject | 'html' \| 'entry' | 'html' | Injection strategy (see below) | | entry | RegExp \| string | /\/src\/main\.(tsx?\|jsx?)$/ | Entry file pattern (only used with inject: 'entry') |

Injection Strategies

'html' (default) — injects <script type="module" src="/@id/virtual:webmcp-tools"> via Vite's HTML pipeline. Works for all standard Vite apps.

'entry' — prepends import 'virtual:webmcp-tools' to your app's entry file via a transform hook. Use this if 'html' causes issues in your setup (e.g. SSR builds).

// SSR or non-standard entry example
webmcp({ inject: 'entry', entry: 'src/app.tsx' })

Verify

After starting your dev server, open the browser console and check:

// Either of these should exist
window.mcp           // WebMCP polyfill runtime
navigator.modelContext // Chrome native WebMCP API

How it works

  1. Scan — On build start, the plugin globs your component files and parses them for interactive elements (forms, buttons, inputs, etc.)
  2. Propose — Each element is turned into an MCP tool proposal with a name, description, input schema, and risk level
  3. Generate — Tool proposals are compiled into executable JS code (DOM helpers + tool registration)
  4. Inject — The generated code is served as a Vite virtual module (virtual:webmcp-tools) that registers all tools at runtime
  5. HMR — When you edit a component, the virtual module is re-generated and the page hot-reloads

License

MIT