@webmcp-js/core
v0.1.4
Published
Type-safe WebMCP toolkit for registering validated, approval-aware browser tools.
Maintainers
Readme
@webmcp-js/core
Type-safe WebMCP toolkit for registering validated, approval-aware browser tools and resources.
Install
pnpm add @webmcp-js/core zodQuick Start
import { createWebMCP, z } from "@webmcp-js/core";
const mcp = createWebMCP({ appName: "Storefront" });
mcp.tool("products.search", {
description: "Search products in the catalog",
input: z.object({ query: z.string(), limit: z.number().default(10) }),
risk: "read",
run: async ({ query, limit }) => productService.search(query, limit)
});Tools are registered with navigator.modelContext when available, and kept as local handles for tests and progressive enhancement when not.
Key Features
- Zod input validation before approval or execution
- Risk-based approval (
read/low/mediumallowed,high/criticalrequire approval) dryRunpreviews effects before the user approvesenabledWhenconditions gate tool availability at runtimeconfirmWhentriggers approval dynamically per call- Resources (static and URI template) for exposing read-only data
createDevAdapter()for an in-browser dev panel during development- Structured
ToolResult<T>with typed error codes - Audit hooks with built-in input redaction
Documentation
Full docs at webmcp.js docs site.
License
MIT.
