Skip to content
OnCharge.io
View as Markdown
Developer docs

AI Connector

Connect Claude, ChatGPT, Claude Code or another AI assistant to your OnCharge store, then ask it about your ad spend, sales and return on ad spend in plain English. The connector is an MCP server. It is read-only: the assistant can look at your ads and payments, but it can't change anything.

Connect your assistant#

The connector's address is:

Text
https://app.oncharge.io/api/mcp

It is also in the merchant portal under Settings → AI Connector.

Claude (claude.ai or the desktop app).

  1. Open Settings → Connectors and press Add custom connector.
  2. Name it OnCharge and paste the address.
  3. Press Add, then Connect.
  4. In the OnCharge window, sign in, pick the store and press Allow.

ChatGPT.

  1. Open Settings → Apps & Connectors → Advanced settings and turn on Developer mode.
  2. Press Create, paste the address and set authentication to OAuth.
  3. Sign in to OnCharge, pick the store and press Allow.

Claude Code.

Shell
claude mcp add --transport http oncharge https://app.oncharge.io/api/mcp

Then type /mcp, choose oncharge and Authenticate.

Other assistants. Any MCP client that supports Streamable HTTP and OAuth 2.1 with dynamic client registration can connect the same way.

What the assistant can see#

ToolNeedsWhat it returns
get_storeeitherThe store, what the connection may see, and its linked ad accounts, pixels and catalogs.
get_revenuePaymentsPaid orders, gross revenue, refunds and net revenue per currency, with disputes opened. It can break these down by day, by ad channel or by utm_campaign.
list_recent_ordersPaymentsThe latest paid orders: amount, refunds, status and ad channel.
get_ad_spendAdsSpend, impressions, clicks, CTR and CPC per ad platform, with the conversions and ROAS the platforms report. It can break these down by day or by ad account.
list_campaign_plansAdsGoogle and TikTok campaigns OnCharge runs for the store, with their status and budget.
get_true_roasAds and PaymentsEach platform's spend against the revenue OnCharge actually took from shoppers who clicked its ads, next to the ROAS the platform reports.
  • No shopper names, emails, phone numbers or addresses are ever sent to the assistant.
  • No API keys or ad platform credentials are sent either.
  • Money is in major units (49.5 is $49.50) next to its currency. Currencies are never converted.

True ROAS#

Ad platforms count conversions their own way. Their totals can include view-through and modelled conversions, and orders that were refunded later.

get_true_roas uses the payments OnCharge processed instead. Each order is credited to the ad platform of the shopper's last recorded click:

  • The click ID from the landing URL, if there is one: fbclid, gclid/gbraid/wbraid or ttclid.
  • Otherwise, Meta's _fbc cookie.

The OnCharge tag or plugin records that click at checkout (see Advertising). Refunds are subtracted, and spend comes from the ad accounts connected in the portal.

Two caveats:

  • Facebook also adds fbclid to clicks on unpaid posts, so some organic Facebook sales can count as Meta.
  • Orders from storefronts without the OnCharge tag can't be credited to any platform.

Try asking#

  • "What was my true ROAS on Meta last month, and how does it compare with what Meta reports?"
  • "Which utm_campaign brought in the most revenue over the last 30 days?"
  • "How much did I spend on ads this week, and how much did refunds cost me?"

Disconnect#

Go to Settings → AI Connector and press Disconnect. You can also remove the connector in your assistant, which revokes its tokens.

Access ends immediately in both cases. It also ends straight away for any connections made by someone you remove from your OnCharge account.

For developers#

The connector follows the MCP authorization spec. OnCharge is both the authorization server and the protected resource.

MCP endpointPOST https://app.oncharge.io/api/mcp. Streamable HTTP in stateless JSON mode; GET returns 405 because there is no server-sent event stream.
Protected resource metadatahttps://app.oncharge.io/.well-known/oauth-protected-resource/api/mcp
Authorization server metadatahttps://app.oncharge.io/.well-known/oauth-authorization-server
Client registrationPOST /api/oauth/register (RFC 7591). Public clients only (token_endpoint_auth_method: none). Redirect URIs must use https, loopback http or a private-use scheme.
Authorization/oauth/authorize: authorization code with PKCE (S256 only). resource must be the MCP endpoint. The response includes iss (RFC 9207).
TokenPOST /api/oauth/token with authorization_code or refresh_token. Access tokens last 1 hour. Refresh tokens last 60 days and rotate on every use; reusing one disconnects the app.
RevocationPOST /api/oauth/revoke (RFC 7009). Revoking a refresh token disconnects the app.
Scopesads:read and payments:read. Both are granted when none are requested.