tiktok-ads-mcp

tiktok-ads-mcp

Provides read-only access to TikTok advertising data, including campaigns, ad groups, ads, and performance reports through the TikTok Business API.

Category
访问服务器

README

TikTok Ads MCP

A comprehensive Model Context Protocol (MCP) server for interacting with the TikTok Business API. This package provides a complete interface to access TikTok advertising campaigns, ad groups, ads, and generate detailed performance reports.

Features

  • Read-Only TikTok Business API Integration: Access all major TikTok advertising endpoints for data retrieval
  • 6 Comprehensive Tools: Business centers, ad accounts, campaigns, ad groups, ads, and reports
  • Advanced Filtering: Powerful filtering options for all data retrieval operations
  • Multi-Advertiser Support: Handle multiple advertiser accounts in a single request
  • Flexible Reporting: Generate detailed performance reports with custom dimensions and metrics
  • Real-time Data: Access live advertising data and performance metrics
  • Error Handling: Comprehensive error handling and validation
  • Modular Architecture: Clean, maintainable code structure
  • Safe Operations: All tools are read-only and will not modify your campaigns or ad data

Available Tools

  1. get_business_centers - Retrieve business centers accessible by your access token
  2. get_authorized_ad_accounts - Get all authorized advertiser accounts
  3. get_campaigns - Retrieve campaigns with comprehensive filtering options
  4. get_ad_groups - Get ad groups with advanced filtering and targeting options
  5. get_ads - Retrieve ads with detailed creative and performance data
  6. get_reports - Generate comprehensive performance reports and analytics

Prerequisites

  • Python 3.10 or higher
  • TikTok Business API access
  • Valid API credentials (app ID, secret, access token)

Quick Start

Installation

  1. Download the TikTok Ads MCP

    • Click the green "Code" button at the top of the GitHub page
    • Select "Download ZIP"
    • Unzip the downloaded file to a location you can easily find (like your Documents folder)
  2. Alternatively, if you're familiar with Git:

    git clone https://github.com/ysntony/tiktok-ads-mcp.git
    
  3. Install Dependencies

    cd tiktok-ads-mcp
    pip install -e .
    # or with uv
    uv pip install -e .
    

Configuration

  1. Set up environment variables in your MCP client configuration:
{
  "mcpServers": {
    "tiktok-ads": {
      "command": "python",
      "args": ["-m", "tiktok_ads_mcp"],
      "env": {
        "TIKTOK_APP_ID": "your_app_id",
        "TIKTOK_SECRET": "your_secret",
        "TIKTOK_ACCESS_TOKEN": "your_access_token"
      }
    }
  }
}
  1. Required credentials:

    • TIKTOK_APP_ID: Your TikTok app ID
    • TIKTOK_SECRET: Your TikTok app secret
    • TIKTOK_ACCESS_TOKEN: Your access token

    How to get these credentials:

    1. Go to the TikTok for Business Developers portal and log in.
    2. Click "My Apps" and create a new app.
    3. Select "Marketing API" as the service type.
    4. In the app settings, enable permissions related to Reading and Reporting (e.g., Ads Management, Reporting).
    5. Once approved, you will find your App ID and Secret in the app details.
    6. Generate an Access Token using the "TikTok Marketing API Inspector" or via the OAuth flow documented in the portal.

Usage

Once configured, you can use the MCP tools through your MCP client (like Cursor, Claude Desktop, etc.):

  • Get business centers and advertiser accounts to discover available accounts
  • Retrieve campaigns with filtering by status, objective, or date range
  • Access ad groups with advanced targeting and optimization settings
  • View ads with detailed creative and performance data
  • Generate reports with custom dimensions, metrics, and time ranges
  • Access real-time advertising data and performance metrics

API Coverage

This MCP server provides read-only access to the TikTok Business API:

Business Management

  • Business center retrieval and access
  • Advertiser account information and permissions

Campaign Management

  • Campaign retrieval and filtering
  • Campaign status and performance monitoring
  • Campaign budget and objective information

Ad Group Management

  • Ad group retrieval and filtering
  • Advanced targeting and optimization settings
  • Performance monitoring and analysis

Ad Management

  • Ad retrieval and filtering
  • Creative asset information
  • Performance tracking and analysis

Reporting & Analytics

  • Basic performance reports
  • Audience insights reports
  • Playable ads reports
  • DSA (Dynamic Search Ads) reports
  • Business Center reports
  • GMV max ads reports

Key Features

Advanced Filtering

All tools support comprehensive filtering options:

  • Status-based filtering (active, paused, deleted)
  • Time-based filtering (creation date, modification date)
  • Performance-based filtering (budget, optimization goals)
  • Creative filtering (ad formats, material types)

Modern Implementation

This package uses the FastMCP framework for optimal performance and developer experience:

  • Automatic Schema Generation: From Python type hints
  • Simplified Tool Registration: Using @app.tool() decorators
  • Built-in Error Handling: Consistent error responses
  • Type Safety: Full parameter validation from type hints

Multi-Advertiser Support

  • Handle multiple advertiser accounts in single requests
  • Cross-advertiser reporting and analytics
  • Unified data access across accounts

Flexible Reporting

  • Custom dimensions and metrics
  • Multiple report types and data levels
  • Time-based and lifetime metrics
  • Aggregated and detailed views

Error Handling

  • Comprehensive parameter validation
  • Detailed error messages and suggestions
  • Graceful handling of API limitations
  • Rate limiting and retry logic

Documentation

  • MCP_USAGE.md: Comprehensive usage guide with examples
  • TikTok Business API: Official API documentation
  • Project Wiki: Additional resources and guides

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement your changes
  4. Add tests and documentation
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues and questions:

  1. Check the MCP_USAGE.md documentation
  2. Review the TikTok Business API documentation
  3. Open an issue on the GitHub repository
  4. Contact the development team

Changelog

v0.1.4 (Current)

  • Retry Logic Fix: Fixed retry decorator being defeated by inner exception handling — retries now actually fire on rate limits and transient errors
  • Pagination Fix: page and page_size params now properly passed through to get_ad_groups and get_ads API calls
  • Security: Access token redacted from debug log output
  • Dependencies: Removed unused requests and pandas, bumped mcp to >=1.27.0, added httpx and tenacity to requirements.txt
  • Code Quality: Modernized type annotations to Python 3.10+ style, removed dead code and redundant error checks, fixed mutable default dict mutation in filter handling
  • Python Compatibility: Lowered minimum Python version to 3.10

v0.1.3

  • Async Support: Complete refactor to use async/await with httpx for improved performance
  • Retry Logic: Added automatic retries for rate limits and server errors using tenacity
  • Error Handling: Simplified and standardized error handling with decorators
  • Dependencies: Switched from requests to httpx

v0.1.2

  • FastMCP Implementation: Modern MCP server using official FastMCP framework
  • 70% Code Reduction: Compared to traditional MCP implementations
  • Automatic Schema Generation: From Python type hints
  • Simplified Tool Registration: Using @app.tool() decorators
  • Enhanced Error Handling: Built-in error handling with consistent responses
  • Type Safety: Full parameter validation from type hints
  • Future-Proof: Part of the official MCP SDK

v0.1.1

  • Complete implementation of all 6 tools
  • Advanced filtering and reporting capabilities
  • Multi-advertiser support
  • Comprehensive error handling
  • Modular tools architecture
  • Complete documentation and usage guides

v0.1.0

  • Initial release with basic MCP server structure
  • Core API client implementation
  • Basic authentication and configuration

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选