Telegram Ads MCP
Provides tools for managing Telegram Ads through the official Telegram Ads API, including accounts, advertisements, budgets, statistics, audiences, pixels, and targeting, with read-only/write modes and safety controls.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Telegram Ads MCP show me last week's Telegram Ads performance and spend by campaign"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
An open-source Model Context Protocol server for the official Telegram Ads API. Manage accounts, advertisements, budgets, statistics, audiences, pixels and targeting from Claude, Cursor, Codex, OpenCode or any MCP-compatible client.
Official API only. No cookies, browser automation or private endpoints.
Local-first. Runs over stdio on your machine. Your token never leaves it except to call
promoteapi.telegram.org.Safe by default. Read-only mode, explicit write confirmation, budget caps, idempotency keys and an optional JSONL audit log.
Built for agents. 24 focused tools, a searchable catalog of all 45 official methods, guided prompts, and an optional sandboxed Code Mode for multi-step work.
This project is unofficial and is not affiliated with, endorsed by or sponsored by Telegram. The Telegram name and logo are trademarks of their respective owners.
Contents
Related MCP server: telegram-ads-mcp
Quick start
Prerequisites
Node.js 22.18 or newer (24 LTS recommended)
A Telegram Ads account with access to the API
An API token from https://ads.telegram.org/account/api
1. Connect the server
The package is published on npm as telegram-ads-mcp and listed in the official
MCP Registry
as io.github.furkankoykiran/telegram-ads. Run:
npx -y telegram-ads-mcp doctorTo run the latest commit from GitHub instead of the npm release, use:
npx -y github:furkankoykiran/telegram-ads-mcp doctorOr build a local checkout:
git clone https://github.com/furkankoykiran/telegram-ads-mcp.git
cd telegram-ads-mcp
npm install
node dist/cli.js doctordoctor checks the token against the API and prints the account currency and budget. It is the
fastest way to confirm everything works.
2. Write your client configuration
init writes the correct file for each client and keeps a .bak copy of an existing config:
npx -y telegram-ads-mcp init --client claude-desktop --token <your-token>
npx -y telegram-ads-mcp init --client cursor --token <your-token>
npx -y telegram-ads-mcp init --client opencode --token <your-token>
npx -y telegram-ads-mcp init --client all --token <your-token>To launch the GitHub package instead of the npm release, add --github:
npx -y github:furkankoykiran/telegram-ads-mcp init --client all --github --token <your-token>For a local checkout, add --local . so the generated config launches node dist/cli.js instead of
npx:
node dist/cli.js init --client claude-desktop --local . --token <your-token>Prefer to edit files by hand? --print prints the merged configuration without writing anything.
Claude Code and Codex are CLI-based; init prints the exact claude mcp add / codex mcp add
command instead of editing their config.
{
"mcpServers": {
"telegram-ads": {
"command": "npx",
"args": ["-y", "telegram-ads-mcp"],
"env": {
"TELEGRAM_ADS_TOKEN": "your-token",
"TG_ADS_MODE": "read-only",
"TG_ADS_CODE_MODE": "read-only"
}
}
}
}{
"mcp": {
"servers": {
"telegram-ads": {
"type": "local",
"command": ["npx", "-y", "telegram-ads-mcp"],
"environment": {
"TELEGRAM_ADS_TOKEN": "your-token",
"TG_ADS_MODE": "read-only",
"TG_ADS_CODE_MODE": "read-only"
},
"codemode": false
}
}
}
}OpenCode V2 uses the mcp.servers shape. codemode: false keeps the 24 tools directly callable;
use the server's own tg_execute when you want sandboxed scripts.
claude mcp add telegram-ads --scope user \
--env TELEGRAM_ADS_TOKEN=<your-token> \
--env TG_ADS_MODE=read-only \
-- npx -y telegram-ads-mcp
codex mcp add telegram-ads \
--env TELEGRAM_ADS_TOKEN=<your-token> \
--env TG_ADS_MODE=read-only \
-- npx -y telegram-ads-mcp3. Ask your agent to start
Restart the client and ask:
Use
tg_get_accountto show my Telegram Ads account and currency.
Then try a read-only report:
Use
tg_get_statsfor the last 30 days, daily interval, and summarize spend, views, CTR and CPM.
Configuration
All configuration is environment-based. The server never reads .env files implicitly; load them
explicitly with node --env-file=.env if you prefer a file.
Variable | Default | Description |
| required | API token from https://ads.telegram.org/account/api. |
| — | Alias for |
|
|
|
|
|
|
| all | Comma-separated allowlist for explicit |
| no cap | Maximum CPM accepted by the server, in account currency. |
| no cap | Maximum ad budget or budget transfer per call. |
| no cap | Maximum daily budget limit per call. |
| disabled | Path to a JSONL audit log. Parent directories are created. |
|
| Per-request timeout in milliseconds. |
| official API | Override only for testing. The token is sent to this URL. |
Caps apply per call. They are a guardrail, not a full budgeting system: a loop of approved
calls can still spend more than a single cap. Use TG_ADS_ALLOWED_ACCOUNTS and the read-only
default when you want hard limits on what an agent can touch.
Currency precision
Telegram rejects values with too many decimals. The server validates them before sending:
Currency | CPM and budgets | Amounts (transfers, account budget) |
EUR | 2 decimals | 5 decimals |
TON | 2 decimals | 5 decimals |
XTR | 0 decimals | 3 decimals |
tg_get_account returns the account currency. tg_create_ad and tg_ad_budget refuse mismatched
precision with a clear error.
Safety model
The server is designed to be useful to an agent without giving it uncontrolled access to money.
Read-only by default.
TG_ADS_MODEdefaults toread-only. Every write tool fails before it reaches the API.Per-call confirmation. In write mode, every write also requires
confirm: true. The model must decide to pass it, and the call is visible in the transcript.New ads start paused with zero budget.
tg_create_addefaultsis_pausedtotrueandinitial_budgetto0. Funding is a separate, explicit step.Dry runs.
tg_create_adandtg_update_adacceptdry_run: trueto show the exact payload and currency without calling the API.Account allowlist.
TG_ADS_ALLOWED_ACCOUNTSrejects explicitaccount_idvalues outside the list.Budget caps.
TG_ADS_MAX_CPM,TG_ADS_MAX_AD_BUDGETandTG_ADS_MAX_DAILY_BUDGETreject oversized values before the request is sent.Idempotency. Every write carries an
Idempotency-Key; retries reuse the same key. Tools accept an explicit key when the caller needs to retry safely.Audit log. Set
TG_ADS_AUDIT_LOGto keep a JSONL record of tool calls. Phone numbers, emails and legal names are summarized, and ad text/code is reduced to its length.No token in logs. The token is never included in tool output, errors or the audit log.
Code Mode adds a second gate: writes inside tg_execute require TG_ADS_MODE=write,
TG_ADS_CODE_MODE=write and confirm: true on the tg_execute call.
Tools
Every tool returns JSON text. Errors are returned with isError: true and a stable code such as
WRITE_DISABLED, CONFIRMATION_REQUIRED, UNAUTHORIZED or CHANNEL_ID_UNKNOWN.
Account
Tool | Access | Purpose |
| read | Current account, currency, budgets. Optionally list related accounts. |
| read | Billing/profile details (company, email, phone, country, city). |
| write | Increase or decrease a related account's budget. |
Advertisements
Tool | Access | Purpose |
| read | Paged ad list with status, budgets and lifetime metrics. |
| read | Up to 100 ads by ID, including decline reasons. |
| write | Create a paused, zero-budget ad. Supports |
| write | Edit fields, pause/resume, or submit for review. Supports |
| write | Move funds into or out of an ad. |
| write | Delete an inactive ad with no remaining budget. |
| write | Upload ad photos, videos or website photos from a local path. |
Statistics
Tool | Access | Purpose |
| read | Account or per-ad stats, with totals and CTR/CPM/CPC. |
| read | Telegram's monthly account report. |
Targeting
Tool | Access | Purpose |
| read | Languages, topics, countries, locations, channels and bots. |
Audiences and pixels
Tool | Access | Purpose |
| read | List or fetch retargeting audiences. |
| write | Create, edit or delete a phone-number audience. |
| read | Pixel ID and installation snippet. |
| read | List or fetch conversion events. |
| write | Create the pixel, create/rename/delete events. |
Transactions
Tool | Access | Purpose |
| read | Account-level or ad-level transaction history. |
| read | Status of a budget transaction. |
Advanced
Tool | Access | Purpose |
| read | Search all official methods by name, description or parameter. |
| read | TypeScript declarations for the Code Mode |
| sandboxed | Run JavaScript with sequential API calls in QuickJS. |
| read/write | Escape hatch for any method without a dedicated tool. |
The server also exposes:
Resources:
telegram-ads://guide,telegram-ads://method-catalog,telegram-ads://sdk.d.tsPrompts:
launch-ad,audit-account,weekly-report
Code Mode
Code Mode lets an agent run one short JavaScript program instead of dozens of tool calls: bulk edits, pagination, joins, cross-ad analysis and compact reports.
const ads = await tg.getAdsList({ limit: 100 });
const active = ads.ads.filter((ad) => ad.status === "active");
return active
.sort((a, b) => (b.spent_budget ?? 0) - (a.spent_budget ?? 0))
.map((ad) => ({
id: ad.ad_id,
title: ad.title,
spent: ad.spent_budget,
cpm: ad.cpm,
}));Limits and guarantees:
QuickJS (WebAssembly) sandbox with no network, filesystem, process or environment access.
Only the
tgobject andconsoleare exposed.Calls run sequentially, so scripts are deterministic and cannot burst the API.
At most 25 API calls, 15 seconds, 64 MB of memory and 64 KB of output per run.
Read-only unless
TG_ADS_MODE=writeandTG_ADS_CODE_MODE=write, andtg_executeis called withconfirm: true.
See docs/code-mode.md for examples and the full security model.
CLI
telegram-ads-mcp serve Start the MCP server over stdio (default)
telegram-ads-mcp doctor Check configuration and verify the token
telegram-ads-mcp init Write MCP client configuration
telegram-ads-mcp --version Print the versioninit options:
--client <name...> claude-desktop, cursor, opencode, claude-code, codex, or all
--token <token> Defaults to TELEGRAM_ADS_TOKEN
--mode <mode> read-only or write (default: read-only)
--code-mode <mode> off, read-only or write (default: read-only)
--local <path> Launch a built local checkout instead of npx
--github Launch github:furkankoykiran/telegram-ads-mcp instead of the npm package
--print Print the configuration without writing filesThe token is stored in plain text in the generated client config. Keep that file private and revoke the token at https://ads.telegram.org/account/api if it is exposed.
Development
npm install
npm run typecheck
npm run lint
npm test
npm run buildScript | Purpose |
| Run the CLI from source with |
| Typecheck, lint and test in one pass. |
| Re-parse the official docs and regenerate |
| Format the repository with Prettier. |
Project layout:
src/
api/ Catalog, shared types and the HTTP client
code-mode/ QuickJS sandbox and generated SDK declarations
tools/ MCP tool registrations
cli.ts serve / doctor / init
server.ts McpServer assembly
policy.ts Write gates, account allowlist and budget caps
audit.ts Optional JSONL audit log
tests/
unit/ Money, client, policy, sandbox, catalog, schemas
contract/ End-to-end MCP client/server contract testsThe method catalog is generated from https://ads.telegram.org/docs/api. If Telegram ships a new
API revision, run npm run sync-catalog, review the diff and update the tools that need new fields.
Do not edit src/api/catalog.ts by hand.
Release steps and the one-time trusted publishing setup are documented in docs/releasing.md.
Troubleshooting
Symptom | Fix |
| The token is invalid or revoked. Create a new one at https://ads.telegram.org/account/api. |
| Set |
| Re-run the write with |
| Use |
| The key was already used with different parameters. Retry with a new key. |
| An identical request is still running. Wait and retry with the same key. |
Precision errors | Check the account currency with |
Stats range error | Use an interval of 300 or 86400 seconds and at most 1000 intervals; the server splits larger ranges. |
Client does not see the server | Restart the client after editing its config, and check that |
Security
Please read SECURITY.md before using write mode in production. Report vulnerabilities through GitHub's private vulnerability reporting, not in a public issue.
License
MIT © Furkan Koykiran. See LICENSE.
Available Tools
24 toolstg_account_budgetMove budget between accountsADestructive
Increase or decrease the budget of a related account from the current account. amount uses the currency's amount precision (EUR/TON: 5 decimals, XTR: 3). Requires confirm: true and TG_ADS_MODE=write.
Inputs: amount (required), direction (required), account_id (required), confirm, +1 more.
tg_ad_budgetIncrease or decrease ad budgetADestructive
Move funds into or out of an ad. amount is in the account currency and must respect its precision. Telegram only allows decreasing budget when the ad has been inactive for at least 10 minutes. Requires confirm: true and TG_ADS_MODE=write.
Inputs: ad_id (required), amount (required), direction (required), confirm, +2 more.
tg_api_callCall any Telegram Ads API methodADestructive
Escape hatch for methods that do not have a dedicated tool. Pass the exact method name from tg_search and its parameters. Read methods run immediately; write methods require TG_ADS_MODE=write and confirm: true, and receive an idempotency key automatically.
Inputs: method (required), params, confirm, idempotency_key.
tg_create_adCreate adA
Create one advertisement. New ads are paused with a zero budget unless you pass is_paused: false and initial_budget. Money values must match the account currency precision (EUR/TON: 2 decimals, XTR: 0). Telegram requires text unless target.type is search, and at most one of photo_id/video_id. Use dry_run: true to validate without calling the API. Requires confirm: true and TG_ADS_MODE=write.
Inputs: cpm (required), title (required), target (required), placement (required), +21 more.
tg_delete_adDelete adADestructive
Permanently delete an advertisement. Telegram requires the ad to be inactive for at least 10 minutes and to have no remaining budget. Requires confirm: true and TG_ADS_MODE=write.
Inputs: ad_id (required), confirm, account_id.
tg_executeExecute a Telegram Ads scriptADestructive
Run JavaScript in an isolated QuickJS sandbox with a typed tg object, for multi-step work that would otherwise need many tool calls: bulk edits, cross-ad analysis, pagination, joins and reports. Only console.log output and the returned value come back. No network, filesystem, process or env access. Calls run sequentially; the limit is 25 API calls, 15 seconds and 64 KB of output. Example: const ads = await tg.getAdsList({limit: 100}); return ads.ads.length. Write methods require TG_ADS_MODE=write, TG_ADS_CODE_MODE=write and confirm: true.
Inputs: code (required), confirm, idempotency_key.
tg_get_accountGet Telegram Ads accountARead-only
Get the current Telegram Ads account: account_id, title, currency, remaining budget and ad budget. Set include_related to also list accounts whose budgets this account can replenish. Start here to learn the account currency, which determines valid CPM and budget precision.
Inputs: limit, offset, include_related.
tg_get_account_infoGet account profileARead-only
Get the billing/profile details of an account (company name, email, phone, country, city). Omit account_id to read the current account.
Inputs: account_id.
tg_get_adsGet ads by IDBRead-only
Fetch up to 100 advertisements by ad_id, including status, budgets, metrics and decline reasons.
Inputs: ad_ids (required), account_id, include_targeting.
tg_get_pixelGet pixelARead-only
Get the account's Pixel Tag, including its ID and the HTML code snippet used to install it on a website.
Inputs: account_id.
tg_get_reportGet monthly account reportBRead-only
Get Telegram's monthly report for all active ads in an account, including views, opens, clicks, actions and spend per ad.
Inputs: year (required), month (required), account_id.
tg_get_sdkGet the Code Mode TypeScript SDKARead-only
Return the TypeScript declarations for the tg namespace available inside tg_execute. Read this before writing a non-trivial script; it documents every method signature.
Inputs: no named parameters.
tg_get_statsGet advertising statsARead-only
Get account or per-ad statistics for a time range. from/to accept Unix seconds, milliseconds, or ISO 8601. interval is 86400 (daily, default) or 300 (5 minutes). Ranges above 1000 intervals are split automatically. Always returns totals and derived CTR/CPM/CPC; set include_series for the raw time series. Timestamps are inclusive for from and exclusive for to.
Inputs: to (required), from (required), scope (required), ad_ids, +3 more.
tg_get_transactionGet transaction statusBRead-only
Check the status of a budget transaction by its transaction ID.
Inputs: transaction_id (required).
tg_list_adsList adsARead-only
List advertisements for an account, newest first, with status, budgets and lifetime metrics. Use next_offset from the response to fetch the next page. Set include_targeting to receive targeting settings (larger response).
Inputs: limit, offset, account_id, include_targeting.
tg_list_audiencesList audiencesARead-only
List retargeting audiences for an account, or fetch specific audiences by ID. Audience sizes are in phone numbers.
Inputs: limit, offset, account_id, audience_ids.
tg_list_pixel_eventsList pixel eventsBRead-only
List conversion events for the account's pixel, or fetch specific events by ID.
Inputs: limit, offset, event_ids, account_id.
tg_list_targetingList targeting optionsARead-only
Look up targeting catalogs. kind=languages, topics or countries takes no extra arguments. kind=locations searches by country_code and/or query, or resolves location_ids. kind=channel resolves a channel by @username or numeric ID; kind=bot does the same for bots. Prefer @username for channels and bots: numeric IDs only work after this account has resolved them.
Inputs: kind (required), bot, limit, query, +6 more.
tg_list_transactionsList transactionsCRead-only
List account-level or ad-level transactions. Use next_offset to page. Transactions explain where budget was added or spent.
Inputs: scope (required), ad_id, limit, offset, +1 more.
tg_manage_audienceCreate, update or delete an audienceADestructive
Manage phone-number retargeting audiences. action=create needs title and add_phones; action=update needs audience_id plus at least one change; action=delete needs audience_id. Phone numbers are sent to Telegram and are never written to the audit log. Requires confirm: true and TG_ADS_MODE=write.
Inputs: action (required), title, confirm, account_id, +4 more.
tg_manage_pixelManage pixel and conversion eventsADestructive
action=create_pixel creates the account's Pixel Tag (only one per account); action=create_event needs title and type; action=update_event renames an event; action=delete_event removes an event that is not used by any ad. Requires confirm: true and TG_ADS_MODE=write.
Inputs: action (required), type, title, confirm, +2 more.
tg_searchSearch Telegram Ads methodsARead-only
Search the official Telegram Ads API methods by name, description or parameter. Use this to discover the right method before calling tg_api_call or writing a tg_execute script. Returns names, descriptions, write flags, return types and full parameter signatures.
Inputs: limit, query, write.
tg_update_adUpdate adBDestructive
Edit an existing advertisement. Only provided fields change. Use is_paused to pause or resume. Set submit_for_review: true to move a ready_for_review ad into review after editing. Changing cpm or budget requires the same currency precision rules as creation. Use dry_run: true to validate without calling the API. Requires confirm: true and TG_ADS_MODE=write.
Inputs: ad_id (required), cpm, text, title, +20 more.
tg_upload_mediaUpload ad mediaA
Upload a local file to Telegram Ads and return its media ID. Limits: ad_photo JPEG/PNG up to 5 MiB and at least 640px wide; ad_video MP4 up to 20 MiB, 16:9, 3-60 seconds; website_photo JPEG/PNG up to 1 MiB and at least 150x150. Requires confirm: true and TG_ADS_MODE=write.
Inputs: kind (required), path (required), confirm, account_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 24 tools
Most tools target a clearly distinct resource and action (ads CRUD, audiences, pixels, targeting, transactions, stats). A few pairs are close enough to risk misselection: tg_get_account vs tg_get_account_info (budget/currency vs billing profile), tg_get_stats vs tg_get_report (custom range vs monthly report), and the tg_search/tg_api_call/tg_execute trio, though descriptions do disambiguate them.
All tools share the tg_ prefix and snake_case, which is strongly consistent. There are minor deviations: some names are verb-first (tg_list_ads, tg_get_ads) while others are noun-only (tg_account_budget, tg_ad_budget), and get/list are used somewhat interchangeably across similar resources.
24 tools is on the heavy side but justified by the breadth of the Telegram Ads surface: ads, budgets, audiences, pixels, targeting, transactions, stats, reports, plus a sandbox and escape hatch. No tool appears redundant enough to remove.
Coverage is thorough: full ad lifecycle (create, update, delete, list, get, budget), audience and pixel/event management, targeting catalogs, stats, reports, and transactions. The tg_search/tg_api_call/tg_execute layer covers any remaining API methods, so there are no real dead ends.
Maintenance
Related MCP Connectors
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
Open-source ad agent for LinkedIn Ads and Google Ads. Drafts campaigns, audiences and reports.
The simplest way to manage your Meta (Facebook and Instagram) ad accounts with your AI agent.
Telegram ad exchange: estimate reach and cost with no account, then create and run campaigns.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn 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.111MIT
- FlicenseAqualityBmaintenanceEnables AI agents to create, target, pause, and read stats for Telegram Ads campaigns through ads.telegram.org using a logged-in session, with tools for managing ads, creatives, targeting, and account settings.264-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to operate a Telegram account through the same commands as the terminal client: messaging, chat management, voice transcription, calls, stickers, and privacy settings.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to manage Telegram chats, messages, contacts, users, groups, and channels via 50+ MCP tools, with a reactive inbox and per-topic proxy isolation for multi-agent setups.MIT