agentronicsDOCS

Getting Started

Install the Agentronics SDK, publish your first governed WebMCP tool, and see agents in the console.

Getting Started

You need a Node 20+ project and two keys from the console's Settings: a publishable key (agtx_pk_…, safe in the browser — list your site's origins on it) and an ingest key (agtx_ik_…, a server-only secret).

Upgrading from 0.6? Read Upgrading to 0.7 first.

Step 1 — Install

npm install @agentronics/sdk

Step 2 — Initialize in the browser

Call Agentronics.init once, as early as possible in your client entry:

import { Agentronics } from '@agentronics/sdk'
 
const client = Agentronics.init({
  publishableKey: process.env.NEXT_PUBLIC_AGENTRONICS_KEY!,
  siteId: 'shop',
  trace: { webhookUrl: '/api/agentronics' }, // your relay, step 4
})

This turns on detection (WebMCP, browser automation, vision models, crawlers). Passing a secret key throws, so leaks fail loudly.

Step 3 — Publish a governed tool

client.registerTool({
  name: 'search_products',
  title: 'Search products',
  description: 'Search the catalogue by keyword; returns matching products with price and availability.',
  inputSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
  annotations: { readOnlyHint: true },
  execute: async ({ query }) => searchCatalogue(query),
})
 
const { registrations } = client.publishToWebMcp() // → document.modelContext.registerTool(…)

Agents in WebMCP browsers can now call the tool, and every call goes through your authorization rules. Don't want to write the tools yourself? Agent Nic in the console reads your repo and opens a pull request with them.

Step 4 — Connect your server

Two pieces: a relay so browser traces reach the console, and middleware that authenticates agents that never run your JavaScript.

// app/api/agentronics/route.ts
import { createTraceRelay } from '@agentronics/sdk/server'
 
export const POST = createTraceRelay({
  url: process.env.AGENTRONICS_API_URL!,
  ingestKey: process.env.AGENTRONICS_INGEST_KEY!,
  siteId: 'shop',
})
// middleware.ts
import { agentronicsMiddleware } from '@agentronics/sdk/next'
 
export default agentronicsMiddleware() // Web Bot Auth + verified crawlers; never blocks

See Connect to the console for agent keys, OAuth, policies and approved tool descriptions.

Step 5 — Confirm it's live

Open your site, then the console's Observability page. Events appear within seconds. If nothing shows up, check that the relay route answers 202, that AGENTRONICS_INGEST_KEY is set on the server, and that the key isn't revoked in Settings.

Next

On this page