Skip to main content
Working code examples for building and using ABP applications.

Minimal ABP App

The simplest possible ABP implementation: a Markdown to HTML converter.

File Structure

public/index.html

public/abp.json

public/abp-runtime.js

server.js

Run It

Markdown to HTML Converter

A more realistic example using the marked library.

public/index.html

public/abp.json

public/abp-runtime.js

Usage with MCP Bridge

PDF Generator

There are two approaches to PDF generation. The recommended approach is to return HTML content and let the agent or client generate a PDF. The advanced approach uses window.print() as a transport signal when the app needs its own CSS context for rendering. The example below shows the advanced window.print() pattern — useful when the app has specific @media print styles or complex page layout needs. For the simple pattern, see the Markdown Converter example above — the agent calls convert.markdownToHtml to get HTML, then uses a client-side tool to produce a PDF.

Advanced: Transport-Assisted PDF via window.print()

Capability Definition (public/abp.json excerpt)

Handler (public/abp-runtime.js excerpt)

Companion CSS

What the Agent Sees

The ABP client intercepts window.print(), generates a PDF via page.pdf(), and routes the binary data to a file. The agent receives something like:
The agent can then read, attach, or reference the PDF file by path.
This is a transport-assisted capability. The app itself never generates the PDF binary — it only renders HTML into a print-ready container and calls window.print(). Puppeteer-based clients listen for that signal and use page.pdf() (Chrome DevTools Protocol) to produce the actual PDF. This means the app works identically in any ABP-compliant client that supports print interception.

Canvas Chart Renderer

An app that uses the browser’s Canvas API to render charts — a capability that only browsers have.

public/abp.json (excerpt)

public/abp-runtime.js (capability handler excerpt)

This example demonstrates a capability that only a browser can provide — GPU-accelerated canvas rendering with a charting library. The agent receives a PNG image it can save, embed in documents, or send to users.

Multi-Capability App

An app with multiple capabilities.

public/abp-runtime.js

Progress Reporting Example

Simulating a long-running operation with progress updates.
Usage:

Elicitation Example

Requesting input from the agent/user.

Dynamic Capabilities Example

An app that detects browser features at runtime and builds its capability list dynamically. When asynchronous features become available (e.g., after browser AI models finish downloading), the app sends a notifications/capabilities/list_changed notification so the bridge can re-discover capabilities without a full reconnect.

File Structure

public/abp.json (Static Baseline)

The manifest advertises only the capabilities that are always available. Dynamic capabilities are added at runtime during initialize().

public/abp-runtime.js

How It Works

  1. At initialize() time, _detectCapabilities() inspects the browser environment:
    • navigator.ai?.summarizer — Chrome’s built-in Summarizer API
    • navigator.ai?.translator — Chrome’s built-in Translator API
    • navigator.gpu — WebGPU support
  2. Only capabilities whose APIs actually exist in the current browser are included in the response.
  3. After initialization, _watchForCapabilityChanges() polls async readiness. Browser AI models may need to download before they are usable. Once a model reports available === 'readily', the app sends a notifications/capabilities/list_changed notification.
  4. The ABP client receives this notification, calls listCapabilities() to get the updated list, and registers any new tools — all without requiring the agent to reconnect.

What the Agent Sees

On a browser with AI features and WebGPU:
On a browser without AI features:
If a model finishes downloading mid-session, the agent is notified that new tools have become available.

Using ABP with the MCP Bridge

Complete Workflow

Next Steps

Building ABP Web Apps

Build your own ABP-compatible app

MCP Bridge Architecture

Understand how the bridge works

Protocol Overview

Read the full specification