Skip to content

Adding Integrations

IMPLEMENTED

This guide covers provider integrations (ad platforms, analytics systems, CRMs) and host adapters (Codex, Claude Code, other MCP clients). Keep provider logic and host packaging separate; start with the shared runtime contract described in Agent Orchestration.

Before implementation

  1. Identify the user workflow and smallest useful capability. Separate account discovery, reporting, planning, and state-changing operations.
  2. Verify an official API, SDK, export format, or documented UI workflow. Record the source URL, date checked, supported account/product tier, and limitations. Do not infer an API from a marketing page or reverse-engineer a private endpoint.
  3. Classify each operation as Read-Only, External, or State-Changing. State-changing ad operations require an explicit approval step and safe defaults.
  4. Define data ownership, scopes, credential storage, retention, and failure behavior. Never put real credentials or client exports into fixtures or logs.
  5. Decide whether the capability belongs in a provider-neutral runtime module, an external provider adapter, a host-only package, or only in a skill. Avoid platform abstractions until at least two real providers need the same contract.

Implementation sequence

  1. Write the capability boundary and a minimal request/result schema before coding.
  2. Add provider-specific code behind a narrow interface. Keep domain decisions in MarketingRuntime modules and translate platform objects at the adapter boundary.
  3. Use timeouts, bounded pagination, retry limits, and explicit rate-limit handling. Do not log authorization headers, tokens, or sensitive payloads.
  4. Run the shared safety checks for workspace paths, URLs, and approvals. Read-only APIs must not silently invoke write endpoints.
  5. Expose the operation through CLI, MCP, HTTP, or a native host package only where a documented user need exists. Tool descriptions must name effects and required inputs.
  6. Add synthetic tests for success, empty data, malformed input, permission denial, rate limits, partial results, and API errors. Never make live account calls in unit tests.
  7. Update English and Arabic docs, agent.md routing, tool manifests, examples, troubleshooting, changelog/roadmap if appropriate, and the capability matrix.

Credentials and configuration

  • Document credential names only as blank keys in .env.example; do not add example secrets that look real.
  • Prefer the provider's official OAuth flow and least-privilege scopes. Do not request broad write access for a read-only feature.
  • Keep local credentials in ignored configuration or an OS secret store. Explain how to revoke and rotate them.
  • Redact account IDs and customer data from diagnostics unless the value is explicitly public and needed.

Host adapter requirements

  • Reuse the same runtime method and approval checks used by other interfaces.
  • Document install, update, removal, supported host versions, tool names, permissions, and fallback behavior.
  • Do not add a separate fork of marketing logic to a host plugin. If a plugin merely wraps MCP/skills, keep it thin and explain its incremental benefit.
  • Keep MCP stdout protocol-clean. Send diagnostics to stderr or the host event hook.
  • Add contract tests that compare adapter behavior to the runtime for representative inputs.

Definition of done

  • Tests use synthetic fixtures; no live write is run as verification.
  • Tool and API effects, limits, attribution assumptions, and failure cases are documented.
  • English and Arabic documentation links build in strict mode.
  • Safety, credential hygiene, and approval gates are reviewed.
  • Users can tell what is implemented, what requires an external account/provider, and what is only planned.