{"_id":"@agentdesksdk/webmcp","name":"@agentdesksdk/webmcp","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@agentdesksdk/webmcp","version":"0.2.0","description":"Capability-virtualization runtime for WebMCP: publish the right tools at the right time, explain capability state, and keep consequential actions under human control.","type":"module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/agentdesksdk/agentdesk.git","directory":"packages/webmcp"},"homepage":"https://github.com/agentdesksdk/agentdesk#readme","bugs":{"url":"https://github.com/agentdesksdk/agentdesk/issues"},"keywords":["webmcp","mcp","model-context","agent","tools","capability","governance"],"sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./package.json":"./package.json"},"main":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18"},"publishConfig":{"access":"public","provenance":true},"scripts":{"build":"tsc -p tsconfig.build.json","prepack":"pnpm run build","test":"vitest run","typecheck":"tsc --noEmit","pack:smoke":"node scripts/pack-smoke.mjs"},"devDependencies":{"@mcp-b/webmcp-polyfill":"5.1.0","@mcp-b/webmcp-types":"5.1.0","@types/node":"^24.3.0","typescript":"^5.9.2","vitest":"^3.2.4","webmcp-types":"0.1.5"},"_id":"@agentdesksdk/webmcp@0.2.0","gitHead":"0e5db9e555f5174f13da975eee28dc67b4d5c1f2","_nodeVersion":"22.23.2","_npmVersion":"10.9.8","dist":{"integrity":"sha512-2YzEuukZZ4x0r9vf0UzIzGzoZ+ESg+ir2y/fI12KyZGKfRHQsu1It1v56i6iSUcZxYe479k3Dk3lzvLEAU7yng==","shasum":"912b60fe0b0bc07dffaf5e02e3c7cdf0dc501cf7","tarball":"https://registry.npmjs.org/@agentdesksdk/webmcp/-/webmcp-0.2.0.tgz","fileCount":112,"unpackedSize":810477,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@agentdesksdk%2fwebmcp@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDXoFoiluPQ/KXPw8Xz+3vDd8xGnOTKjMkegomxFgWIzAIgOukri5dtDKW6Pt5ZNaAlf0us7K9C7kuczjLoT+p7OR4="}]},"_npmUser":{"name":"ameineskinder","email":"amiin1416@gmail.com"},"directories":{},"maintainers":[{"name":"ameineskinder","email":"amiin1416@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/webmcp_0.2.0_1788402691453_0.5408902191218166"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-03T02:31:31.286Z","0.2.0":"2026-09-03T02:31:31.614Z","modified":"2026-09-03T02:31:31.977Z"},"maintainers":[{"name":"ameineskinder","email":"amiin1416@gmail.com"}],"description":"Capability-virtualization runtime for WebMCP: publish the right tools at the right time, explain capability state, and keep consequential actions under human control.","homepage":"https://github.com/agentdesksdk/agentdesk#readme","keywords":["webmcp","mcp","model-context","agent","tools","capability","governance"],"repository":{"type":"git","url":"git+https://github.com/agentdesksdk/agentdesk.git","directory":"packages/webmcp"},"bugs":{"url":"https://github.com/agentdesksdk/agentdesk/issues"},"license":"MIT","readme":"# @agentdesksdk/webmcp\n\nCapability-virtualization runtime for WebMCP pages. Register a large\ncapability catalog once; publish only the relevant few as typed native\ntools, with structured availability reasons, human approval for\nconsequential actions, and an audit trail.\n\n## Installing\n\n```bash\nnpm install @agentdesksdk/webmcp\n```\n\nNo runtime dependencies; Node 18 or newer.\n\n```ts\nimport { createAgentDeskRuntime, defineCapability } from \"@agentdesksdk/webmcp\";\n\nconst runtime = createAgentDeskRuntime({\n  capabilities: [\n    defineCapability({\n      name: \"refund_shipping\",\n      description: \"Refund the shipping fee for an order\",\n      domain: \"shipping\",\n      intents: [\"refund shipping\"],\n      risk: \"CONSEQUENTIAL\",\n      inputSchema: { type: \"object\", required: [\"order_id\"], properties: { order_id: { type: \"string\" } } },\n      execute: (input) => performRefund(input),\n    }),\n  ],\n});\nawait runtime.start(); // registers get_context, find_capabilities, invoke_capability, get_action_status\n```\n\n- `runtime.setContext({ route, state })` — reconcile the surface as the app\n  navigates.\n- `runtime.setExposure(\"flat\" | \"routed\")` — baseline vs virtualized.\n- `runtime.approve(id)` / `runtime.reject(id)` — resolve pending\n  consequential actions (approval re-checks availability first).\n- `runtime.subscribe(listener)` — UI snapshots; unsubscribing never\n  unregisters tools.\n- `runtime.subscribeAudit(listener)` — stream events to your observability\n  backend; `toObservabilityEvent()` maps them to a versioned envelope.\n- `runtime.subscribePresentation(listener)` — optional UI choreography.\n\n## Handlers get the execution context\n\n```ts\nexecute: async (input, { signal, executionId, route, state }) =>\n  fetch(\"/api/refund\", { method: \"POST\", signal }),\n```\n\n`signal` is the WebMCP execution signal linked with the runtime lifecycle,\nso it aborts when the client cancels or the runtime is reset.\n\n## Swap the pieces you disagree with\n\n```ts\ncreateAgentDeskRuntime({\n  capabilities,\n  validate: ajvValidator,          // default: bundled JSON Schema subset\n  policy: ({ capability, input }) => // default: riskBasedPolicy\n    Number(input.amount) > 500\n      ? { kind: \"deny\", reason: \"Refunds above $500 need a manager.\" }\n      : { kind: \"allow\" },\n  exposedTo: [\"https://agent.example\"], // spec: registerTool exposedTo\n});\n```\n\nConsuming other pages' tools is a separate, optional role:\n\n```ts\nimport { createWebMcpClient } from \"@agentdesksdk/webmcp\";\nconst client = createWebMcpClient();\nif (client.features.getTools) {\n  const listed = await client.listTools({ fromOrigins: [\"https://shop.example\"] });\n}\n```\n\nNo React dependency. Only `webmcp-adapter.ts` touches\n`document.modelContext`; tests enforce the boundary. See\n`../../docs/architecture.md`.\n","readmeFilename":"README.md","_rev":"1-329056510efd5fed7093ad3e25e0a7d1"}