One MCP server that answers questions across Amazon + DSP, Flipkart, Nykaa, Blinkit, Zepto, Instamart, Shopify, Meta, Google and DV360. Vendor data is normalised into one Postgres model. Tools are organised by job, not by vendor, and most of them load only when a question needs them.
Vendors feed one store on a schedule. Tools read the store, never the vendor live, so questions cost no vendor API calls.
flowchart LR
subgraph V["Vendors"]
direction TB
A1["Amazon Ads + SP-API + DSP"]
A2["Meta · Google · DV360"]
A3["Shopify"]
A4["Flipkart (partner / export)"]
A5["Blinkit · Zepto · Instamart · Nykaa
(portal exports, no public API)"]
end
subgraph I["Ingest"]
direction TB
I1["API pullers"]
I2["Report / portal parsers"]
end
subgraph D["Postgres 17 · one data model"]
direction TB
D1["Tenancy: agency → users → advertisers"]
D2["Product master: SKU ↔ ASIN / FSN / item ids"]
D3["Facts: ads · sales · stock · POs · search terms
listing · audience · attribution · reviews"]
D4["Row-level security on advertiser_id"]
end
subgraph M["Hector MCP"]
direction TB
M1["7 core tools, always listed"]
M2["8 groups, loaded on demand
find_capability"]
end
subgraph C["Clients"]
direction TB
C1["Hector chat (AgentUX)"]
C2["Claude.ai / Desktop / Code"]
end
A1 --> I1
A2 --> I1
A3 --> I1
A4 --> I2
A5 --> I2
I1 --> D
I2 --> D
D --> M
M --> C1
M --> C2
Each tool call runs in its own Postgres transaction scoped to the caller's brands. The model gets a compact table back, not raw vendor JSON.
sequenceDiagram participant U as User participant A as Agent (chat / Claude) participant H as Hector MCP participant P as Postgres U->>A: Why is Revitalift soft on Nykaa? A->>H: get_performance (core tool) A->>H: find_capability "keywords, reviews" H-->>A: loads keyword_optimizer + marketplace_listing A->>H: get_keyword_market, get_reviews, get_inventory H->>P: BEGIN READ ONLY · SET LOCAL hector.advertiser_ids = 'loreal_paris' P-->>H: rows for that brand only (RLS) H-->>A: small markdown tables, INR, caveats A-->>U: cause + action (organic rank loss to Competitor C)
Everything a brand owns carries advertiser_id. Vendors are rows (platform = 'blinkit'), not separate tables or tools.
erDiagram
agencies ||--o{ users : employs
agencies ||--o{ advertisers : manages
users ||--o{ user_advertiser_access : "can see"
advertisers ||--o{ user_advertiser_access : ""
advertisers ||--o{ connections : "platform accounts"
advertisers ||--o{ products : sells
products ||--o{ product_map : "ASIN / FSN / item id"
advertisers ||--o{ campaigns : runs
campaigns ||--o{ keyword_targets : bids
campaigns ||--o{ fact_ad_daily : "daily results"
campaigns ||--o{ fact_search_term_daily : "search terms"
products ||--o{ fact_sales_daily : "sell-out"
products ||--o{ fact_listing_daily : "listing health"
products ||--o{ fact_inventory_daily : "darkstore stock"
products ||--o{ fact_fc_inventory_daily : "warehouse stock"
products ||--o{ purchase_orders : "QC POs"
products ||--o{ reviews : reviews
advertisers ||--o{ fact_keyword_market_weekly : "keyword market"
advertisers ||--o{ fact_audience_weekly : audience
advertisers ||--o{ fact_attribution_weekly : "cross-channel"
advertisers ||--o{ fact_qc_market_daily : "QC share"
advertisers ||--o{ advertiser_notes : memory
advertisers {
text id PK
text business_model
numeric target_roas
numeric target_tacos
}
campaigns {
text id PK
text advertiser_id FK
text platform
text ad_type
numeric daily_budget_inr
}
fact_ad_daily {
date date
text campaign_id FK
text sku
text city
numeric spend_inr
bigint orders
numeric ad_revenue_inr
}
fact_search_term_daily {
date date
text campaign_id FK
text keyword
text search_term
numeric spend_inr
bigint orders
}
product_map {
text sku FK
text platform
text platform_item_id
}
| Table | Grain | Answers | Fed by |
|---|---|---|---|
| Tenancy + reference | |||
agencies · users · user_advertiser_access | row per user / grant | who can see which brands (role: admin, account manager, client viewer) | Hector |
advertisers | brand | business model, KPI targets | Hector |
connections | brand × platform | account ids, ingest method, last sync | all |
products · product_map | SKU · SKU × platform | one SKU linked to ASIN, FSN, Blinkit / Zepto / Shopify ids | all |
| Ads | |||
campaigns | campaign | type, objective, status, budget | all ad platforms |
fact_ad_daily | day × campaign × SKU × city | spend, clicks, ROAS, viewability, VCR, DPV, new-to-brand | Amazon, DSP, Flipkart, Nykaa, QC, Meta, Google, DV360 |
keyword_targets | keyword × campaign | bids, match types, negatives | search platforms |
fact_search_term_daily | day × campaign × search term | what shoppers typed, wasted vs converting spend (reconciles to campaign spend) | Amazon, Flipkart, Nykaa, QC, Google |
fact_keyword_market_weekly | week × platform × term | search volume, our click/conversion share, top competitor | Amazon, Flipkart, Nykaa |
| Sales + listings | |||
fact_sales_daily | day × platform × SKU × city | organic + paid sell-out, TACoS, MER | Amazon, Flipkart, QC, Nykaa, Shopify |
fact_listing_daily | day × platform × SKU | sessions, conversion, Buy Box, BSR, rating, returns | Amazon, Flipkart, Shopify |
reviews | review | rating, theme, sentiment, text | Amazon, Flipkart, Nykaa |
| Stock + supply | |||
fact_inventory_daily | day × QC platform × SKU × city | darkstore availability (OSA), units on hand | Blinkit, Zepto, Instamart |
fact_fc_inventory_daily | day × platform × SKU × location | FBA / Flipkart / Shopify available, inbound, days of cover | Amazon, Flipkart, Shopify |
purchase_orders | PO | fill rate, expiries | Blinkit, Zepto, Instamart |
fact_qc_market_daily | day × QC platform × city | category market share | Blinkit, Zepto, Instamart |
| Audience + cross-channel | |||
fact_audience_weekly | week × platform × segment | age, gender, device, city tier, new vs returning | Meta, Google, DV360, Amazon DSP |
fact_attribution_weekly | week × source channel | Meta / YouTube / DV360 clicks that became Amazon sales | Amazon Attribution |
fact_conversion_paths | month × path | ad sequences before purchase, order value, days to convert | AMC |
| Memory + audit | |||
advertiser_notes · action_log | note · change | client instructions; every budget / keyword change | Hector |
Grouped by the job the user is doing. The platform registry decides which groups a user is offered, so a Meta-only brand never sees quick-commerce tools.
| Group | Tools | Loaded |
|---|---|---|
core | list_accounts, get_performance, morning_check, get_brand_context, save_note, find_capability, run_capability | always |
inventory_supply | get_inventory, get_purchase_orders | on demand |
marketplace_listing | get_listing_health, get_reviews | on demand |
digital_shelf | get_share_of_voice, get_market_share | on demand |
keyword_optimizer | get_search_terms, get_keyword_market, recommend_keywords, update_keywords | on demand |
audience_insights | get_audience, get_cross_channel | on demand |
campaign_actions | list_campaigns, update_campaign | on demand, not for client logins |
sql_explorer | run_query (read-only) | on demand |
reference | describe_platforms, describe_data_model, describe_metrics | on demand |
Tools always read Hector's data model, never the vendor directly. Freshness is handled behind the tools, so how a vendor's data arrives can change without changing the MCP.
flowchart LR
Q["Question"] --> T["Tool"]
T --> F{"Data fresh enough?"}
F -- "yes" --> DB[("Hector data model")]
F -- "no · API vendor
Amazon, Meta, Google, Shopify" --> R1["Pull that brand, platform
and date range now"]
R1 --> DB
F -- "no · portal-only vendor
Blinkit, Zepto, Instamart, Nykaa" --> R2["Queue a refresh job
(portal automation)"]
R2 -.-> DB
R2 --> N["Answer now with 'as of' time,
update when the pull lands"]
When a question needs fresher data, the connector pulls just the brand, platform and dates involved, normalises it, and the tool answers from the model. Tools stay the same.
Live access means logging into the brand portal with automation or scraping the app by pincode. Each pull takes 30 seconds to a few minutes, needs an OTP login, and breaks when the portal changes. Instead: pull more often when it matters (hourly for stock and ads on sale days, daily otherwise), and offer a refresh that answers with the latest data and its timestamp, then updates.
With no write API, pausing a Blinkit campaign or changing a bid creates a task for the account manager. API vendors get the change pushed directly.
If Blinkit grants partner API access, only the connector changes, from portal export to API. The data model, tools and chat stay the same.
Vendor tools aren't exposed. One model with INR ex-GST, IST dates and one SKU master. Zepto and Instamart report ad sales on MRP; Hector stores both figures and reports on selling price.
Adding Blinkit or a new vendor adds rows and a registry entry, not tools. The tool list, and so the per-turn context, stays the same size.
7 core tools are always listed. Other groups are enabled on request and the server sends tools/list_changed; run_capability covers clients that don't refresh.
The app role has no bypass. Every call sets hector.advertiser_ids with SET LOCAL in its own transaction, and set_config() is revoked, so even free-form SQL can't widen its own scope. Tested with escape attempts.
Attribution windows differ by platform, so blended ROAS comes with a caveat. Social, video and DSP are judged on MER, new-to-brand and Amazon Attribution, not in-platform ROAS.
Demo data only: 4 fictional brands plus L'Oréal Paris as an illustrative example, 90 days, with planted problems for the agent to find. None of the numbers are real. Production still needs real ingest connectors, OAuth instead of API keys, and vendor write APIs for campaign and keyword changes.