telegram-ads-mcp

telegram-ads-mcp

An MCP server that lets AI agents read and manage Telegram Ads campaigns, including listing accounts and ads, reading stats and budgets, and creating/updating ads, CPM, status, and budget by driving the real ads.telegram.org web UI through Playwright with a reused cookie-based login session.

Category
访问服务器

README

telegram-ads-mcp

An MCP server that lets AI agents (Cursor, Claude Desktop, etc.) read and manage your Telegram Ads campaigns — list accounts and ads, read stats and budgets, and create/update ads, CPM, status, and budget — by driving the real ads.telegram.org web UI through Playwright with a reused, cookie-based login session.

⚠️ Security warning

This server reuses a saved Telegram Ads browser session (auth_state.json). That file is equivalent to your login credentials for ads.telegram.org — anyone with it can act as you, including spending your TON ad budget. Never commit it, share it, or check it into version control. Mutating and financial tools (update_ad, set_cpm, set_status, increase_budget, set_budget, create_ad, get_ad_stats_csv) default to a safe confirm=False dry-run and only take effect when an agent explicitly passes confirm=True. Read SECURITY.md before connecting this server to any agent you don't fully trust with your ad spend.

Requirements

  • Python 3.11+
  • Chromium, installed via Playwright (playwright install chromium)
  • A Telegram Ads account with access to ads.telegram.org

Quick start (recommended: clone)

Cloning and installing in a virtualenv is the recommended path — it makes the one-time interactive login step and the Playwright browser install straightforward and reproducible.

git clone https://github.com/Free-cat/telegram_ads_mcp.git
cd telegram_ads_mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
playwright install chromium
telegram-ads-auth

telegram-ads-auth opens a real (visible) browser window so you can log in to Telegram, choose the ads account you want to manage, and save the session. It prints the path it saved to (by default ~/.config/telegram-ads-mcp/auth_state.json).

Cursor configuration

Add the server to your mcp.json, using the absolute path to the console script inside the venv you just created:

{
  "mcpServers": {
    "telegram-ads": {
      "command": "/ABS/PATH/telegram_ads_mcp/.venv/bin/telegram-ads-mcp",
      "env": {
        "TELEGRAM_ADS_ACCOUNT": "Artem",
        "TELEGRAM_ADS_AUTH_STATE": "/ABS/PATH/to/auth_state.json"
      }
    }
  }
}

Restart Cursor (or reload MCP servers) after adding this. The same shape works for Claude Desktop's claude_desktop_config.json.

Alternative: install via pip + git

If you'd rather not clone, you can install directly from git:

pip install "git+https://github.com/Free-cat/telegram_ads_mcp.git"
playwright install chromium

Run playwright install chromium in the same environment/interpreter you installed the package into, so the browser binary is available at runtime. Ephemeral environments (e.g. running via uvx on every invocation) are fragile for this reason — Playwright needs its browser binaries to persist between runs — which is why the clone + venv path above is recommended for anything beyond a quick try.

Tools

All mutating/financial tools default to confirm=False, which returns a structured dry-run preview and makes no changes. Pass confirm=True to actually execute the action.

Tool Type confirm required? Description
list_accounts Read — List Telegram Ads accounts available for this login session
list_ads Read — List all ads with full table columns (id, metrics, budget, status, date)
get_ad_info Read — Read ad form fields (targeting chips are read-only for existing ads)
get_account_budget Read — Read-only per-ad budgets on /account/budget
update_ad Write Yes (to save) Update ad info fields (title, text, url, budget, etc.), not CPM/budget delta
set_cpm Write Yes (to execute) Set CPM via the /edit_cpm modal
set_status Write Yes (to execute) Set ad status (Active / On Hold) via the /edit_status modal
increase_budget Write (financial) Yes (to execute) Add TON to an ad's budget (delta)
set_budget Write (financial) Yes (to execute) Set a target budget by computing the delta from the current one
create_ad Write (financial) Yes (to execute) Create a new ad; clears the draft by default
get_ad_stats_csv Write (download) Yes (to execute) Download the stats CSV for an ad and period

Every tool raises a stable AUTH_EXPIRED error when the stored session is no longer valid — re-run telegram-ads-auth to refresh it.

Configuration

Env var Purpose
TELEGRAM_ADS_AUTH_STATE Absolute path to the saved Playwright session file. Overrides the default lookup (~/.config/telegram-ads-mcp/auth_state.json, falling back to ./auth_state.json in the current directory).
TELEGRAM_ADS_ACCOUNT Substring match against the account name shown on the Telegram Ads "Choose Account" screen, used to select which account's ads the tools operate on. Optional when your login has exactly one account; required when multiple accounts are available.

Limitations

  • Fragment top-ups are manual. The server can read per-ad budgets but does not automate adding TON via Fragment.
  • Ad Schedule and similar widgets are not automated. Scheduling and "Similar channels/bots" targeting widgets on ads.telegram.org are out of scope for v0.1.
  • Targeting on existing ads is read-only. get_ad_info can read targeting chips, but changing targeting for an already-created ad is not supported — targeting is set at creation time via create_ad.
  • No live end-to-end tests in CI. Tests that hit the real ads.telegram.org are marked live, require a real session, and are never run automatically — they need a human with an active account to run them locally.
  • Transport is stdio only. There is no remote/HTTP transport or Docker image in this release.

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选