Skip to main content
Glama
tiktok-ads-mcp

tiktok-ads-mcp

TikTok Ads MCP

A Model Context Protocol (MCP) server for the TikTok Business API. Connect Claude (or any MCP-compatible AI client) directly to your TikTok ad accounts to query campaigns, video performance, audience targeting, benchmarks, and more — all in natural language.

The server speaks the MCP authorization spec (2025-06-18), so it works as a remote connector anywhere Claude supports custom MCP servers — claude.ai (personal), Claude Desktop, and Claude Teams. Add one URL, click "Connect", sign in with TikTok, done. For a Teams plan, the org owner adds the URL once and each member individually authenticates on first use.

What you can do

Account & Business Center

  • List authorized advertiser accounts under your TikTok identity

  • Get advertiser metadata (currency, timezone, industry, status)

  • List Business Centers, BC members, and BC assets

Campaigns, Ad Groups & Ads

  • List standard campaigns and Smart+ (AI-optimised) campaigns

  • List ad groups and individual ads with creatives and status

  • Inspect video assets and creative fatigue scores

Reporting & Performance

  • Custom reports with any TikTok dimensions and metrics over any date range

  • Video-specific metrics (2s/6s views, completion rate, average watch time)

  • Ad benchmark comparisons against industry CTR/CVR/CPM/CPC

  • Async reports for large date ranges (partner-programme tools)

Audience, Pixels, Conversions

  • Browse all interest categories for audience targeting

  • Audience reach estimates

  • List TikTok Pixel installs + conversion event stats

  • List offline event sets

Account Operations

  • Advertiser balance for the authorised account


Related MCP server: TikTok Ads MCP

How auth works

There are two modes. Pick one.

Mode A — Local STDIO (one user, no server)

Use this if you only want it on your own machine. Run the included one-shot OAuth flow (get_token.py / catch_auth.py) once, set TIKTOK_ACCESS_TOKEN in your env, and Claude Desktop launches the server as a subprocess. No Firestore, no Cloud Run, no public URL.

Mode B — Remote HTTP server (Claude Teams, claude.ai, multi-user)

The MCP server is also an OAuth 2.1 authorization server. When Claude connects:

  1. Claude discovers our metadata at /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server.

  2. Claude registers itself via Dynamic Client Registration (POST /oauth/register).

  3. Claude redirects the user to /oauth/authorize. We delegate identification to TikTok Business OAuth.

  4. After TikTok login, we issue our own opaque bearer token to Claude — TikTok credentials never leave the server.

  5. On each /mcp request Claude sends our bearer; we map it server-side to the right user's stored TikTok credentials and call the TikTok Business APIs.

A note on access control. TikTok returns whatever email the user signed up with — usually personal (gmail, hotmail, etc.) rather than work email. Domain-based restriction therefore isn't reliable. By default this MCP allows any TikTok Business user to connect; the security comes from TikTok's own permission model (each user only sees ad accounts their TikTok profile has been authorised for). For tighter control, set ALLOWED_EMAILS to a comma-separated allow-list of TikTok-account emails.


Prerequisites

  • Python 3.10+

  • A TikTok Business app with at least one advertiser authorised

  • A Google Cloud project (Mode B only)


Step 1 — Create a TikTok Developer App

  1. Go to the TikTok Business API Developer Portal and create an app.

  2. Note your App ID and Secret (used as the OAuth client credentials).

  3. Under Advertiser redirect URLs, add:

    • http://localhost:8080/oauth/callback (local dev)

    • https://YOUR-CLOUD-RUN-URL/oauth/callback (Mode B — add after deploy)

  4. Note: TikTok shows a 10-minute propagation delay for new redirect URLs.


Step 2 — Install

git clone https://github.com/dhawalshah/tiktok-ads-mcp
cd tiktok-ads-mcp
pip install -r requirements.txt
cp env.template .env       # fill in values

Step 3 — Mode A: Local STDIO

Run the one-shot OAuth flow (visits TikTok, captures the auth_code, exchanges for tokens):

python catch_auth.py        # opens browser, prints access_token
# Copy the access_token into .env as TIKTOK_ACCESS_TOKEN

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "tiktok-ads": {
      "command": "tiktok-ads-mcp",
      "env": {
        "TIKTOK_APP_ID": "your_app_id",
        "TIKTOK_SECRET": "your_app_secret",
        "TIKTOK_ACCESS_TOKEN": "your_access_token"
      }
    }
  }
}

Restart Claude Desktop. You're done — skip the rest.


Step 3 — Mode B: Remote HTTP server (Claude Teams / claude.ai)

Enable Firestore

The server stores OAuth bearer tokens and per-user TikTok credentials in Firestore.

  1. In Cloud Console, Firestore → Create database → Native mode, pick a region.

  2. Grant the Cloud Run service account Cloud Datastore User role under IAM & Admin → IAM.

Deploy to Cloud Run

gcloud run deploy tiktok-ads-mcp \
  --source . \
  --region YOUR_REGION \
  --project YOUR_PROJECT_ID \
  --platform managed \
  --port 8080 \
  --allow-unauthenticated \
  --set-env-vars "GCP_PROJECT_ID=your-project-id,BASE_URL=https://YOUR-SERVICE-URL.run.app,TIKTOK_APP_ID=...,TIKTOK_SECRET=..."

Recommended: store TIKTOK_SECRET in Secret Manager and inject via --set-secrets rather than as a plain env var.

After it's up, go back to the TikTok Developer Portal and add the live callback URL:

https://YOUR-SERVICE-URL.run.app/oauth/callback

Connect from Claude

Claude Teams (org owner adds it once for everyone):

  • Settings → Connectors → Add custom connector

  • URL: https://YOUR-SERVICE-URL.run.app/mcp

  • Each member clicks Connect, signs in with TikTok, done.

claude.ai personal:

  • Settings → Connectors → Add custom connector

  • URL: https://YOUR-SERVICE-URL.run.app/mcp

Claude Desktop with a remote server:

{
  "mcpServers": {
    "tiktok-ads": {
      "url": "https://YOUR-SERVICE-URL.run.app/mcp"
    }
  }
}

Claude Desktop will run the OAuth dance the first time you use it.


Environment Variables

Variable

Required

Description

TIKTOK_APP_ID

Yes

App ID from your TikTok Business Developer app.

TIKTOK_SECRET

Yes

App secret from your TikTok Business Developer app.

TIKTOK_REDIRECT_URI

No

Override the TikTok callback URL. Defaults to ${BASE_URL}/oauth/callback.

BASE_URL

Mode B

Public URL of this service. Used for OAuth metadata and as the canonical resource URI tokens are bound to.

GCP_PROJECT_ID

Mode B

GCP project hosting Firestore.

ALLOWED_EMAILS

No

Comma-separated allow-list of TikTok-account emails. Empty = no restriction.

TIKTOK_ACCESS_TOKEN

Mode A

Your single-user access token. Not used by the HTTP server.

TIKTOK_ADVERTISER_ID

Mode A (optional)

Default advertiser to query.

TIKTOK_SANDBOX

No

true to use the TikTok sandbox API base URL. Default false.

TIKTOK_REQUEST_TIMEOUT

No

HTTP timeout in seconds. Default 30.

PORT

No

HTTP port (default 8080).


Available Tools

Tool

Description

get_authorized_ad_accounts_tool

List all advertiser accounts accessible under the current TikTok identity

get_advertiser_info_tool

Account metadata: currency, timezone, industry, status

get_advertiser_balance_tool

Current balance for the authorised advertiser

get_business_centers_tool

List Business Centers accessible to this user

get_bc_assets_tool

List assets owned by a Business Center

get_bc_members_tool

List members of a Business Center

get_campaigns_tool

List standard campaigns with optional filters

get_smart_plus_campaigns_tool

List AI-optimised Smart+ campaigns

get_ad_groups_tool

List ad groups under a campaign or advertiser

get_ads_tool

List individual ads with detailed creative and status data

get_reports_tool

Performance reports with custom dimensions, metrics, date ranges

get_video_performance_tool

TikTok video metrics: 2s/6s views, completion rate, average watch time

get_video_assets_tool

List video assets in an advertiser library

get_ad_benchmark_tool

Compare ad CTR, CVR, CPM, CPC against industry benchmarks

get_creative_fatigue_tool

Creative fatigue scores and refresh recommendations

get_audience_reach_tool

Estimated audience reach for given targeting

get_targeting_options_tool

All interest categories available for audience targeting

get_pixels_tool

List TikTok Pixel installations and tracked conversion events

get_pixel_event_stats_tool

Stats per pixel event

get_offline_event_sets_tool

List offline event sets

create_async_report_tool

Create an async report task for large datasets (partner programme)

check_async_report_tool

Check status of an async report task

download_async_report_tool

Download data from a completed async report


Example Prompts

List all my TikTok advertiser accounts

Show spend and impressions by campaign for the last 30 days

Which campaigns had the highest CPM last week?

What's the 6-second view rate for campaign 12345?

Show me Smart+ campaigns and their status

How does ad 111 CTR compare to industry benchmarks?

What interest categories can I target for a fitness audience?

List the pixel events on advertiser 67890

OAuth endpoint reference (Mode B)

For developers who want to verify the implementation or write their own MCP client.

Endpoint

Spec

Purpose

GET /.well-known/oauth-protected-resource

RFC 9728

Advertises the canonical resource URI and authorization server.

GET /.well-known/oauth-authorization-server

RFC 8414

Authorization server metadata.

POST /oauth/register

RFC 7591

Dynamic Client Registration.

GET /oauth/authorize

OAuth 2.1

Starts the auth code flow with PKCE; redirects to TikTok.

GET /oauth/callback

—

TikTok redirects here; we mint our authorization code and bounce back to the MCP client.

POST /oauth/token

OAuth 2.1

Authorization code + refresh token grants.

A GET /mcp without a valid bearer returns 401 with a WWW-Authenticate: Bearer resource_metadata="…" header pointing at the protected-resource metadata document, which is how a standards-compliant MCP client discovers the rest.

PKCE caveat: TikTok's OAuth implementation does not support PKCE on the upstream side, so PKCE is only enforced on the Claude → us channel. The us → TikTok channel uses a state parameter for CSRF protection.

Token format quirks: TikTok's token endpoint accepts a JSON body with app_id, secret, auth_code (rather than the standard form-encoded client_id / code). Their access token is sent as an Access-Token header (rather than Authorization: Bearer). The OAuth proxy here normalises both into standard OAuth 2.1 for the Claude side.


Tech Stack

  • Python 3.10+

  • FastMCP — MCP server framework

  • Starlette + uvicorn — HTTP wrapper

  • httpx — HTTP client for TikTok APIs

  • google-cloud-firestore — per-user token storage and OAuth-server state (Mode B)

  • Google Cloud Run — Serverless hosting


About Dhawal Shah

I run a 40-plus person digital marketing agency out of Singapore, and I build the automation my own teams use. This server is one of those tools rather than a weekend project: it runs against live TikTok Ads accounts every week, which is why the read-only surface is wide and the write surface is deliberately narrow.

Fourteen years building companies across Asia behind it. 5,000+ campaigns, 400+ brands, 30+ startups advised, and 300+ training sessions for teams including Sony, Toyota, DHL and Interpol. I am also an Accredited Director with the Singapore Institute of Directors, which in practice means I get asked what breaks, who is accountable and what it costs before anyone asks what it can do.

I write up the routines and agents I actually run at dhawalshah.net.

Worth reading alongside this repo: Google Ads, Meta, LinkedIn & TikTok MCPs for Claude: Agency Setup Guide.


License

MIT

Available Tools

23 tools
check_async_report_toolA

Checks the status of an async report task created by create_async_report_tool. Status will be PROCESSING, COMPLETE, or FAILED. If PROCESSING, inform the user the report is still generating and check again shortly. When COMPLETE, call download_async_report_tool with the same task_id.

Inputs: task_id (required), advertiser_id (required). Returns: result

create_async_report_toolA

Creates an async report task for large datasets or long date ranges. After calling this tool, immediately use check_async_report_tool with the returned task_id to monitor progress. When status is COMPLETE, use download_async_report_tool to retrieve the data. Inform the user that the report is being generated and you will check on it. report_type: BASIC | AUDIENCE. data_level: AUCTION_AD | AUCTION_ADGROUP | AUCTION_CAMPAIGN. Dates are YYYY-MM-DD.

Inputs: metrics (required), end_date (required), data_level (required), dimensions (required), +3 more. Returns: result

download_async_report_toolA

Downloads the completed data for an async report task. Only call after check_async_report_tool returns status COMPLETE. Returns the report rows.

Inputs: task_id (required), advertiser_id (required). Returns: result

get_ad_benchmark_toolA

Get benchmark metrics (CTR, CVR, CPM, CPC) for specific ads compared to industry averages. ad_ids is required. dimensions defaults to ['PLACEMENT']. Allowed dimension values: AD_CATEGORY, EXTERNAL_ACTION, LOCATION, PLACEMENT. objective_type example: 'CONVERSIONS'.

Inputs: ad_ids (required), advertiser_id (required), dimensions, objective_type. Returns: result

get_ad_groups_toolC

Get ad groups for a specific advertiser with optional filtering

Inputs: advertiser_id (required), page, filters, page_size, +1 more. Returns: result

get_ads_toolC

Get ads for a specific advertiser with optional filtering

Inputs: advertiser_id (required), page, filters, page_size, +1 more. Returns: result

get_advertiser_balance_toolA

Get cash balance and credit limit for all advertiser accounts within a Business Center. Returns advertiser_id, balance, credit_limit, and currency for each account. Use get_business_centers_tool first to get bc_id.

Inputs: bc_id (required). Returns: result

get_advertiser_info_toolA

Get account-level metadata (currency, timezone, industry, status) for one or more advertisers. This is foundational context for interpreting all other data — especially date breakdowns, which depend on the account timezone.

Inputs: advertiser_ids (required). Returns: result

get_audience_reach_toolB

Get estimated audience reach for given targeting criteria. NOTE: This endpoint requires allowlist access from TikTok. Contact TikTok support if you receive a 404 error. objective_type examples: 'TRAFFIC', 'CONVERSIONS', 'APP_INSTALL'. gender: 'GENDER_MALE' | 'GENDER_FEMALE' | 'GENDER_UNLIMITED'. Returns estimated_audience_size_lower, estimated_audience_size_upper, reach_trend.

Inputs: advertiser_id (required), objective_type (required), age, gender, +3 more. Returns: result

get_authorized_ad_accounts_toolB

Get all authorized ad accounts accessible by the current access token

Inputs: random_string. Returns: result

get_bc_assets_toolA

Get all assets of a given type within a Business Center. asset_type must be one of: ADVERTISER, PIXEL, CATALOG. Returns asset_id, asset_name, asset_type, status for each asset. Use get_business_centers_tool first to get bc_id.

Inputs: bc_id (required), asset_type (required). Returns: result

get_bc_members_toolA

Get all members of a Business Center, their roles, and access status. Returns user_id, username, email, role, status for each member. Useful for access audits. Use get_business_centers_tool first to get bc_id.

Inputs: bc_id (required). Returns: result

get_business_centers_toolC

Get business centers accessible by the current access token

Inputs: page, bc_id, page_size. Returns: result

get_campaigns_toolC

Get campaigns for a specific advertiser with optional filtering

Inputs: advertiser_id (required), filters. Returns: result

get_creative_fatigue_toolA

Get creative fatigue scores per ad. Indicates when an ad has been shown too frequently to the same audience and needs refreshing. Returns fatigue_status, fatigue_level, and recommendations per ad. Optionally filter by ad_ids.

Inputs: advertiser_id (required), page, ad_ids, page_size. Returns: result

get_offline_event_sets_toolB

List offline conversion event sets configured for an advertiser. Shows what offline events (e.g. in-store purchases, phone leads) are being matched back to TikTok ad exposure. Returns event_set_id, name, status, event_types, and create_time.

Inputs: advertiser_id (required). Returns: result

get_pixel_event_stats_toolA

Get aggregated conversion event counts (Purchase, AddToCart, ViewContent, etc.) per pixel over a date range. Use after get_pixels_tool to get pixel_ids. Dates are YYYY-MM-DD. Returns one row per pixel per event type per day.

Inputs: end_date (required), pixel_ids (required), start_date (required), advertiser_id (required). Returns: result

get_pixels_toolC

List all TikTok Pixel installations for an advertiser. Shows which conversion events are being tracked and whether measurement is set up correctly. Returns pixel_id, pixel_name, pixel_code, status, create_time, and tracked events.

Inputs: advertiser_id (required), page, page_size. Returns: result

get_reports_toolC

Get performance reports and analytics with comprehensive filtering and grouping options

Inputs: page, bc_id, filters, metrics, +14 more. Returns: result

get_smart_plus_campaigns_toolA

Get Smart+ (AI-optimised) campaigns for an advertiser. Smart+ campaigns do NOT appear in get_campaigns_tool — accounts using Smart+ have a blind spot without this tool. Returns campaign_id, name, status, budget, objective_type, create/modify times. status filter examples: 'ENABLE', 'DISABLE', 'DELETE'.

Inputs: advertiser_id (required), page, status, page_size, +1 more. Returns: result

get_targeting_options_toolA

Get all available interest categories for audience targeting. Returns a list of interest categories with their IDs, names, levels, and sub-category IDs. Use the returned interest_category_id values when setting up ad group targeting. Optionally filter by objective_type (e.g. 'TRAFFIC', 'CONVERSIONS').

Inputs: advertiser_id (required), objective_type. Returns: result

get_video_assets_toolA

Browse the creative video asset library for an advertiser. Returns video_id, video_name, duration, width, height, cover_url, create_time, size. Optional filtering dict supports keys like 'video_name' for name search.

Inputs: advertiser_id (required), page, filtering, page_size. Returns: result

get_video_performance_toolA

Get TikTok-specific video engagement metrics not available in the standard integrated report: 2-second views, 6-second views, completion rate, average watch time, and video play actions. At least one of campaign_ids, adgroup_ids, or ad_ids is required. data_level: AUCTION_AD | AUCTION_ADGROUP | AUCTION_CAMPAIGN. Dates are YYYY-MM-DD.

Inputs: advertiser_id (required), page, ad_ids, end_date, +6 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 23 tools

    Disambiguation5/5

    Each tool maps to a distinct TikTok Ads resource or reporting concernasi get_reports_tool, get_video_performance_tool, get_ad_benchmark_tool, and get_creative_fatigue_tool are clearly differentiated by their descriptions. The explicit note that Smart+ campaigns do not appear in get_campaigns_tool removes a likely source of confusion.

    Naming Consistency5/5

    Tool names follow a predictable snake_case verb_noun pattern: get_* for reads and create/check/download_async_report for the async report workflow. Minor abbreviations like 'bc' are still consistent and readable.

    Tool Count3/5

    With 23 tools, the set is on the heavy side and above the ideal 3–15 range. Most tools represent legitimate distinct endpoints, but several niche analytics tools could reasonably be consolidated or split into a separate reporting-focused server.

    Completeness3/5

    The read/analytics surface is broad, covering accounts, campaigns, ads, pixels, targeting, assets, and reports. However, there are no create, update, or delete tools for campaigns, ad groups, or ads, which is a notable gap if the server is intended to support actual ad management rather than read-only insights.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      MCP server for TikTok that enables searching videos, users, hashtags, and fetching trending content, user profiles, and video details via official API or public scraping.
      8
      -
    • A
      license
      B
      quality
      C
      maintenance
      A read-only MCP server that provides comprehensive access to the TikTok Business API for retrieving advertising data, including campaigns, ad groups, ads, and performance reports.
      24
      31 PyPI
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      MCP server for TikTok that publishes videos to your own TikTok account and retrieves video performance metrics through TikTok's official Content Posting and Display APIs.
      6
      36 PyPI
      1
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables MCP clients to read and analyze TikTok advertising data, with optional preview-first write tools for managing campaigns, ad groups, and budgets.
      35
      Apache 2.0