@adcp/sdk API Reference - v17.0.0-rc.0
    Preparing search index...

    Function withMCPConnectionScope

    • Isolate connection reuse to one runner/workflow and close it on every exit. Nested callers join the existing scope so a storyboard still gets exactly one reusable session rather than one session per helper layer.

      Every MCP call made inside fn — endpoint probe, capability discovery, tools/list, and tool calls — reuses one negotiated session per (endpoint, credential, tenant headers, signing identity, transport policy). Per-call correlation headers, AbortSignals and timeouts do not choose the session. The scope terminates its sessions once, when fn settles; pass { isolate: true } to force a fresh scope even when called from inside one. Explicit workflows terminate sessions at exit even if an inner call returned submitted/working; the caller owns that lifetime. Implicit task scopes may close only their local clients when their final result remains nonterminal.

      Type Parameters

      • T

      Parameters

      • fn: () => Promise<T>
      • options: { isolate?: boolean } = {}

      Returns Promise<T>

      await withMCPConnectionScope(async () => {
      await client.syncAccounts(accounts);
      await client.getProducts(brief); // same MCP session, one `initialize`
      });