@adcp/client API Reference - v4.19.0
    Preparing search index...

    Function adcpError

    • Build an L3-compliant MCP tool error response with all three transport layers:

      1. structuredContent.adcp_error — programmatic extraction (L3)
      2. content[0].text — JSON text fallback (L2)
      3. isError: true — MCP error signal

      Recovery is auto-populated from the standard error code table when not provided.

      Parameters

      Returns AdcpErrorResponse

      import { adcpError } from '@adcp/client';

      server.tool("get_products", schema, async ({ query }) => {
      if (!products.length) {
      return adcpError('PRODUCT_NOT_FOUND', {
      message: 'No products match query',
      field: 'query',
      suggestion: 'Try a broader search term',
      });
      }
      return { content: [...], structuredContent: { products } };
      });