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

@mcp-b/webmcp-types

v5.1.0

Published

Strict TypeScript type definitions for the WebMCP core API (document.modelContext)

Downloads

315,282

Readme

@mcp-b/webmcp-types

TypeScript contracts for the current WebMCP API on document.modelContext. This package emits declarations only and has no runtime side effects.

The WebMCP draft is authoritative for the browser API. MCP-B extension types are kept separate from that standard surface.

Install

pnpm add -D @mcp-b/webmcp-types

Use a production dependency when your published declarations reference these types.

Activate the browser globals

Choose one activation method:

{
  "compilerOptions": {
    "types": ["@mcp-b/webmcp-types"]
  }
}
/// <reference types="@mcp-b/webmcp-types" />
import type {} from '@mcp-b/webmcp-types';

Activation adds the canonical document.modelContext type and the optional deprecated navigator compatibility surfaces.

Register a standard tool

import type { JsonSchemaForInference } from '@mcp-b/webmcp-types';

const inputSchema = {
  type: 'object',
  properties: {
    query: { type: 'string' },
    limit: { type: 'integer', minimum: 1 },
  },
  required: ['query'],
  additionalProperties: false,
} as const satisfies JsonSchemaForInference;

const controller = new AbortController();

await document.modelContext.registerTool(
  {
    name: 'search',
    description: 'Search indexed docs',
    inputSchema,
    execute: ({ query, limit }) => ({ query, limit }),
  },
  { signal: controller.signal }
);

controller.abort();

The callback input is { query: string; limit?: number }. registerTool() returns Promise<void>; aborting the registration signal removes the tool.

Type surfaces

| Type | Contract | | ---------------------------- | ---------------------------------------------------------------- | | ModelContext | Current standard document.modelContext producer API | | ChromeModelContext | Standard API plus feature-detectable Chromium executeTool() | | ModelContextExtensions | MCP-B registration and listTools() extensions | | ModelContextWithExtensions | Standard event/discovery shape with MCP-B registration overloads | | ModelContextTesting | Deprecated optional testing compatibility surface |

Both tool descriptor callbacks receive one input argument. MCP-B ToolDescriptor may also declare outputSchema.

Schema inference

JsonSchemaForInference is the JSON Schema type owned by @modelcontextprotocol/server. The local inference helpers add no competing schema vocabulary.

InferJsonSchema<T> supports:

  • type, including multi-type arrays such as ['string', 'null']
  • const and enum
  • object properties, required, and additionalProperties
  • array items
  • boolean subschemas

Typeless object keywords infer an object. Unsupported compositions such as $ref and oneOf remain unknown.

InferArgsFromInputSchema<T> keeps object and array inputs. A widened or runtime-defined InputSchema safely falls back to WebMcpToolInput, which is Record<string, unknown> | unknown[].

MCP-B output inference uses ToolResultFromOutputSchema<T> or ToolDescriptorFromSchema<TInput, TOutput>. outputSchema is not part of the current standard ModelContextTool dictionary.

Main exports

| Export | Purpose | | ---------------------------- | -------------------------------------------- | | ModelContextTool | Standard one-argument tool dictionary | | RegisteredTool | Metadata returned by getTools() | | ToolDescriptor | Explicit MCP-B input and result types | | ToolDescriptorFromSchema | MCP-B input and output schema inference | | ToolListItem | Metadata returned by listTools() | | InputSchema | Broad runtime JSON Schema boundary | | JsonSchemaForInference | Canonical upstream JSON Schema type | | InferJsonSchema | Infer a value from supported schema keywords | | InferArgsFromInputSchema | Infer an object or array callback input | | ToolResultFromOutputSchema | Infer MCP structuredContent | | CallToolResult | Canonical MCP tool result | | RegistrationHandle | Handle returned by prompt/resource helpers |

Compatibility

  • navigator.modelContext remains optional and deprecated.
  • navigator.modelContextTesting remains optional and deprecated.
  • unregisterTool(), provideContext(), and clearContext() are absent. Use an AbortSignal to own a tool registration.
  • Strict and strictNullChecks: false projects are covered by package type tests.

See the package reference and strict core versus MCP-B extensions.

License

MIT