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

@mcptrail/webmcp-kit

v0.1.0

Published

Type-safe defineTool for WebMCP: infer execute() arg types from a JSON Schema, with optional runtime validation. Zero deps.

Downloads

58

Readme

@mcptrail/webmcp-kit

CI License: MIT

Author WebMCP tools with full type safety and zero dependencies. defineTool infers your execute handler's argument type straight from its JSON Schema at the type level — required vs. optional props, primitive types, and even enum literal unions — so the compiler catches a wrong shape before an agent ever calls it. Opt into runtime validation with a single flag.

Install

npm install @mcptrail/webmcp-kit

Usage

import { defineTool, toolset, registerTools } from "@mcptrail/webmcp-kit";

const searchHotels = defineTool({
  name: "search_hotels",
  description: "Search available hotels",
  inputSchema: {
    type: "object",
    properties: {
      city: { type: "string" },
      guests: { type: "integer", minimum: 1 },
      cabin: { type: "string", enum: ["economy", "business"] },
    },
    required: ["city"],
  },
  readOnly: true,
  validate: true, // execute() checks args at runtime and throws on a bad shape
  execute: (args) => {
    // args is typed as { city: string; guests?: number; cabin?: "economy" | "business" }
    return `Searching ${args.city} for ${args.guests ?? 1} guest(s)`;
  },
});

// Register the whole set into navigator.modelContext (a no-op off-page).
registerTools(toolset(searchHotels));

The headline: args above is inferred as { city: string; guests?: number; cabin?: "economy" | "business" } — no manual type annotation, no code generation.

API

| Export | Signature | Notes | |--------|-----------|-------| | defineTool | defineTool(spec) => WebMcpTool | Infers execute(args) from spec.inputSchema. validate: true wraps execute with a runtime guard; readOnly sets annotations.readOnlyHint | | toolset | toolset(...tools) => WebMcpTool[] | Collect tools into an array | | registerTools | registerTools(tools, target?) => void | Register each into (target ?? navigator).modelContext.registerTool when present | | validateArgs | validateArgs(schema, args) => { valid, errors } | Common JSON-Schema subset: type, required, enum, minimum/maximum, minLength/maxLength, nested objects and arrays | | InferArgs<S> | type | The type-level schema → args mapping, exported for your own helpers |

Type inference rules

For an { type: "object", properties, required } schema, each property maps by its typestringstring, number/integernumber, booleanboolean, arrayunknown[], objectRecord<string, unknown>. A statically-known enum of string literals becomes a union of those literals. Keys in required are required; the rest are optional. Non-object schemas infer as unknown.

Development

npm install
npm run typecheck
npm test          # Vitest + jsdom
npm run build     # tsup → dist (ESM + CJS + d.ts)

License

MIT © Zied Guetari