{"_id":"@adipetcu/webmcp-polyfill","_rev":"3-53cc7457bd2a45939f9acc3eec65207b","name":"@adipetcu/webmcp-polyfill","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@adipetcu/webmcp-polyfill","version":"0.1.0","keywords":["webmcp","mcp","model-context-protocol","ai-agent","polyfill","navigator.modelContext","w3c"],"license":"Apache-2.0","_id":"@adipetcu/webmcp-polyfill@0.1.0","maintainers":[{"name":"adipetcu","email":"adrianpetcu92@gmail.com"}],"dist":{"shasum":"67370afb799df38cdc827d525fa9c2d4e8243d9b","tarball":"https://registry.npmjs.org/@adipetcu/webmcp-polyfill/-/webmcp-polyfill-0.1.0.tgz","fileCount":9,"integrity":"sha512-/yNtYipSmaChagMjgU2PCy0+ZeaPUp01L33V7tNzMxXXLbnBybbebxIW9Dsr/dZYoE1TtdskPXrWbKsjM7W5AQ==","signatures":[{"sig":"MEQCIEbGKDLIIA8cPbzs5VN7mhFnGQrQXa3LpZV/hemb7AZKAiB5zmFiw3sKTIIW5Cc1dgQ6z66rPfhPyj46g6sfo+OoYg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47702},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"54cdfecf23d6ac3fcd26f942b5531c5b97ba9e42","scripts":{"dev":"tsup --watch","build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"adipetcu","email":"adrianpetcu92@gmail.com"},"_npmVersion":"10.9.0","description":"Lightweight W3C WebMCP (navigator.modelContext) polyfill for making websites AI-agent-friendly","directories":{},"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/webmcp-polyfill_0.1.0_1771156967577_0.7366955818731722","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@adipetcu/webmcp-polyfill","version":"0.1.1","keywords":["webmcp","mcp","model-context-protocol","ai-agent","polyfill","navigator.modelContext","w3c"],"license":"Apache-2.0","_id":"@adipetcu/webmcp-polyfill@0.1.1","maintainers":[{"name":"adipetcu","email":"adrianpetcu92@gmail.com"}],"dist":{"shasum":"999a25e658b6c017e1137874171f09a676682b39","tarball":"https://registry.npmjs.org/@adipetcu/webmcp-polyfill/-/webmcp-polyfill-0.1.1.tgz","fileCount":9,"integrity":"sha512-+m++9ADTsM/YW1/4qMSvM9xuV7RFzukUljgvwYNgR0951YsZVgWiqVcW65zUg1cDFBcWSnz/iv9erJaQu1LYSQ==","signatures":[{"sig":"MEYCIQDy+NwLoDeCXnk6h0HCzvNPzQJNlrzLIInrVVFxavuejgIhAIkecZ1fbMJ63sX1TYkh34KxM36U0jFg7l11y/hzts8z","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47761},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"11d092da7aab4dbbce9d0d5d1d1c05c8b05be80d","scripts":{"dev":"tsup --watch","build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"adipetcu","email":"adrianpetcu92@gmail.com"},"_npmVersion":"10.9.0","description":"Lightweight W3C WebMCP (navigator.modelContext) polyfill for making websites AI-agent-friendly","directories":{},"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/webmcp-polyfill_0.1.1_1771158865713_0.6074671432722947","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@adipetcu/webmcp-polyfill","version":"0.1.2","description":"Lightweight W3C WebMCP (navigator.modelContext) polyfill for making websites AI-agent-friendly","homepage":"https://github.com/apetcu/webmcp-polyfill","publishConfig":{"access":"public"},"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"build":"tsup","dev":"tsup --watch","prepublishOnly":"npm run build"},"keywords":["webmcp","mcp","model-context-protocol","ai-agent","polyfill","navigator.modelContext","w3c"],"license":"Apache-2.0","devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_id":"@adipetcu/webmcp-polyfill@0.1.2","gitHead":"e0441fd8ccf03cb188a3a7023cc216b6d06cd6b8","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-rerlculNHA/VGMT5BDepcdCQ/A6vUSqPJwFvGQL8KUD7UIDPXXvWCgoiu/1Um4KqIbX+VoGD+fvdPEuzYl03uQ==","shasum":"b019178a5d3e72b2ab972b7d4b7dc69ebb8882ef","tarball":"https://registry.npmjs.org/@adipetcu/webmcp-polyfill/-/webmcp-polyfill-0.1.2.tgz","fileCount":9,"unpackedSize":47840,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDCfXObDXILsX5dqZa02288SblaE+vTdnt+iGUJttYGQAIhAO0zGjV923L9kqf0dfNTDlRTkY+Q/sd3vzN09qQO/3CO"}]},"_npmUser":{"name":"adipetcu","email":"adrianpetcu92@gmail.com"},"directories":{},"maintainers":[{"name":"adipetcu","email":"adrianpetcu92@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/webmcp-polyfill_0.1.2_1771269079679_0.5203089742880125"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-15T12:02:47.501Z","modified":"2026-02-16T19:11:19.916Z","0.1.0":"2026-02-15T12:02:47.739Z","0.1.1":"2026-02-15T12:34:25.895Z","0.1.2":"2026-02-16T19:11:19.815Z"},"license":"Apache-2.0","keywords":["webmcp","mcp","model-context-protocol","ai-agent","polyfill","navigator.modelContext","w3c"],"description":"Lightweight W3C WebMCP (navigator.modelContext) polyfill for making websites AI-agent-friendly","maintainers":[{"name":"adipetcu","email":"adrianpetcu92@gmail.com"}],"readme":"# @adipetcu/webmcp-polyfill\n\nLightweight W3C WebMCP (`navigator.modelContext`) polyfill for making websites AI-agent-friendly.\n\n## Overview\n\nWebMCP (Model Context Protocol for the Web) is a proposed standard that allows websites to expose tools and context to AI agents. This polyfill provides a compatible implementation of `navigator.modelContext` for browsers that don't yet support it natively.\n\n## Installation\n\n```bash\nnpm install @adipetcu/webmcp-polyfill\n```\n\n## Usage\n\n```ts\nimport { initPolyfill, createModelContextClient } from \"@adipetcu/webmcp-polyfill\";\n\n// Initialize the polyfill early (e.g., in your app entry point)\n// Safe to call multiple times; subsequent calls are no-ops\ninitPolyfill();\n\n// Define tools that AI agents can use\nconst tools = [\n  {\n    name: \"search\",\n    description: \"Search for products on the site\",\n    inputSchema: {\n      type: \"object\",\n      properties: {\n        query: { type: \"string\", description: \"Search query\" },\n      },\n      required: [\"query\"],\n    },\n    execute: async (input, client) => ({\n      content: [{ type: \"text\", text: `Results for: ${input.query}` }],\n    }),\n  },\n];\n\n// Provide context to agents\nnavigator.modelContext.provideContext({ tools });\n```\n\n### Dynamic tool registration\n\n```ts\n// Register a tool at runtime\nnavigator.modelContext.registerTool({\n  name: \"getUser\",\n  description: \"Get current user info\",\n  execute: async () => ({\n    content: [{ type: \"text\", text: JSON.stringify(user) }],\n  }),\n});\n\n// Unregister when no longer needed\nnavigator.modelContext.unregisterTool(\"getUser\");\n```\n\n### Clearing context\n\n```ts\nnavigator.modelContext.clearContext();\n```\n\n## API\n\n- **`initPolyfill()`** — Adds `navigator.modelContext` if not present. No-op in non-browser environments (SSR).\n\n- **`createModelContextClient()`** — Returns a default client implementation for tool execution. Useful when tools need to request user interaction (e.g., confirmations).\n\n- **`ModelContext.provideContext(options?)`** — Set the initial tools available to agents.\n\n- **`ModelContext.registerTool(tool)`** — Add a tool at runtime.\n\n- **`ModelContext.unregisterTool(name)`** — Remove a registered tool.\n\n- **`ModelContext.clearContext()`** — Clear all base and dynamic tools.\n\n## Debug\n\nIn development, the polyfill exposes a debug object on `window.__webmcp`:\n\n- **`tools`** — Map of all registered tools\n- **`callHistory`** — Array of tool invocations with inputs, results, and errors\n\n## License\n\nApache-2.0 — see [LICENSE](LICENSE) for details.\n","readmeFilename":"README.md","homepage":"https://github.com/apetcu/webmcp-polyfill"}