lucidAGENTS
Packages

@lucid-agents/ap2

Advertise AP2 role metadata in a Lucid Agent Card.

@lucid-agents/ap2 adds AP2 role metadata to an Agent Card. It does not implement AP2 mandates, carts, credentials, payment authorization, or settlement. Use the x402 or MPP extension for payment enforcement.

This is a Next package. Install it from a repository workspace or wait for its version to appear in the Stable release table.

Configure role metadata

import { createAgent } from '@lucid-agents/core';
import { http } from '@lucid-agents/http';
import { ap2 } from '@lucid-agents/ap2';

const runtime = await createAgent({
  name: 'merchant',
  version: '1.0.0',
})
  .use(http())
  .use(
    ap2({
      roles: ['merchant'],
      description: 'Sells typed research capabilities',
      required: true,
    })
  )
  .build();

Supported role labels are:

type AP2Role =
  | 'merchant'
  | 'shopper'
  | 'credentials-provider'
  | 'payment-processor';

The extension adds a descriptor using the AP2 v0.1 specification URI:

{
  "uri": "https://github.com/google-agentic-commerce/ap2/tree/v0.1",
  "description": "Sells typed research capabilities",
  "required": true,
  "params": { "roles": ["merchant"] }
}

An empty roles array adds no descriptor. Rebuilding a card replaces the existing Lucid AP2 descriptor instead of duplicating it.

Public surface

export {
  ap2,
  createAP2Runtime,
  createAgentCardWithAP2,
} from '@lucid-agents/ap2';
export { AP2_EXTENSION_URI } from '@lucid-agents/ap2';
export type {
  AP2Config,
  AP2ExtensionDescriptor,
  AP2ExtensionParams,
  AP2Role,
} from '@lucid-agents/ap2';

See AP2 role metadata for the protocol boundary.

On this page