"""Influ2 MCP Server — Person-Based Advertising platform integration.

This module creates the FastMCP server instance and imports all tool modules.
Tools register themselves via the @mcp.tool() decorator when imported.
"""

from __future__ import annotations

from fastmcp import FastMCP

mcp = FastMCP(
    name="Influ2",
    instructions="""\
Influ2 is a Person-Based Advertising (PBA) platform for targeting specific \
individuals at target accounts with personalized ads across LinkedIn, Facebook, \
Google, and display networks. Unlike traditional advertising that targets broad \
audiences, Influ2 shows ads to named people and tracks engagement per-person.

KEY CONCEPTS:
- Client: Your Influ2 account/dashboard. Most users have one. Always needed as client_id.
- Cohort: A campaign audience segment combining targets + buyer journey + ad content. \
  This is the main campaign unit. When users say "campaign", they mean a cohort.
- Target: An individual person to show ads to, identified by external_id (your CRM ID). \
  When users say "audience", "people", or "contacts", they mean targets.
- Content: An ad creative (social image, carousel, video, native, display banner) with \
  copy and landing page. When users say "ad" or "creative", they mean content.
- Asset: An uploaded image or video file used inside content. Has resolution requirements.
- Journey: The sequence of stages a target moves through (warm-up → engagement → \
  re-engagement). Created automatically with cohorts.
- Buying Group: Group of targets at the same company/account. Metrics track reach per BG.
- Job: Async operations (target sync, cohort creation) return job IDs. Compound tools \
  poll these automatically.

TYPICAL WORKFLOWS:
1. Explore: influ2_list_clients → influ2_list_cohorts → influ2_get_cohort_details
2. New campaign: influ2_list_asset_templates → influ2_upload_asset → influ2_create_cohort
3. Update audience: influ2_manage_targets (action='upsert')
4. Add new ad: influ2_upload_asset → influ2_add_content
5. Check performance: influ2_get_cohort_details (includes metrics automatically)

IMPORTANT:
- Always get a client_id first (via influ2_list_clients or INFLU2_CLIENT_ID env var)
- external_id is the critical field for targets — it's your CRM contact/lead ID
- Asset resolution requirements vary by ad format — check influ2_list_asset_templates
- Target operations are async — compound tools poll automatically, but large lists may timeout
""",
)

# Import tool modules — they register themselves via @mcp.tool() decorator
from influ2_mcp.tools import clients  # noqa: E402, F401
from influ2_mcp.tools import cohorts  # noqa: E402, F401
from influ2_mcp.tools import targets  # noqa: E402, F401
from influ2_mcp.tools import contents  # noqa: E402, F401
from influ2_mcp.tools import assets  # noqa: E402, F401
from influ2_mcp.tools import jobs  # noqa: E402, F401
