Getting started

Quickstart

Install the browser SDK and record your first WebMCP tool call.

Add your website

Create an account and start a free trial, add your website and copy its public key from Project settings → Setup. It starts with al_pub_ and is safe to commit: it can only send events.

Install the SDK

Load it before any code that registers WebMCP tools.

<script src="https://agentstats.io/sdk/v1.js" data-key="al_pub_…" async></script>

With a package, call init() once in the browser. See Framework guides for where that goes in your stack.

import { AgentStats } from '@agentstats/sdk'

AgentStats.init({ key: 'al_pub_…' })

Register tools as usual

Nothing changes in your tool code. The SDK wraps execute for you.

document.modelContext.registerTool({
  name: 'search_products',
  description: 'Search the catalogue by free-text query. Returns up to 20 products.',
  inputSchema: {
    type: 'object',
    properties: { q: { type: 'string', description: 'Search query' } },
    required: ['q'],
  },
  annotations: { readOnlyHint: true },
  async execute({ q }) {
    return fetch(`/api/search?q=${q}`).then(r => r.json())
  },
})

Check it works

Trigger any tool, then check Active now on your project's Overview; it opens the live feed. Pass debug: true to init() (or data-debug="true" on the script tag) to log each batch to the console.

Arguments are sent as-is by default. If a tool takes emails, passwords or other personal data, read Privacy & data captured before going live.

Next steps