telegram-ads-mcp 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/api/client.ts","../src/api/catalog.ts","../src/errors.ts","../src/version.ts","../src/config.ts","../src/server.ts","../src/audit.ts","../src/money.ts","../src/policy.ts","../src/prompts.ts","../src/code-mode/sdk.ts","../src/resources.ts","../src/tools/account.ts","../src/tools/helpers.ts","../src/tools/ads.ts","../src/tools/schemas.ts","../src/tools/audiences.ts","../src/tools/code.ts","../src/code-mode/run.ts","../src/tools/pixels.ts","../src/tools/raw.ts","../src/tools/stats.ts","../src/tools/targeting.ts","../src/tools/transactions.ts","../src/tools/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport pc from \"picocolors\";\nimport { access, copyFile, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { TelegramAdsClient } from \"./api/client.js\";\nimport { loadConfig } from \"./config.js\";\nimport { ConfigError } from \"./errors.js\";\nimport { createServer } from \"./server.js\";\nimport { SERVER_NAME, VERSION } from \"./version.js\";\n\nconst program = new Command();\n\nprogram\n .name(SERVER_NAME)\n .description(\"MCP server for the official Telegram Ads API\")\n .version(VERSION, \"-v, --version\", \"Print the version\");\n\nprogram\n .command(\"serve\", { isDefault: true })\n .description(\"Start the MCP server over stdio\")\n .action(async () => {\n const config = loadConfig();\n const { serveStdio } = await import(\"@modelcontextprotocol/server/stdio\");\n const handle = serveStdio(() => createServer({ config }), {\n onerror: (error) => process.stderr.write(`[${SERVER_NAME}] ${error.message}\\n`),\n });\n\n const shutdown = () => {\n void handle.close().finally(() => process.exit(0));\n };\n process.once(\"SIGINT\", shutdown);\n process.once(\"SIGTERM\", shutdown);\n\n process.stderr.write(\n `[${SERVER_NAME}] ready on stdio (mode=${config.mode}, code_mode=${config.codeMode})\\n`,\n );\n });\n\nprogram\n .command(\"doctor\")\n .description(\"Check configuration and verify the access token against the API\")\n .action(async () => {\n const config = loadConfig();\n const client = new TelegramAdsClient({\n token: config.token,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n\n console.log(`${pc.bold(\"Node\")} ${process.version}`);\n console.log(`${pc.bold(\"Token\")} ${redact(config.token)}`);\n console.log(`${pc.bold(\"Mode\")} ${config.mode}`);\n console.log(`${pc.bold(\"Code Mode\")} ${config.codeMode}`);\n console.log(`${pc.bold(\"Base URL\")} ${config.baseUrl}`);\n console.log(`${pc.bold(\"Audit log\")} ${config.auditLog ?? pc.dim(\"disabled\")}`);\n console.log(\n `${pc.bold(\"Caps\")} cpm=${config.maxCpm ?? \"∞\"} ad=${config.maxAdBudget ?? \"∞\"} daily=${\n config.maxDailyBudget ?? \"∞\"\n }`,\n );\n\n const account = await client.getCurrentAccount();\n console.log(\"\");\n console.log(pc.green(\"✓ Connected to the Telegram Ads API\"));\n console.log(` account_id: ${account.account_id}`);\n console.log(` title: ${account.title ?? \"—\"}`);\n console.log(` currency: ${account.currency}`);\n console.log(` remaining: ${account.remaining_budget ?? \"—\"}`);\n console.log(` ads budget: ${account.ads_budget ?? \"—\"}`);\n });\n\nprogram\n .command(\"init\")\n .description(\"Write MCP client configuration for local use\")\n .option(\"--client <client...>\", \"claude-desktop, cursor, opencode, claude-code, codex, or all\", [\n \"claude-desktop\",\n ])\n .option(\"--token <token>\", \"Telegram Ads token (defaults to TELEGRAM_ADS_TOKEN)\")\n .option(\"--mode <mode>\", \"read-only or write\", \"read-only\")\n .option(\"--code-mode <mode>\", \"off, read-only or write\", \"read-only\")\n .option(\n \"--local <path>\",\n \"Run a local checkout instead of npx (path to the repository root, must be built)\",\n )\n .option(\"--github\", \"Launch the GitHub package instead of the npm package\", false)\n .option(\"--print\", \"Print the configuration instead of writing files\", false)\n .action(async (options: InitOptions) => {\n const token = options.token ?? process.env.TELEGRAM_ADS_TOKEN;\n if (!token) {\n throw new ConfigError(\n \"Provide --token or set TELEGRAM_ADS_TOKEN. Create a token at https://ads.telegram.org/account/api.\",\n );\n }\n if (![\"read-only\", \"write\"].includes(options.mode)) {\n throw new ConfigError(\"--mode must be read-only or write.\");\n }\n if (![\"off\", \"read-only\", \"write\"].includes(options.codeMode)) {\n throw new ConfigError(\"--code-mode must be off, read-only or write.\");\n }\n\n const clients = expandClients(options.client);\n const env = {\n TELEGRAM_ADS_TOKEN: token,\n TG_ADS_MODE: options.mode,\n TG_ADS_CODE_MODE: options.codeMode,\n };\n\n if (options.local && options.github) {\n throw new ConfigError(\"Use either --local or --github, not both.\");\n }\n\n let launch: { command: string; args: string[] } = {\n command: \"npx\",\n args: [\"-y\", options.github ? GITHUB_PACKAGE : SERVER_NAME],\n };\n if (options.local) {\n const root = resolve(options.local);\n const entry = join(root, \"dist\", \"cli.js\");\n try {\n await access(entry);\n } catch {\n throw new ConfigError(`${entry} was not found. Run \"npm run build\" in ${root} first.`);\n }\n launch = { command: \"node\", args: [entry] };\n }\n\n const standardEntry = { ...launch, env };\n const openCodeEntry = {\n type: \"local\",\n command: [launch.command, ...launch.args],\n environment: env,\n codemode: false,\n };\n\n for (const client of clients) {\n if (client === \"claude-desktop\") {\n await writeConfig(\n claudeDesktopPath(),\n (config) => ({\n ...config,\n mcpServers: { ...asObject(config.mcpServers), \"telegram-ads\": standardEntry },\n }),\n options.print,\n );\n } else if (client === \"cursor\") {\n await writeConfig(\n join(homedir(), \".cursor\", \"mcp.json\"),\n (config) => ({\n ...config,\n mcpServers: { ...asObject(config.mcpServers), \"telegram-ads\": standardEntry },\n }),\n options.print,\n );\n } else if (client === \"opencode\") {\n await writeConfig(\n join(homedir(), \".config\", \"opencode\", \"opencode.json\"),\n (config) => {\n const mcp = asObject(config.mcp);\n return {\n ...config,\n mcp: {\n ...mcp,\n servers: { ...asObject(mcp.servers), \"telegram-ads\": openCodeEntry },\n },\n };\n },\n options.print,\n );\n } else if (client === \"claude-code\") {\n console.log(\n `\\n${pc.bold(\"Claude Code\")}\\n claude mcp add telegram-ads --scope user \\\\\\n` +\n ` --env TELEGRAM_ADS_TOKEN=<your-token> --env TG_ADS_MODE=${options.mode} \\\\\\n` +\n ` -- ${shellLaunch(launch)}\\n`,\n );\n } else if (client === \"codex\") {\n console.log(\n `\\n${pc.bold(\"Codex\")}\\n codex mcp add telegram-ads \\\\\\n` +\n ` --env TELEGRAM_ADS_TOKEN=<your-token> --env TG_ADS_MODE=${options.mode} \\\\\\n` +\n ` -- ${shellLaunch(launch)}\\n`,\n );\n }\n }\n\n if (!options.print) {\n console.log(\n pc.yellow(\n \"\\nThe token is stored in plain text in the files above. Keep them private and revoke the token if exposed.\",\n ),\n );\n console.log(`Restart the client, then ask it to run ${pc.cyan(\"tg_get_account\")}.`);\n }\n });\n\nconst GITHUB_PACKAGE = \"github:furkankoykiran/telegram-ads-mcp\";\n\ninterface InitOptions {\n client: string[];\n token?: string;\n mode: string;\n codeMode: string;\n local?: string;\n github: boolean;\n print: boolean;\n}\n\nfunction shellLaunch(launch: { command: string; args: string[] }): string {\n return [launch.command, ...launch.args]\n .map((part) => (/\\s/.test(part) ? `\"${part}\"` : part))\n .join(\" \");\n}\n\nfunction expandClients(requested: string[]): string[] {\n const valid = new Set([\"claude-desktop\", \"cursor\", \"opencode\", \"claude-code\", \"codex\"]);\n const result = new Set<string>();\n\n for (const value of requested) {\n if (value === \"all\") {\n for (const client of valid) result.add(client);\n continue;\n }\n if (!valid.has(value)) {\n throw new ConfigError(`Unknown client \"${value}\". Use: ${[...valid].join(\", \")}, or all.`);\n }\n result.add(value);\n }\n return [...result];\n}\n\nfunction asObject(value: unknown): Record<string, unknown> {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n}\n\nasync function writeConfig(\n path: string,\n update: (config: Record<string, unknown>) => Record<string, unknown>,\n print: boolean,\n): Promise<void> {\n let current: Record<string, unknown> = {};\n try {\n current = JSON.parse(await readFile(path, \"utf8\")) as Record<string, unknown>;\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== \"ENOENT\") {\n throw new ConfigError(`Could not read ${path}: ${(error as Error).message}`);\n }\n }\n\n const next = update(current);\n\n if (print) {\n console.log(`\\n${pc.bold(path)}\\n${JSON.stringify(next, null, 2)}\\n`);\n return;\n }\n\n await mkdir(dirname(path), { recursive: true });\n if (Object.keys(current).length > 0) {\n await copyFile(path, `${path}.bak`);\n }\n await writeFile(path, `${JSON.stringify(next, null, 2)}\\n`, \"utf8\");\n console.log(`${pc.green(\"✓\")} ${path}`);\n}\n\nfunction claudeDesktopPath(): string {\n if (process.platform === \"win32\") {\n const appData = process.env.APPDATA ?? join(homedir(), \"AppData\", \"Roaming\");\n return join(appData, \"Claude\", \"claude_desktop_config.json\");\n }\n if (process.platform === \"darwin\") {\n return join(\n homedir(),\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\",\n );\n }\n return join(homedir(), \".config\", \"Claude\", \"claude_desktop_config.json\");\n}\n\nfunction redact(token: string): string {\n if (token.length <= 8) return \"****\";\n return `${token.slice(0, 4)}…${token.slice(-4)}`;\n}\n\nprogram.parseAsync(process.argv).catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`${pc.red(\"Error:\")} ${message}\\n`);\n process.exit(1);\n});\n","import { readFile } from \"node:fs/promises\";\nimport { basename, extname } from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport type { Account, Currency } from \"./types.js\";\nimport { getMethod } from \"./catalog.js\";\nimport { TelegramAdsError } from \"../errors.js\";\nimport { VERSION } from \"../version.js\";\n\nexport const DEFAULT_BASE_URL = \"https://promoteapi.telegram.org\";\nconst RETRYABLE_STATUS = new Set([408, 425, 429, 500, 502, 503, 504]);\n\nexport type Params = Record<string, unknown>;\n\nexport interface TelegramAdsClientOptions {\n token: string;\n baseUrl?: string;\n timeoutMs?: number;\n maxRetries?: number;\n maxConcurrent?: number;\n fetch?: typeof globalThis.fetch;\n userAgent?: string;\n}\n\nexport interface CallOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport interface WriteResult<T> {\n data: T;\n idempotencyKey: string;\n attempts: number;\n}\n\nexport interface UploadFile {\n path: string;\n contentType?: string;\n}\n\ninterface RawResponse<T> {\n data: T;\n attempts: number;\n}\n\nclass Semaphore {\n private active = 0;\n private readonly queue: Array<() => void> = [];\n\n constructor(private readonly limit: number) {}\n\n async run<T>(fn: () => Promise<T>): Promise<T> {\n if (this.active >= this.limit) {\n await new Promise<void>((resolve) => this.queue.push(resolve));\n } else {\n this.active += 1;\n }\n\n try {\n return await fn();\n } finally {\n const next = this.queue.shift();\n if (next) next();\n else this.active -= 1;\n }\n }\n}\n\nconst MIME_BY_EXTENSION: Record<string, string> = {\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".png\": \"image/png\",\n \".mp4\": \"video/mp4\",\n};\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseRetryAfter(header: string | null): number | undefined {\n if (!header) return undefined;\n const seconds = Number(header);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000);\n const date = Date.parse(header);\n if (Number.isFinite(date)) return Math.max(0, date - Date.now());\n return undefined;\n}\n\nfunction backoff(attempt: number): number {\n const ceiling = Math.min(500 * 2 ** attempt, 8_000);\n return Math.round(ceiling * (0.5 + Math.random() * 0.5));\n}\n\nconst sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));\n\n/**\n * Thin, dependency-free client for https://promoteapi.telegram.org.\n *\n * Responsibilities kept deliberately small: authentication, JSON/multipart\n * encoding, retries with jitter, idempotency keys and error normalisation.\n */\nexport class TelegramAdsClient {\n private readonly token: string;\n private readonly baseUrl: string;\n private readonly timeoutMs: number;\n private readonly maxRetries: number;\n private readonly fetchImpl: typeof globalThis.fetch;\n private readonly userAgent: string;\n private readonly semaphore: Semaphore;\n private readonly accountCache = new Map<string, { account: Account; expires: number }>();\n\n constructor(options: TelegramAdsClientOptions) {\n if (!options.token) throw new Error(\"A Telegram Ads access token is required.\");\n this.token = options.token;\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeoutMs = options.timeoutMs ?? 30_000;\n this.maxRetries = options.maxRetries ?? 2;\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n this.userAgent = options.userAgent ?? `telegram-ads-mcp/${VERSION}`;\n this.semaphore = new Semaphore(options.maxConcurrent ?? 4);\n }\n\n /** Read-only call. Write methods are rejected so callers cannot bypass policy by accident. */\n async call<T>(method: string, params: Params = {}, options: CallOptions = {}): Promise<T> {\n if (getMethod(method)?.write) {\n throw new Error(`${method} changes state. Use write() so an idempotency key is attached.`);\n }\n const response = await this.request<T>(method, params, options);\n return response.data;\n }\n\n /** Write call. Always carries an idempotency key, including across retries. */\n async write<T>(\n method: string,\n params: Params = {},\n options: CallOptions = {},\n ): Promise<WriteResult<T>> {\n const idempotencyKey = options.idempotencyKey ?? randomUUID();\n const response = await this.request<T>(method, params, { ...options, idempotencyKey });\n return { data: response.data, idempotencyKey, attempts: response.attempts };\n }\n\n /** Multipart upload for uploadAdPhoto, uploadAdVideo and uploadWebsitePhoto. */\n async upload<T>(\n method: string,\n params: Params,\n file: UploadFile,\n options: CallOptions = {},\n ): Promise<WriteResult<T>> {\n const idempotencyKey = options.idempotencyKey ?? randomUUID();\n const buffer = await readFile(file.path);\n const contentType =\n file.contentType ??\n MIME_BY_EXTENSION[extname(file.path).toLowerCase()] ??\n \"application/octet-stream\";\n\n const form = new FormData();\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n form.append(key, typeof value === \"object\" ? JSON.stringify(value) : String(value));\n }\n form.append(\"file\", new Blob([buffer], { type: contentType }), basename(file.path));\n\n const response = await this.request<T>(method, form, { ...options, idempotencyKey }, true);\n return { data: response.data, idempotencyKey, attempts: response.attempts };\n }\n\n async getCurrentAccount(): Promise<Account> {\n return this.resolveAccount();\n }\n\n async resolveAccount(accountId?: string): Promise<Account> {\n const key = accountId ?? \"__current__\";\n const cached = this.accountCache.get(key);\n if (cached && cached.expires > Date.now()) return cached.account;\n\n const account = accountId\n ? await this.call<Account[]>(\"getAccountsById\", { account_ids: [accountId] }).then(\n (accounts) => {\n const first = accounts[0];\n if (!first) {\n throw new TelegramAdsError({\n code: \"ACCOUNT_NOT_FOUND\",\n message: `Account ${accountId} was not returned by the API.`,\n });\n }\n return first;\n },\n )\n : await this.call<Account>(\"getCurrentAccount\");\n\n this.accountCache.set(key, { account, expires: Date.now() + 60_000 });\n return account;\n }\n\n async resolveCurrency(accountId?: string): Promise<Currency> {\n return (await this.resolveAccount(accountId)).currency;\n }\n\n clearCache(): void {\n this.accountCache.clear();\n }\n\n private async request<T>(\n method: string,\n params: Params | FormData,\n options: CallOptions,\n multipart = false,\n ): Promise<RawResponse<T>> {\n const url = `${this.baseUrl}/${method}`;\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.token}`,\n Accept: \"application/json\",\n \"User-Agent\": this.userAgent,\n };\n if (!multipart) headers[\"Content-Type\"] = \"application/json\";\n if (options.idempotencyKey) headers[\"Idempotency-Key\"] = options.idempotencyKey;\n\n const body = multipart ? (params as FormData) : JSON.stringify(params);\n\n let lastError: unknown;\n for (let attempt = 0; attempt <= this.maxRetries; attempt += 1) {\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, this.timeoutMs);\n const onAbort = () => controller.abort();\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n try {\n const response = await this.semaphore.run(() =>\n this.fetchImpl(url, { method: \"POST\", headers, body, signal: controller.signal }),\n );\n\n if (RETRYABLE_STATUS.has(response.status) && attempt < this.maxRetries) {\n const retryAfter = parseRetryAfter(response.headers.get(\"retry-after\"));\n await response.body?.cancel().catch(() => undefined);\n await sleep(retryAfter ?? backoff(attempt));\n continue;\n }\n\n const payload = await this.parseBody(response);\n if (!response.ok) {\n throw this.toError(method, response.status, payload);\n }\n if (isRecord(payload) && payload.ok === false) {\n throw this.toError(method, response.status, payload);\n }\n const data =\n isRecord(payload) && \"result\" in payload ? (payload.result as T) : (payload as T);\n return { data, attempts: attempt + 1 };\n } catch (error) {\n if (error instanceof TelegramAdsError) throw error;\n\n const aborted = error instanceof Error && error.name === \"AbortError\";\n if (timedOut) {\n lastError = new TelegramAdsError({\n code: \"REQUEST_TIMEOUT\",\n message: `Request to ${method} timed out after ${this.timeoutMs} ms.`,\n method,\n retryable: true,\n });\n } else if (aborted) {\n throw new TelegramAdsError({\n code: \"REQUEST_ABORTED\",\n message: `Request to ${method} was aborted.`,\n method,\n retryable: false,\n });\n } else {\n lastError = new TelegramAdsError({\n code: \"NETWORK_ERROR\",\n message:\n error instanceof Error ? error.message : `Network error while calling ${method}.`,\n method,\n retryable: true,\n details: error,\n });\n }\n\n if (attempt < this.maxRetries) {\n await sleep(backoff(attempt));\n continue;\n }\n throw lastError;\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n\n throw lastError instanceof Error\n ? lastError\n : new TelegramAdsError({ code: \"UNKNOWN\", message: `Request to ${method} failed.`, method });\n }\n\n private async parseBody(response: Response): Promise<unknown> {\n const text = await response.text();\n if (!text) return {};\n try {\n return JSON.parse(text);\n } catch {\n return { ok: false, error: `HTTP_${response.status}`, description: text.slice(0, 500) };\n }\n }\n\n private toError(method: string, status: number, payload: unknown): TelegramAdsError {\n const record = isRecord(payload) ? payload : {};\n const rawCode = record.error ?? record.error_code;\n const code =\n typeof rawCode === \"string\" ? rawCode : status === 401 ? \"UNAUTHORIZED\" : `HTTP_${status}`;\n const description =\n typeof record.description === \"string\"\n ? record.description\n : typeof record.message === \"string\"\n ? record.message\n : undefined;\n\n return new TelegramAdsError({\n code,\n message: description ? `${code}: ${description}` : code,\n httpStatus: status,\n method,\n retryable: RETRYABLE_STATUS.has(status),\n details: record,\n });\n }\n}\n","// Generated by scripts/sync-catalog.mjs from https://ads.telegram.org/docs/api\n// Do not edit by hand. Re-run the script to refresh.\nimport type { ApiMethod } from \"./types.js\";\n\nexport const API_METHODS: readonly ApiMethod[] = [\n {\n \"id\": \"createaccount\",\n \"name\": \"createAccount\",\n \"description\": \"Use this method to create a new account. This method can only be called from the main advertiser's account. An account created in this way can only be managed through the main account from which it was created. On success, returns an AccountInfo object.\",\n \"returns\": \"AccountInfo\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Title of the account is being created, 1-128 characters.\"\n },\n {\n \"name\": \"full_name\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Full company name for which the account is being created, 1-256 characters.\"\n },\n {\n \"name\": \"email\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Company email for which the account is being created, 1-64 characters.\"\n },\n {\n \"name\": \"phone_number\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Phone number of the company for which the account is being created.\"\n },\n {\n \"name\": \"country\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Company's country for which the account is being created, 1-128 characters.\"\n },\n {\n \"name\": \"city\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Company's city for which the account is being created, 1-128 characters.\"\n },\n {\n \"name\": \"legal_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Advertiser's legal name for which the account is being created, 0-256 characters. Additional information that can be viewed by users.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editaccountinfo\",\n \"name\": \"editAccountInfo\",\n \"description\": \"Use this method to edit the info of the account. On success, returns an AccountInfo object.\",\n \"returns\": \"AccountInfo\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit info. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New title of the account, 1-128 characters.\"\n },\n {\n \"name\": \"full_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New full company name of the account, 1-256 characters.\"\n },\n {\n \"name\": \"email\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New company email of the account, 1-64 characters.\"\n },\n {\n \"name\": \"phone_number\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New phone number of the company of the account.\"\n },\n {\n \"name\": \"country\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New company's country of the account, 1-128 characters.\"\n },\n {\n \"name\": \"city\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New company's city of the account, 1-128 characters.\"\n },\n {\n \"name\": \"legal_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New advertiser's legal name of the account, 0-256 characters.\"\n }\n ]\n },\n {\n \"id\": \"getaccountinfo\",\n \"name\": \"getAccountInfo\",\n \"description\": \"Use this method to get the info of the account. On success, returns an AccountInfo object.\",\n \"returns\": \"AccountInfo\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get info. If not specified, the current account will be used.\"\n }\n ]\n },\n {\n \"id\": \"getrelatedaccountslist\",\n \"name\": \"getRelatedAccountsList\",\n \"description\": \"Use this method to get a list of related accounts. Budgets of related accounts can be replenished using the budget of the main account. On success, returns a RelatedAccountsList object.\",\n \"returns\": \"RelatedAccountsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the related accounts list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of the related accounts to be retrieved. By default, all related accounts are returned.\"\n }\n ]\n },\n {\n \"id\": \"increaseaccountbudget\",\n \"name\": \"increaseAccountBudget\",\n \"description\": \"Use this method to increase the budget of a related account. The current account budget must have enough funds. On success, returns a TransactionStatus object.\",\n \"returns\": \"TransactionStatus\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the account to increase budget.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be added to the account budget from the current account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"decreaseaccountbudget\",\n \"name\": \"decreaseAccountBudget\",\n \"description\": \"Use this method to decrease the budget of a related account. The target account budget must have enough funds. On success, returns a TransactionStatus object.\",\n \"returns\": \"TransactionStatus\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the account to decrease budget.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be withdrawn from the account budget to the current account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"gettransactionstatus\",\n \"name\": \"getTransactionStatus\",\n \"description\": \"Use this method to get the status of transaction. On success, returns a TransactionStatus object.\",\n \"returns\": \"TransactionStatus\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"transaction_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the transaction to get status.\"\n }\n ]\n },\n {\n \"id\": \"getcurrentaccount\",\n \"name\": \"getCurrentAccount\",\n \"description\": \"Use this method to get the current account. Requires no parameters. On success, returns an Account object.\",\n \"returns\": \"Account\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"getaccountsbyid\",\n \"name\": \"getAccountsById\",\n \"description\": \"Use this method to get accounts by their identifiers. On success, an array of Account objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_ids\",\n \"type\": \"Array of String\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of account identifiers.\"\n }\n ]\n },\n {\n \"id\": \"getaccounttransactionslist\",\n \"name\": \"getAccountTransactionsList\",\n \"description\": \"Use this method to get a list of transactions related to an account. On success, returns an AccountTransactionsList object.\",\n \"returns\": \"AccountTransactionsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account whose transaction list will be returned. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the transaction list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of transactions to be retrieved. Defaults to 100.\"\n }\n ]\n },\n {\n \"id\": \"getaccountstats\",\n \"name\": \"getAccountStats\",\n \"description\": \"Use this method to get statistics related to the account. On success, returns an array of AdStatItem objects.\",\n \"returns\": \"Array<AdStatItem>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get statistics. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"from_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Start of the period, in Unix time. It will be rounded to the start of the interval. The start point is included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"to_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"End of the period, in Unix time. It will be rounded to the start of the interval. The end point is not included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"interval\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Interval in seconds, can be either 300 (5 min) or 86400 (1 day).\"\n }\n ]\n },\n {\n \"id\": \"getaccountreport\",\n \"name\": \"getAccountReport\",\n \"description\": \"Use this method to get a report of the active advertisements for the account. On success, returns an array of AccountReportItem objects.\",\n \"returns\": \"Array<AccountReportItem>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get a report. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"year\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Year of the report, 2021-2100.\"\n },\n {\n \"name\": \"month\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Month of the report, 1-12.\"\n }\n ]\n },\n {\n \"id\": \"uploadadphoto\",\n \"name\": \"uploadAdPhoto\",\n \"description\": \"Use this method to upload a photo to be displayed in the advertisement. On success, returns an AdPhoto object.\",\n \"returns\": \"AdPhoto\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to upload the photo. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"InputFile\",\n \"required\": true,\n \"description\": \"Photo to upload. The photo should be in JPEG or PNG format, up to 5 MB in size, and at least 640 pixels in width with a 16:9 aspect ratio.\"\n }\n ]\n },\n {\n \"id\": \"uploadadvideo\",\n \"name\": \"uploadAdVideo\",\n \"description\": \"Use this method to upload a video to be displayed in the advertisement. On success, returns an AdVideo object.\",\n \"returns\": \"AdVideo\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to upload the video. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"InputFile\",\n \"required\": true,\n \"description\": \"Video to upload. The video should be in MP4 format, up to 20 MB in size, at least 640 pixels in width with a 16:9 aspect ratio, and with a duration between 3 and 60 seconds.\"\n }\n ]\n },\n {\n \"id\": \"uploadwebsitephoto\",\n \"name\": \"uploadWebsitePhoto\",\n \"description\": \"Use this method to upload a photo of the website you want to promote. On success, returns an WebsitePhoto object.\",\n \"returns\": \"WebsitePhoto\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to upload a photo of the website. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"InputFile\",\n \"required\": true,\n \"description\": \"Photo to upload. The photo should be in JPEG or PNG format, up to 1 MB in size, and at least 150x150 pixels in dimensions.\"\n }\n ]\n },\n {\n \"id\": \"createad\",\n \"name\": \"createAd\",\n \"description\": \"Use this method to create a new advertisement. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create an ad. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New ad title, 1-128 bytes. Only displayed in the Telegram Ads interface.\"\n },\n {\n \"name\": \"text\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Text of the advertisement, 1-160 characters. This is what your target audience will see. Required for all targeting types except search .\"\n },\n {\n \"name\": \"photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo to be displayed in the advertisement. To upload a photo, use the uploadAdPhoto method. On average, ads with a photo require a 50-80% higher CPM to be displayed. Applicable for targeting types channels or users only. Only one of photo_id or video_id can be used.\"\n },\n {\n \"name\": \"video_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded video to be displayed in the advertisement. To upload a video, use the uploadAdVideo method. On average, ads with a video require a 70-100% higher CPM to be displayed. Applicable for targeting types channels or users only. Only one of video_id or photo_id can be used.\"\n },\n {\n \"name\": \"promote_url\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"A valid URL of the channel, post, bot or website you want to promote, 1-256 characters. The button below the ad will open this link.\"\n },\n {\n \"name\": \"cpm\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"The price per 1000 impressions in the account's currency. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). The minimum value depends on the account's currency and other advertisement parameters.\"\n },\n {\n \"name\": \"placement\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Placement of the advertisement. Must be one of “channel_post”, “bot_banner”, “search_result” or “video_banner”. This field determines where the ad will be shown. While currently optional for backward compatibility – if not specified, the value will be inferred from target.type – it is strongly recommended to always provide this field explicitly , as missing placement may lead to errors in future versions.\"\n },\n {\n \"name\": \"target\",\n \"type\": \"InputAdTarget\",\n \"required\": true,\n \"description\": \"Target settings.\"\n },\n {\n \"name\": \"impression_frequency\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Frequency of ad impressions to a single user per day, 1-4. Defaults to 1.\"\n },\n {\n \"name\": \"website_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Name of the website you want to promote, 1-40 characters. Required if the URL you want to promote is an external link.\"\n },\n {\n \"name\": \"website_photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo of the website you want to promote. To upload a photo, use the uploadWebsitePhoto method.\"\n },\n {\n \"name\": \"button\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Type of the button to be displayed in the advertisement. Applicable only if the URL you want to promote is an external link. Can be either “subscribe”, “view”, “read”, “learn_more”, “download”, “open”, “sign_up”, “buy”, “order”, “play”, “try” or “leave_request”. If empty, the default button labeled “Open Website” will be displayed.\"\n },\n {\n \"name\": \"conversion_event_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A pixel event used to track conversions. Applicable only if the URL you want to promote is an external link.\"\n },\n {\n \"name\": \"additional_info\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Additional information that can be viewed by users, 0-64 characters. This information can be viewed by users only if the legal_name field is filled in the AccountInfo .\"\n },\n {\n \"name\": \"show_userpic\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement should contain a picture of the promoted channel or bot. On average, ads with a picture require a 30% higher CPM to be displayed.\"\n },\n {\n \"name\": \"initial_budget\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"Amount in the account's currency that will be added to the ad budget from the account budget. The account budget must have enough funds. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). Defaults to 0.\"\n },\n {\n \"name\": \"daily_budget_limit\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"Amount limit in the account's currency that can be spent daily. If 0, the limit is not applied. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). Defaults to 0.\"\n },\n {\n \"name\": \"is_paused\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement should remain on hold after creation. Ignored if activate_date or deactivate_date are passed.\"\n },\n {\n \"name\": \"activate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be activated. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to True if the value is in the future, otherwise, is_paused will be set to False .\"\n },\n {\n \"name\": \"deactivate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be paused. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to False if the value is in the future and activate_date is not set, otherwise, is_paused will be set to True .\"\n },\n {\n \"name\": \"schedule\",\n \"type\": \"InputAdSchedule\",\n \"required\": false,\n \"description\": \"Schedule for displaying the advertisement by hours.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editad\",\n \"name\": \"editAd\",\n \"description\": \"Use this method to edit an existing advertisement. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit an ad. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad to edit.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New ad title, 1-128 bytes. Only displayed in the ad interface.\"\n },\n {\n \"name\": \"text\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Text of the advertisement, 1-160 characters. This is what your target audience will see.\"\n },\n {\n \"name\": \"photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo to be displayed in the advertisement. To upload a photo, use the uploadAdPhoto method. On average, ads with a photo require a 50-80% higher CPM to be displayed. Applicable for targeting types channels or users only. If passed, any previously set photo or video will be removed. Only one of photo_id or video_id can be used.\"\n },\n {\n \"name\": \"video_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded video to be displayed in the advertisement. To upload a video, use the uploadAdVideo method. On average, ads with a video require a 70-100% higher CPM to be displayed. Applicable for targeting types channels or users only. If passed, any previously set photo or video will be removed. Only one of video_id or photo_id can be used.\"\n },\n {\n \"name\": \"promote_url\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A valid URL of the channel, post, bot or website you want to promote, 1-256 characters. The button below the ad will open this link.\"\n },\n {\n \"name\": \"cpm\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"The price per 1000 impressions in the account's currency. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). The minimum value depends on the account's currency and other advertisement parameters.\"\n },\n {\n \"name\": \"impression_frequency\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Frequency of ad impressions to a single user per day, 1-4. Defaults to 1.\"\n },\n {\n \"name\": \"website_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Name of the website you want to promote, 1-40 characters.\"\n },\n {\n \"name\": \"website_photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo of the website you want to promote. To upload a photo, use the uploadWebsitePhoto method.\"\n },\n {\n \"name\": \"button\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Type of the button to be displayed in the advertisement. Applicable only if the URL you want to promote is an external link. Can be either “subscribe”, “view”, “read”, “learn_more”, “download”, “open”, “sign_up”, “buy”, “order”, “play”, “try” or “leave_request”. If empty, the default button labeled “Open Website” will be displayed.\"\n },\n {\n \"name\": \"conversion_event_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A pixel event used to track conversions. Applicable only if the URL you want to promote is an external link. Can't be changed if already set.\"\n },\n {\n \"name\": \"additional_info\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Additional information that can be viewed by users, 0-64 characters. This information can be viewed by users only if the legal_name field is filled in the AccountInfo . Can't be changed if already set.\"\n },\n {\n \"name\": \"show_userpic\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement should contain a picture of the promoted channel or bot. On average, ads with a picture require a 30% higher CPM to be displayed.\"\n },\n {\n \"name\": \"daily_budget_limit\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"Amount limit in the account's currency that can be spent daily. If 0, the limit is not applied. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"is_paused\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement needs to be paused. Pass False if the paused advertisement needs to be resumed. If passed, previously set activate_date and deactivate_date will be reset. Ignored if activate_date or deactivate_date are passed.\"\n },\n {\n \"name\": \"activate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be activated. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to True if the value is in the future, otherwise, is_paused will be set to False .\"\n },\n {\n \"name\": \"deactivate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be paused. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to False if the value is in the future and activate_date is not set, otherwise, is_paused will be set to True .\"\n },\n {\n \"name\": \"schedule\",\n \"type\": \"InputAdSchedule\",\n \"required\": false,\n \"description\": \"Schedule for displaying the advertisement by hours.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n }\n ]\n },\n {\n \"id\": \"editadstatus\",\n \"name\": \"editAdStatus\",\n \"description\": \"Deprecated. Use method editAd with parameter is_paused instead.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": true,\n \"params\": []\n },\n {\n \"id\": \"increaseadbudget\",\n \"name\": \"increaseAdBudget\",\n \"description\": \"Use this method to increase the budget of an advertisement. The account budget must have enough funds. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to increase an ad budget. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the advertisement to increase budget.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be added to the ad budget from the account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"decreaseadbudget\",\n \"name\": \"decreaseAdBudget\",\n \"description\": \"Use this method to decrease the budget of an advertisement. The ad budget must have enough funds. To decrease the budget of an ad, it must be inactive for at least 10 minutes. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to decrease an ad budget. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the advertisement whose budget should be decreased.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be withdrawn from the ad budget to the account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"submitadforreview\",\n \"name\": \"submitAdForReview\",\n \"description\": \"Use this method to submit an advertisement for review. Can only be used for ads with the “ready_for_review” status. Ads are submitted for review automatically when they are created or edited, provided the ad's budget is not empty. If an ad has the “ready_for_review” status, it will not be submitted for review automatically and must be submitted using this method. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to submit an ad for review. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad to submit for review.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n }\n ]\n },\n {\n \"id\": \"deletead\",\n \"name\": \"deleteAd\",\n \"description\": \"Use this method to delete an existing advertisement. To delete an ad, it must be inactive for at least 10 minutes. Returns True on success.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to delete an ad. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the advertisement to delete.\"\n }\n ]\n },\n {\n \"id\": \"getadsbyid\",\n \"name\": \"getAdsById\",\n \"description\": \"Use this method to get advertisements by their identifiers. On success, an array of Ad objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get ads. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_ids\",\n \"type\": \"Array of Integer\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of unique ad identifiers.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad objects.\"\n }\n ]\n },\n {\n \"id\": \"getadslist\",\n \"name\": \"getAdsList\",\n \"description\": \"Use this method to get a list of advertisements for the current account. On success, returns an AdList object.\",\n \"returns\": \"AdList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get ads list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Offset of the ads list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of ads to be retrieved. Values between 0-100 are accepted. Defaults to 100.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad objects.\"\n }\n ]\n },\n {\n \"id\": \"getadtransactionslist\",\n \"name\": \"getAdTransactionsList\",\n \"description\": \"Use this method to get a list of transactions for an advertisement. On success, returns an AdTransactionsList object.\",\n \"returns\": \"AdTransactionsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get an ad transactions list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad whose transaction list will be returned.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the transaction list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of the transactions to be retrieved. Defaults to 100.\"\n }\n ]\n },\n {\n \"id\": \"getadstats\",\n \"name\": \"getAdStats\",\n \"description\": \"Use this method to get statistics for an advertisement. On success, returns an array of AdStatItem objects.\",\n \"returns\": \"Array<AdStatItem>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get an ad stats. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad to get statistics.\"\n },\n {\n \"name\": \"from_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Start of the period, in Unix time. It will be rounded to the start of the interval. The start point is included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"to_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"End of the period, in Unix time. It will be rounded to the start of the interval. The end point is not included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"interval\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Interval in seconds, can be either 300 (5 min) or 86400 (1 day).\"\n }\n ]\n },\n {\n \"id\": \"createaudience\",\n \"name\": \"createAudience\",\n \"description\": \"Use this method to create a new audience. On success, returns an Audience object.\",\n \"returns\": \"Audience\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create an audience. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New audience title, 1-64 characters. Only displayed in the Telegram Ads interface.\"\n },\n {\n \"name\": \"add_phones\",\n \"type\": \"Array of String\",\n \"required\": false,\n \"description\": \"List of 0-10000 phone numbers or their SHA256 hashes.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editaudience\",\n \"name\": \"editAudience\",\n \"description\": \"Use this method to edit an existing audience. If the fields add_phones and remove_phones or reset_phones are passed simultaneously, the deletions will be performed first, followed by the addition of new ones. On success, returns an Audience object.\",\n \"returns\": \"Audience\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit an audience. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"audience_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the audience to edit.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New audience title, 1-64 bytes. If not provided, the title will not be changed.\"\n },\n {\n \"name\": \"add_phones\",\n \"type\": \"Array of String\",\n \"required\": false,\n \"description\": \"List of 0-10000 phone numbers or their SHA256 hashes to include in the audience.\"\n },\n {\n \"name\": \"remove_phones\",\n \"type\": \"Array of String\",\n \"required\": false,\n \"description\": \"List of 0-10000 phone numbers or their SHA256 hashes to remove from the audience. Will be ignored if reset_phones is passed.\"\n },\n {\n \"name\": \"reset_phones\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to reset all phone numbers from the audience.\"\n }\n ]\n },\n {\n \"id\": \"deleteaudience\",\n \"name\": \"deleteAudience\",\n \"description\": \"Use this method to delete an existing audience. You can only delete an audience that is not currently used in any advertisements. Returns True on success.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to delele an audience. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"audience_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the audience to delete.\"\n }\n ]\n },\n {\n \"id\": \"getaudiencesbyid\",\n \"name\": \"getAudiencesById\",\n \"description\": \"Use this method to get audiences by their identifiers. On success, an array of Audience objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get audiences. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"audience_ids\",\n \"type\": \"Array of Integer\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of audience identifiers.\"\n }\n ]\n },\n {\n \"id\": \"getaudienceslist\",\n \"name\": \"getAudiencesList\",\n \"description\": \"Use this method to get the list of audiences. On success, returns an AudiencesList object.\",\n \"returns\": \"AudiencesList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get audiences list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the audiences list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of audiences to be retrieved. By default, all audiences are returned.\"\n }\n ]\n },\n {\n \"id\": \"createpixel\",\n \"name\": \"createPixel\",\n \"description\": \"Use this method to create a Pixel Tag. On success, returns a Pixel object.\",\n \"returns\": \"Pixel\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create a pixel. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"getpixel\",\n \"name\": \"getPixel\",\n \"description\": \"Use this method to get a Pixel Tag related to the account. On success, returns a Pixel object.\",\n \"returns\": \"Pixel\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get a pixel. If not specified, the current account will be used.\"\n }\n ]\n },\n {\n \"id\": \"createpixelevent\",\n \"name\": \"createPixelEvent\",\n \"description\": \"Use this method to create a new pixel event. On success, returns a PixelEvent object.\",\n \"returns\": \"PixelEvent\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create an event. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New event title, 1-64 characters. Only displayed in the Telegram Ads interface.\"\n },\n {\n \"name\": \"type\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Type of the event that most closely matches the action you want to track. Can be either “page_view”, “add_to_cart”, “add_to_wishlist”, “customize_product”, “initiate_checkout”, “add_payment_info”, “purchase”, “contact”, “lead”, “schedule”, “complete_registration”, “submit_application”, “start_trial”, “subscribe”, “view_content”, “search”, “find_location”, “donate”, “custom”.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editpixelevent\",\n \"name\": \"editPixelEvent\",\n \"description\": \"Use this method to edit an existing pixel event. You can't edit a pixel event that was automatically created. On success, returns a PixelEvent object.\",\n \"returns\": \"PixelEvent\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit the pixel event. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"event_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the pixel event to edit.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New event title, 1-64 bytes.\"\n }\n ]\n },\n {\n \"id\": \"deletepixelevent\",\n \"name\": \"deletePixelEvent\",\n \"description\": \"Use this method to delete an existing pixel event. You can only delete a pixel event that is not currently used in any advertisements and was not automatically created. Returns True on success.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to delete the pixel event. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"event_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the pixel event to delete.\"\n }\n ]\n },\n {\n \"id\": \"getpixeleventsbyid\",\n \"name\": \"getPixelEventsById\",\n \"description\": \"Use this method to get pixel events by their identifiers. On success, an array of PixelEvent objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get pixel events. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"event_ids\",\n \"type\": \"Array of String\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of pixel event identifiers.\"\n }\n ]\n },\n {\n \"id\": \"getpixeleventslist\",\n \"name\": \"getPixelEventsList\",\n \"description\": \"Use this method to get a list of pixel events. On success, returns a PixelEventsList object.\",\n \"returns\": \"PixelEventsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get pixel events list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the list of pixel events to return.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of pixel events to be retrieved. By default, all pixel events are returned.\"\n }\n ]\n },\n {\n \"id\": \"gettargetlanguageslist\",\n \"name\": \"getTargetLanguagesList\",\n \"description\": \"Use this method to get the list of available target languages. Requires no parameters. On success, returns an array of TargetLanguage objects.\",\n \"returns\": \"Array<TargetLanguage>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"gettargettopicslist\",\n \"name\": \"getTargetTopicsList\",\n \"description\": \"Use this method to get the list of available target topics. Requires no parameters. On success, returns an array of TargetTopic objects.\",\n \"returns\": \"Array<TargetTopic>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"gettargetcountrieslist\",\n \"name\": \"getTargetCountriesList\",\n \"description\": \"Use this method to get the list of available target countries. Requires no parameters. On success, returns an array of TargetCountry objects.\",\n \"returns\": \"Array<TargetCountry>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"gettargetlocationsbyid\",\n \"name\": \"getTargetLocationsById\",\n \"description\": \"Use this method to get locations by their identifiers. On success, an array of TargetLocation objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"location_ids\",\n \"type\": \"Array of Integer\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of unique location identifiers.\"\n }\n ]\n },\n {\n \"id\": \"gettargetlocationslist\",\n \"name\": \"getTargetLocationsList\",\n \"description\": \"Use this method to get target locations. On success, returns a TargetLocationList object.\",\n \"returns\": \"TargetLocationList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"country_code\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Two-letter ISO 3166-1 alpha-2 country code.\"\n },\n {\n \"name\": \"query\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Text of the query.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Offset of the locations list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of locations to be retrieved. Defaults to 100.\"\n }\n ]\n },\n {\n \"id\": \"gettargetchannel\",\n \"name\": \"getTargetChannel\",\n \"description\": \"Use this method to get target channel. On success, returns a TargetChannel object.\",\n \"returns\": \"TargetChannel\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"channel_id\",\n \"type\": \"Integer or String\",\n \"required\": true,\n \"description\": \"Unique identifier for the target channel or username of the target channel (in the format @channelusername ). Numeric identifiers can only be used if they were previously resolved by this account via username (see Resolving channels and bots ).\"\n },\n {\n \"name\": \"for_excluding\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if you want to exclude the channel.\"\n }\n ]\n },\n {\n \"id\": \"gettargetbot\",\n \"name\": \"getTargetBot\",\n \"description\": \"Use this method to get target bot. On success, returns a TargetBot object.\",\n \"returns\": \"TargetBot\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"bot_id\",\n \"type\": \"Integer or String\",\n \"required\": true,\n \"description\": \"Unique identifier for the target bot or username of the target bot (in the format @usernamebot ). Numeric identifiers can only be used if they were previously resolved by this account via username (see Resolving channels and bots ).\"\n }\n ]\n }\n];\n\nexport const METHOD_NAMES: readonly string[] = API_METHODS.map((method) => method.name);\n\nconst BY_NAME = new Map(API_METHODS.map((method) => [method.name, method]));\n\nexport function getMethod(name: string): ApiMethod | undefined {\n return BY_NAME.get(name);\n}\n\nexport function isWriteMethod(name: string): boolean {\n return BY_NAME.get(name)?.write ?? false;\n}\n","/** Error types surfaced by the server. */\n\nexport class TelegramAdsError extends Error {\n readonly code: string;\n readonly httpStatus: number | undefined;\n readonly method: string | undefined;\n readonly retryable: boolean;\n readonly details: unknown;\n\n constructor(options: {\n message: string;\n code: string;\n httpStatus?: number;\n method?: string;\n retryable?: boolean;\n details?: unknown;\n }) {\n super(options.message);\n this.name = \"TelegramAdsError\";\n this.code = options.code;\n this.httpStatus = options.httpStatus;\n this.method = options.method;\n this.retryable = options.retryable ?? false;\n this.details = options.details;\n }\n}\n\nexport class ConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n\nexport class PolicyError extends Error {\n readonly code: string;\n\n constructor(code: string, message: string) {\n super(message);\n this.name = \"PolicyError\";\n this.code = code;\n }\n}\n\n/** Human-readable hint appended to tool errors for common failure modes. */\nexport function hintFor(error: unknown): string | undefined {\n if (error instanceof PolicyError) return undefined;\n if (!(error instanceof TelegramAdsError)) return undefined;\n\n if (error.code === \"UNAUTHORIZED\" || error.httpStatus === 401) {\n return \"The access token was rejected. Create a new token at https://ads.telegram.org/account/api and update TELEGRAM_ADS_TOKEN.\";\n }\n if (error.code === \"CHANNEL_ID_UNKNOWN\") {\n return \"Pass the channel as @username so this account can resolve it first, then retry with the numeric ID if needed.\";\n }\n if (error.code === \"BOT_ID_UNKNOWN\") {\n return \"Pass the bot as @username so this account can resolve it first, then retry with the numeric ID if needed.\";\n }\n if (error.code === \"MAIN_ACCOUNT_REQUIRED\") {\n return \"This method is only available to main (agency) accounts. Use a token from the main account.\";\n }\n if (error.code === \"IDEMPOTENT_PARAM_MISMATCH\") {\n return \"This idempotency key was already used with different parameters. Retry with a new key.\";\n }\n if (error.code === \"IDEMPOTENT_REQUEST_IN_PROGRESS\") {\n return \"An identical request is still in progress. Wait a moment, then retry with the same key.\";\n }\n if (error.httpStatus === 429) {\n return \"Telegram Ads is rate limiting this account. Wait before retrying.\";\n }\n return undefined;\n}\n","export const VERSION = \"0.1.0\";\nexport const SERVER_NAME = \"telegram-ads-mcp\";\n","import { z } from \"zod\";\nimport { ConfigError } from \"./errors.js\";\nimport { DEFAULT_BASE_URL } from \"./api/client.js\";\n\nconst optionalNumber = z.preprocess(\n (value) => (value === undefined || value === \"\" ? undefined : Number(value)),\n z.number().finite().nonnegative().optional(),\n);\n\nconst optionalString = z.preprocess(\n (value) => (typeof value === \"string\" && value.trim() === \"\" ? undefined : value),\n z.string().optional(),\n);\n\nconst schema = z.object({\n token: z.string().min(1, \"TELEGRAM_ADS_TOKEN is required.\"),\n mode: z.enum([\"read-only\", \"write\"]).default(\"read-only\"),\n codeMode: z.enum([\"off\", \"read-only\", \"write\"]).default(\"read-only\"),\n allowedAccounts: z.array(z.string()).default([]),\n maxCpm: optionalNumber,\n maxAdBudget: optionalNumber,\n maxDailyBudget: optionalNumber,\n auditLog: optionalString,\n timeoutMs: z.number().int().positive().default(30_000),\n baseUrl: z.string().url().default(DEFAULT_BASE_URL),\n});\n\nexport type Config = z.infer<typeof schema>;\n\nexport interface LoadConfigOptions {\n /** Allow commands such as `init` and `--help` to run without a token. */\n requireToken?: boolean;\n}\n\nexport function loadConfig(\n env: NodeJS.ProcessEnv = process.env,\n options: LoadConfigOptions = {},\n): Config {\n const raw = {\n token:\n env.TELEGRAM_ADS_TOKEN ?? env.TG_ADS_TOKEN ?? (options.requireToken === false ? \"-\" : \"\"),\n mode: env.TG_ADS_MODE,\n codeMode: env.TG_ADS_CODE_MODE,\n allowedAccounts: (env.TG_ADS_ALLOWED_ACCOUNTS ?? \"\")\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean),\n maxCpm: env.TG_ADS_MAX_CPM,\n maxAdBudget: env.TG_ADS_MAX_AD_BUDGET,\n maxDailyBudget: env.TG_ADS_MAX_DAILY_BUDGET,\n auditLog: env.TG_ADS_AUDIT_LOG,\n timeoutMs: env.TG_ADS_TIMEOUT_MS ? Number(env.TG_ADS_TIMEOUT_MS) : 30_000,\n baseUrl: env.TG_ADS_BASE_URL ?? DEFAULT_BASE_URL,\n };\n\n const parsed = schema.safeParse(raw);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`);\n throw new ConfigError(`Invalid configuration:\\n- ${issues.join(\"\\n- \")}`);\n }\n return parsed.data;\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { TelegramAdsClient } from \"./api/client.js\";\nimport { AuditLogger } from \"./audit.js\";\nimport type { Config } from \"./config.js\";\nimport { Policy } from \"./policy.js\";\nimport { registerPrompts } from \"./prompts.js\";\nimport { registerResources } from \"./resources.js\";\nimport { registerTools } from \"./tools/index.js\";\nimport { SERVER_NAME, VERSION } from \"./version.js\";\n\nexport interface CreateServerOptions {\n config: Config;\n client?: TelegramAdsClient;\n audit?: AuditLogger;\n}\n\nexport function createServer(options: CreateServerOptions): McpServer {\n const { config } = options;\n const client =\n options.client ??\n new TelegramAdsClient({\n token: config.token,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n\n const context = {\n client,\n config,\n policy: new Policy(config),\n audit: options.audit ?? new AuditLogger(config.auditLog),\n };\n\n const server = new McpServer(\n { name: SERVER_NAME, version: VERSION },\n { capabilities: { tools: {}, resources: {}, prompts: {} } },\n );\n\n registerTools(server, context);\n registerResources(server);\n registerPrompts(server);\n\n return server;\n}\n","import { appendFile, mkdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nexport interface AuditEvent {\n ts: string;\n tool: string;\n outcome: \"ok\" | \"error\";\n duration_ms: number;\n account_id?: string;\n method?: string;\n idempotency_key?: string;\n error?: string;\n params?: unknown;\n}\n\nconst SENSITIVE_KEYS = new Set([\n \"add_phones\",\n \"remove_phones\",\n \"phone_number\",\n \"email\",\n \"legal_name\",\n]);\n\n/** Keeps PII and long payloads out of the audit log. */\nexport function summarizeParams(params: unknown): unknown {\n if (!params || typeof params !== \"object\") return params;\n if (Array.isArray(params)) return params.map(summarizeParams);\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(params)) {\n if (SENSITIVE_KEYS.has(key)) {\n result[key] = { count: Array.isArray(value) ? value.length : 1 };\n } else if (key === \"text\" && typeof value === \"string\") {\n result[key] = { length: value.length };\n } else if (key === \"code\" && typeof value === \"string\") {\n result[key] = { length: value.length };\n } else if (typeof value === \"string\" && value.length > 200) {\n result[key] = `${value.slice(0, 200)}…`;\n } else if (typeof value === \"object\" && value !== null) {\n result[key] = summarizeParams(value);\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\n/**\n * Optional JSONL audit trail. Disabled unless TG_ADS_AUDIT_LOG is set.\n * Writes are serialised so concurrent tool calls cannot interleave lines.\n */\nexport class AuditLogger {\n private queue: Promise<void> = Promise.resolve();\n\n constructor(private readonly path?: string) {}\n\n get enabled(): boolean {\n return Boolean(this.path);\n }\n\n record(event: Omit<AuditEvent, \"ts\">): void {\n if (!this.path) return;\n const line = `${JSON.stringify({ ts: new Date().toISOString(), ...event })}\\n`;\n this.queue = this.queue\n .then(async () => {\n await mkdir(dirname(this.path as string), { recursive: true });\n await appendFile(this.path as string, line, \"utf8\");\n })\n .catch((error: unknown) => {\n process.stderr.write(\n `[telegram-ads-mcp] audit log write failed: ${\n error instanceof Error ? error.message : String(error)\n }\\n`,\n );\n });\n }\n\n async flush(): Promise<void> {\n await this.queue;\n }\n}\n","import type { Currency } from \"./api/types.js\";\n\n/**\n * Currency precision rules from the Telegram Ads documentation.\n * CPM and budget values use `budget` decimals; account amounts use `amount`.\n */\nconst PRECISION: Record<Currency, { budget: number; amount: number }> = {\n EUR: { budget: 2, amount: 5 },\n TON: { budget: 2, amount: 5 },\n XTR: { budget: 0, amount: 3 },\n};\n\nexport type MoneyKind = \"budget\" | \"amount\";\n\nexport function precisionFor(currency: Currency, kind: MoneyKind): number {\n return PRECISION[currency][kind];\n}\n\nexport function decimalPlaces(value: number): number {\n if (!Number.isFinite(value)) return Number.POSITIVE_INFINITY;\n const text = value.toString();\n if (!text.includes(\"e\")) {\n const dot = text.indexOf(\".\");\n return dot === -1 ? 0 : text.length - dot - 1;\n }\n // Normalise exponential notation (e.g. 1e-7) before counting decimals.\n const normalised = value.toFixed(12).replace(/0+$/, \"\").replace(/\\.$/, \"\");\n const dot = normalised.indexOf(\".\");\n return dot === -1 ? 0 : normalised.length - dot - 1;\n}\n\nexport function assertMoney(\n value: number,\n currency: Currency,\n kind: MoneyKind,\n field: string,\n): void {\n if (!Number.isFinite(value) || value < 0) {\n throw new Error(`${field} must be a non-negative number.`);\n }\n const allowed = precisionFor(currency, kind);\n const actual = decimalPlaces(value);\n if (actual > allowed) {\n throw new Error(\n `${field} has ${actual} decimal places, but ${currency} allows ${allowed} for ${kind} values. ` +\n `Round the value before sending it.`,\n );\n }\n}\n\nexport function roundMoney(value: number, currency: Currency, kind: MoneyKind): number {\n return Number(value.toFixed(precisionFor(currency, kind)));\n}\n\n/** Ratios used in summaries, rounded to keep tool output compact. */\nexport function ratio(numerator: number, denominator: number, scale = 1): number {\n if (!denominator) return 0;\n return Number(((numerator / denominator) * scale).toFixed(6));\n}\n","import type { Config } from \"./config.js\";\nimport type { Currency } from \"./api/types.js\";\nimport { PolicyError } from \"./errors.js\";\nimport { assertMoney } from \"./money.js\";\n\nconst WRITE_HINT =\n \"Write access is disabled. Set TG_ADS_MODE=write in the server environment and restart the server.\";\n\n/**\n * Central guard for anything that can spend money or change account state.\n * Every write tool must pass through here before touching the API.\n */\nexport class Policy {\n constructor(private readonly config: Config) {}\n\n get canWrite(): boolean {\n return this.config.mode === \"write\";\n }\n\n get codeModeEnabled(): boolean {\n return this.config.codeMode !== \"off\";\n }\n\n get codeModeCanWrite(): boolean {\n return this.config.codeMode === \"write\";\n }\n\n assertWrite(confirm: boolean | undefined): void {\n if (!this.canWrite) throw new PolicyError(\"WRITE_DISABLED\", WRITE_HINT);\n if (confirm !== true) {\n throw new PolicyError(\n \"CONFIRMATION_REQUIRED\",\n \"This operation changes the account. Re-run with confirm: true after verifying the parameters. \" +\n \"Use dry_run: true to validate without calling the API.\",\n );\n }\n }\n\n assertCodeModeWrite(confirm: boolean | undefined): void {\n if (!this.canWrite) throw new PolicyError(\"WRITE_DISABLED\", WRITE_HINT);\n if (!this.codeModeCanWrite) {\n throw new PolicyError(\n \"CODE_MODE_WRITE_DISABLED\",\n \"Code Mode can only read. Set TG_ADS_CODE_MODE=write to allow write methods inside tg_execute.\",\n );\n }\n if (confirm !== true) {\n throw new PolicyError(\n \"CONFIRMATION_REQUIRED\",\n \"Code Mode may change the account. Re-run tg_execute with confirm: true.\",\n );\n }\n }\n\n assertAccount(accountId: string | undefined): void {\n if (!accountId || this.config.allowedAccounts.length === 0) return;\n if (!this.config.allowedAccounts.includes(accountId)) {\n throw new PolicyError(\n \"ACCOUNT_NOT_ALLOWED\",\n `Account ${accountId} is not in TG_ADS_ALLOWED_ACCOUNTS.`,\n );\n }\n }\n\n assertCpm(cpm: number, currency: Currency): void {\n assertMoney(cpm, currency, \"budget\", \"cpm\");\n if (this.config.maxCpm !== undefined && cpm > this.config.maxCpm) {\n throw new PolicyError(\n \"CPM_LIMIT_EXCEEDED\",\n `cpm ${cpm} exceeds TG_ADS_MAX_CPM (${this.config.maxCpm}).`,\n );\n }\n }\n\n assertAdBudget(amount: number, currency: Currency, field = \"initial_budget\"): void {\n assertMoney(amount, currency, \"budget\", field);\n if (this.config.maxAdBudget !== undefined && amount > this.config.maxAdBudget) {\n throw new PolicyError(\n \"BUDGET_LIMIT_EXCEEDED\",\n `${field} ${amount} exceeds TG_ADS_MAX_AD_BUDGET (${this.config.maxAdBudget}).`,\n );\n }\n }\n\n assertDailyBudget(amount: number, currency: Currency): void {\n assertMoney(amount, currency, \"budget\", \"daily_budget_limit\");\n if (this.config.maxDailyBudget !== undefined && amount > this.config.maxDailyBudget) {\n throw new PolicyError(\n \"DAILY_BUDGET_LIMIT_EXCEEDED\",\n `daily_budget_limit ${amount} exceeds TG_ADS_MAX_DAILY_BUDGET (${this.config.maxDailyBudget}).`,\n );\n }\n }\n\n assertAmount(amount: number, currency: Currency): void {\n assertMoney(amount, currency, \"amount\", \"amount\");\n if (this.config.maxAdBudget !== undefined && amount > this.config.maxAdBudget) {\n throw new PolicyError(\n \"BUDGET_LIMIT_EXCEEDED\",\n `amount ${amount} exceeds TG_ADS_MAX_AD_BUDGET (${this.config.maxAdBudget}).`,\n );\n }\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\n\nexport function registerPrompts(server: McpServer): void {\n server.registerPrompt(\n \"launch-ad\",\n {\n title: \"Launch a Telegram ad safely\",\n description:\n \"Walk through account discovery, targeting, paused ad creation, validation and funding.\",\n argsSchema: z.object({\n brief: z.string().min(1).describe(\"What to promote, the target audience and the budget.\"),\n }),\n },\n ({ brief }) => ({\n messages: [\n {\n role: \"user\",\n content: {\n type: \"text\",\n text:\n `Plan and launch a Telegram ad for this brief:\\n\\n${brief}\\n\\n` +\n `Follow this order strictly:\\n` +\n `1. Call tg_get_account to learn the account currency and available budget.\\n` +\n `2. Use tg_list_targeting to resolve languages, topics, countries, locations, channels or bots. ` +\n `Prefer @username for channels and bots.\\n` +\n `3. Call tg_create_ad with dry_run: true and is_paused: true. Show me the exact payload and cost implications.\\n` +\n `4. Ask for my approval before creating anything that spends money.\\n` +\n `5. Create the ad paused with a zero initial budget, then show me its ad_id.\\n` +\n `6. Only after I approve the budget, call tg_ad_budget and tg_update_ad to unpause it.\\n\\n` +\n `Never submit an ad for review without asking me. Never exceed the configured budget caps.`,\n },\n },\n ],\n }),\n );\n\n server.registerPrompt(\n \"audit-account\",\n {\n title: \"Audit account performance\",\n description: \"Read-only review of spend, delivery and underperforming ads.\",\n argsSchema: z.object({\n days: z.string().optional().describe(\"Lookback window in days, default 30.\"),\n }),\n },\n ({ days }) => ({\n messages: [\n {\n role: \"user\",\n content: {\n type: \"text\",\n text:\n `Audit my Telegram Ads account for the last ${days ?? \"30\"} days. Stay read-only.\\n\\n` +\n `1. tg_get_account for currency and remaining budget.\\n` +\n `2. tg_list_ads with include_targeting: false, paging through all active ads.\\n` +\n `3. tg_get_stats for those ads with include_series: true and interval 86400.\\n` +\n `4. Identify: zero-delivery ads, CTR outliers, CPM outliers, ads with spend but no clicks, ` +\n `and ads whose budget is nearly exhausted.\\n` +\n `5. Return a compact table plus a prioritized list of actions. Do not change anything.`,\n },\n },\n ],\n }),\n );\n\n server.registerPrompt(\n \"weekly-report\",\n {\n title: \"Weekly performance report\",\n description: \"Aggregate a week of stats into a compact report.\",\n argsSchema: z.object({\n week_offset: z.string().optional().describe(\"0 is the current week, 1 is last week.\"),\n }),\n },\n ({ week_offset }) => ({\n messages: [\n {\n role: \"user\",\n content: {\n type: \"text\",\n text:\n `Build a weekly Telegram Ads report for week offset ${week_offset ?? \"1\"} (0 = current week).\\n\\n` +\n `Use tg_execute for efficiency: fetch the active ads, pull daily stats for the week, then return ` +\n `per-ad spend, views, clicks, CTR, CPM and week-over-week change. Keep the returned object small ` +\n `and sorted by spend. Do not make any write calls.`,\n },\n },\n ],\n }),\n );\n}\n","import { API_METHODS } from \"../api/catalog.js\";\nimport type { ApiMethod } from \"../api/types.js\";\n\nconst PRIMITIVES: Record<string, string> = {\n String: \"string\",\n Integer: \"number\",\n Float: \"number\",\n Boolean: \"boolean\",\n \"Integer or String\": \"number | string\",\n InputFile: \"never\",\n};\n\nfunction tsType(docType: string): string {\n if (docType.startsWith(\"Array of \")) return `${tsType(docType.slice(\"Array of \".length))}[]`;\n return PRIMITIVES[docType] ?? \"Record<string, unknown>\";\n}\n\nfunction paramsType(method: ApiMethod): string {\n const fields = method.params\n .filter((param) => param.name !== \"idempotency_key\")\n .map((param) => ` ${param.name}${param.required ? \"\" : \"?\"}: ${tsType(param.type)};`);\n return fields.length === 0 ? \"{}\" : `{\\n${fields.join(\"\\n\")}\\n }`;\n}\n\n/** Compact one-line signature used by tg_search output. */\nexport function signature(method: ApiMethod): string {\n const params = method.params\n .filter((param) => param.name !== \"idempotency_key\")\n .map((param) => `${param.name}${param.required ? \"\" : \"?\"}: ${tsType(param.type)}`);\n return `${method.name}({ ${params.join(\"; \")} })`;\n}\n\n/** TypeScript declarations for the tg namespace inside tg_execute. */\nexport function buildSdkDts(): string {\n const declarations = API_METHODS.filter((method) => !method.deprecated)\n .map((method) => {\n const doc = method.description.replace(/\\*\\//g, \"*\\\\/\");\n return ` /**\\n * ${doc}\\n *\\n * Returns: ${method.returns}\\n */\\n ${method.name}(params${method.params.some((p) => p.required) ? \"\" : \"?\"}: ${paramsType(method)}): Promise<any>;`;\n })\n .join(\"\\n\\n\");\n\n return `/**\n * Type declarations for the \\`tg\\` object available inside tg_execute.\n *\n * Calls are executed sequentially. Write methods only work when the server runs\n * with TG_ADS_MODE=write and TG_ADS_CODE_MODE=write, and tg_execute is called\n * with confirm: true.\n *\n * @example\n * const ads = await tg.getAdsList({ limit: 100 });\n * const active = ads.ads.filter((ad) => ad.status === \"active\");\n * return active.map((ad) => ({ id: ad.ad_id, title: ad.title, spent: ad.spent_budget }));\n */\ndeclare const tg: {\n${declarations}\n};\n\ndeclare const console: {\n log(...args: unknown[]): void;\n warn(...args: unknown[]): void;\n error(...args: unknown[]): void;\n};\n`;\n}\n\nexport interface MethodMatch {\n name: string;\n description: string;\n write: boolean;\n returns: string;\n signature: string;\n}\n\nexport function searchMethods(query: string, limit: number, write?: boolean): MethodMatch[] {\n const needle = query.trim().toLowerCase();\n const scored: Array<{ score: number; method: ApiMethod }> = [];\n\n for (const method of API_METHODS) {\n if (method.deprecated) continue;\n if (write !== undefined && method.write !== write) continue;\n\n if (!needle) {\n scored.push({ score: 0, method });\n continue;\n }\n\n const name = method.name.toLowerCase();\n let score = 0;\n if (name === needle) score = 100;\n else if (name.includes(needle)) score = 60;\n else if (method.description.toLowerCase().includes(needle)) score = 30;\n else if (method.params.some((param) => param.name.includes(needle))) score = 15;\n\n if (score > 0) scored.push({ score, method });\n }\n\n return scored\n .sort((a, b) => b.score - a.score || a.method.name.localeCompare(b.method.name))\n .slice(0, limit)\n .map(({ method }) => ({\n name: method.name,\n description: method.description,\n write: method.write,\n returns: method.returns,\n signature: signature(method),\n }));\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { API_METHODS } from \"./api/catalog.js\";\nimport { buildSdkDts } from \"./code-mode/sdk.js\";\n\nconst GUIDE = `# Telegram Ads MCP\n\nThis server wraps the official Telegram Ads API (https://ads.telegram.org/docs/api).\nIt is unofficial and not affiliated with Telegram.\n\n## Safe workflow\n\n1. Read first: tg_get_account, tg_list_ads, tg_get_ads, tg_get_stats.\n2. Validate writes with dry_run: true when the tool supports it.\n3. Writes require TG_ADS_MODE=write and an explicit confirm: true.\n4. New ads default to paused with a zero budget. Fund them deliberately.\n5. Budget changes are real money. Check the account currency and precision first.\n\n## Currency precision\n\n- EUR and TON: CPM/budget 2 decimals, amounts 5 decimals.\n- XTR: CPM/budget 0 decimals, amounts 3 decimals.\n\n## Channels and bots\n\nPrefer @username. Numeric IDs only work after this account has resolved the\nsame channel or bot via its username.\n\n## Code Mode\n\ntg_execute runs JavaScript in QuickJS with a tg object. Use tg_get_sdk for the\nfull TypeScript surface, or tg_search to discover methods. Code Mode is\nread-only unless TG_ADS_MODE=write and TG_ADS_CODE_MODE=write are both set and\nthe call includes confirm: true.\n\n## Limits\n\n- Stats: interval 300 or 86400 seconds, at most 1000 intervals per request.\n- getAdsById/getAccountsById/getAudiencesById: up to 100 IDs.\n- Ad photo: JPEG/PNG, 5 MiB, at least 640px wide, 16:9.\n- Ad video: MP4, 20 MiB, 16:9, 3-60 seconds.\n- Website photo: JPEG/PNG, 1 MiB, at least 150x150.\n- No published rate limits. Calls are sequential and retried with backoff.\n`;\n\nexport function registerResources(server: McpServer): void {\n server.registerResource(\n \"method-catalog\",\n \"telegram-ads://method-catalog\",\n {\n title: \"Telegram Ads method catalog\",\n description:\n \"All 45 official methods with parameters, required flags, descriptions and return types.\",\n mimeType: \"application/json\",\n },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: \"application/json\",\n text: JSON.stringify(\n {\n source: \"https://ads.telegram.org/docs/api\",\n count: API_METHODS.length,\n methods: API_METHODS,\n },\n null,\n 2,\n ),\n },\n ],\n }),\n );\n\n server.registerResource(\n \"code-mode-sdk\",\n \"telegram-ads://sdk.d.ts\",\n {\n title: \"Code Mode TypeScript SDK\",\n description: \"Type declarations for the tg object available inside tg_execute.\",\n mimeType: \"text/plain\",\n },\n async (uri) => ({\n contents: [{ uri: uri.href, mimeType: \"text/plain\", text: buildSdkDts() }],\n }),\n );\n\n server.registerResource(\n \"guide\",\n \"telegram-ads://guide\",\n {\n title: \"Usage and safety guide\",\n description: \"Workflow, currency precision, limits and Code Mode rules.\",\n mimeType: \"text/markdown\",\n },\n async (uri) => ({\n contents: [{ uri: uri.href, mimeType: \"text/markdown\", text: GUIDE }],\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { RelatedAccountsList, TransactionStatus } from \"../api/types.js\";\nimport { TelegramAdsError } from \"../errors.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nexport function registerAccountTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_get_account\",\n {\n title: \"Get Telegram Ads account\",\n description:\n \"Get the current Telegram Ads account: account_id, title, currency, remaining budget and ad budget. \" +\n \"Set include_related to also list accounts whose budgets this account can replenish. \" +\n \"Start here to learn the account currency, which determines valid CPM and budget precision.\",\n inputSchema: z.object({\n include_related: z\n .boolean()\n .optional()\n .describe(\"Also list related accounts that this account can fund.\"),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_account\", async (input) => {\n const account = await ctx.client.getCurrentAccount();\n if (!input.include_related) return { account };\n\n try {\n const related = await ctx.client.call<RelatedAccountsList>(\n \"getRelatedAccountsList\",\n compact({ offset: input.offset, limit: input.limit }),\n );\n return { account, related };\n } catch (error) {\n if (error instanceof TelegramAdsError && error.code === \"MAIN_ACCOUNT_REQUIRED\") {\n return {\n account,\n related: null,\n note: \"Related accounts are only available to main (agency) accounts.\",\n };\n }\n throw error;\n }\n }),\n );\n\n server.registerTool(\n \"tg_get_account_info\",\n {\n title: \"Get account profile\",\n description:\n \"Get the billing/profile details of an account (company name, email, phone, country, city). \" +\n \"Omit account_id to read the current account.\",\n inputSchema: z.object({\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_account_info\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const info = await ctx.client.call(\n \"getAccountInfo\",\n compact({ account_id: input.account_id }),\n );\n return { account_info: info };\n }),\n );\n\n server.registerTool(\n \"tg_account_budget\",\n {\n title: \"Move budget between accounts\",\n description:\n \"Increase or decrease the budget of a related account from the current account. \" +\n \"amount uses the currency's amount precision (EUR/TON: 5 decimals, XTR: 3). \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n account_id: z.string().min(1).describe(\"Related account to fund or withdraw from.\"),\n direction: z.enum([\"increase\", \"decrease\"]),\n amount: z.number().positive(),\n confirm: z.boolean().optional(),\n idempotency_key: z.string().min(1).max(128).optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_account_budget\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const currency = await ctx.client.resolveCurrency(input.account_id);\n ctx.policy.assertAmount(input.amount, currency);\n ctx.policy.assertWrite(input.confirm);\n\n const method =\n input.direction === \"increase\" ? \"increaseAccountBudget\" : \"decreaseAccountBudget\";\n const result = await ctx.client.write<TransactionStatus>(\n method,\n { account_id: input.account_id, amount: input.amount },\n input.idempotency_key ? { idempotencyKey: input.idempotency_key } : {},\n );\n return { transaction: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n}\n","import type { CallToolResult } from \"@modelcontextprotocol/server\";\nimport type { AdStatItem } from \"../api/types.js\";\nimport type { AuditLogger } from \"../audit.js\";\nimport { summarizeParams } from \"../audit.js\";\nimport type { TelegramAdsClient } from \"../api/client.js\";\nimport type { Config } from \"../config.js\";\nimport type { Policy } from \"../policy.js\";\nimport { hintFor, PolicyError, TelegramAdsError } from \"../errors.js\";\nimport { ratio } from \"../money.js\";\n\nexport interface ToolContext {\n client: TelegramAdsClient;\n config: Config;\n policy: Policy;\n audit: AuditLogger;\n}\n\nexport function ok(data: unknown): CallToolResult {\n return {\n content: [{ type: \"text\", text: JSON.stringify(data, null, 2) }],\n };\n}\n\nexport function fail(error: unknown): CallToolResult {\n const code =\n error instanceof TelegramAdsError || error instanceof PolicyError ? error.code : \"ERROR\";\n const message = error instanceof Error ? error.message : String(error);\n const hint = hintFor(error);\n const text = `Error [${code}]: ${message}${hint ? `\\n\\nHint: ${hint}` : \"\"}`;\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/**\n * Wraps a tool body with error normalisation and audit logging.\n * Tool implementations stay focused on their actual job.\n */\nexport function toolHandler<Input>(\n ctx: ToolContext,\n tool: string,\n fn: (input: Input) => Promise<unknown>,\n): (input: Input) => Promise<CallToolResult> {\n return async (input: Input): Promise<CallToolResult> => {\n const started = Date.now();\n const record = (input ?? {}) as Record<string, unknown>;\n const accountId = typeof record.account_id === \"string\" ? record.account_id : undefined;\n const method = typeof record.method === \"string\" ? record.method : undefined;\n\n try {\n const data = await fn(input);\n const idempotencyKey =\n data && typeof data === \"object\" && \"idempotency_key\" in data\n ? (data as { idempotency_key?: unknown }).idempotency_key\n : undefined;\n ctx.audit.record({\n tool,\n outcome: \"ok\",\n duration_ms: Date.now() - started,\n ...(accountId ? { account_id: accountId } : {}),\n ...(method ? { method } : {}),\n ...(typeof idempotencyKey === \"string\" ? { idempotency_key: idempotencyKey } : {}),\n params: summarizeParams(input),\n });\n return ok(data);\n } catch (error) {\n const code =\n error instanceof TelegramAdsError || error instanceof PolicyError ? error.code : \"ERROR\";\n ctx.audit.record({\n tool,\n outcome: \"error\",\n duration_ms: Date.now() - started,\n ...(accountId ? { account_id: accountId } : {}),\n ...(method ? { method } : {}),\n error: code,\n params: summarizeParams(input),\n });\n return fail(error);\n }\n };\n}\n\n/** Drops undefined/null so optional fields are not sent to the API. */\nexport function compact(input: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input)) {\n if (value !== undefined && value !== null) result[key] = value;\n }\n return result;\n}\n\nexport function toUnixSeconds(value: string | number, field: string): number {\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new Error(`${field} must be a finite number.`);\n const seconds = value > 1e12 ? Math.floor(value / 1000) : Math.floor(value);\n return seconds;\n }\n\n const trimmed = value.trim();\n if (/^\\d+$/.test(trimmed)) return toUnixSeconds(Number(trimmed), field);\n\n const parsed = Date.parse(trimmed);\n if (!Number.isFinite(parsed)) {\n throw new Error(`${field} must be Unix seconds, milliseconds, or an ISO 8601 date.`);\n }\n return Math.floor(parsed / 1000);\n}\n\nexport interface TimeRange {\n from: number;\n to: number;\n}\n\nexport function parseRange(from: string | number, to: string | number): TimeRange {\n const start = toUnixSeconds(from, \"from\");\n const end = toUnixSeconds(to, \"to\");\n if (start >= end) throw new Error(\"from must be earlier than to.\");\n return { from: start, to: end };\n}\n\n/**\n * Telegram accepts at most 1000 intervals per stats request.\n * Split larger ranges into contiguous windows so callers can ask for a year.\n */\nexport function planWindows(range: TimeRange, interval: number): TimeRange[] {\n const maxIntervals = 1000;\n const span = interval * maxIntervals;\n if (range.to - range.from <= span) return [range];\n\n const windows: TimeRange[] = [];\n for (let start = range.from; start < range.to; start += span) {\n windows.push({ from: start, to: Math.min(start + span, range.to) });\n }\n return windows;\n}\n\nexport interface StatsSummary {\n views: number;\n opens: number;\n clicks: number;\n actions: number;\n spent_budget: number;\n ctr: number;\n cpm: number;\n cpc: number;\n}\n\nexport function summarizeStats(items: AdStatItem[]): StatsSummary {\n let views = 0;\n let opens = 0;\n let clicks = 0;\n let actions = 0;\n let spent = 0;\n\n for (const item of items) {\n views += item.views ?? 0;\n opens += item.opens ?? 0;\n clicks += item.clicks ?? 0;\n actions += item.actions ?? 0;\n spent += item.spent_budget ?? 0;\n }\n\n return {\n views,\n opens,\n clicks,\n actions,\n spent_budget: Number(spent.toFixed(6)),\n ctr: ratio(clicks, views),\n cpm: ratio(spent, views, 1000),\n cpc: ratio(spent, clicks),\n };\n}\n","import { stat } from \"node:fs/promises\";\nimport { extname, resolve } from \"node:path\";\nimport type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { Ad, AdList } from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\nimport { assertTargetLimits, targetSchema } from \"./schemas.js\";\n\nconst placement = z.enum([\"channel_post\", \"bot_banner\", \"search_result\", \"video_banner\"]);\nconst button = z.enum([\n \"subscribe\",\n \"view\",\n \"read\",\n \"learn_more\",\n \"download\",\n \"open\",\n \"sign_up\",\n \"buy\",\n \"order\",\n \"play\",\n \"try\",\n \"leave_request\",\n]);\n\nconst schedule = z.object({\n week_hours_mask: z\n .array(z.number().int().min(0).max(16_777_215))\n .length(7)\n .describe(\n \"Exactly 7 bitmasks, Monday first. Bit 0 is 00:00-01:00, bit 23 is 23:00-00:00. All zeros means no schedule.\",\n ),\n timezone: z\n .number()\n .int()\n .min(-43_200)\n .max(50_400)\n .multipleOf(900)\n .optional()\n .describe(\"Offset in seconds from UTC. Required unless use_viewer_timezone is true.\"),\n use_viewer_timezone: z\n .boolean()\n .optional()\n .describe(\"Apply the schedule in the viewer's timezone. Users targeting only.\"),\n});\n\nconst money = z.number().nonnegative();\n\nconst httpUrl = z\n .string()\n .url()\n .max(256)\n .refine((value) => /^https?:\\/\\//i.test(value), \"Use an http:// or https:// URL.\");\n\nexport function registerAdTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_ads\",\n {\n title: \"List ads\",\n description:\n \"List advertisements for an account, newest first, with status, budgets and lifetime metrics. \" +\n \"Use next_offset from the response to fetch the next page. \" +\n \"Set include_targeting to receive targeting settings (larger response).\",\n inputSchema: z.object({\n account_id: z.string().optional(),\n offset: z.string().optional().describe(\"Pagination cursor from a previous response.\"),\n limit: z.number().int().min(1).max(100).optional(),\n include_targeting: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_ads\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const result = await ctx.client.call<AdList>(\n \"getAdsList\",\n compact({\n account_id: input.account_id,\n offset: input.offset,\n limit: input.limit,\n return_target: input.include_targeting,\n }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_get_ads\",\n {\n title: \"Get ads by ID\",\n description:\n \"Fetch up to 100 advertisements by ad_id, including status, budgets, metrics and decline reasons.\",\n inputSchema: z.object({\n ad_ids: z.array(z.number().int().positive()).min(1).max(100),\n account_id: z.string().optional(),\n include_targeting: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_ads\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const ads = await ctx.client.call<Ad[]>(\n \"getAdsById\",\n compact({\n account_id: input.account_id,\n ad_ids: input.ad_ids,\n return_target: input.include_targeting,\n }),\n );\n return { ads };\n }),\n );\n\n server.registerTool(\n \"tg_create_ad\",\n {\n title: \"Create ad\",\n description:\n \"Create one advertisement. New ads are paused with a zero budget unless you pass is_paused: false \" +\n \"and initial_budget. Money values must match the account currency precision (EUR/TON: 2 decimals, \" +\n \"XTR: 0). Telegram requires text unless target.type is search, and at most one of photo_id/video_id. \" +\n \"Use dry_run: true to validate without calling the API. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n title: z.string().min(1).max(128),\n text: z.string().min(1).max(160).optional(),\n promote_url: httpUrl,\n cpm: z.number().positive().describe(\"Price per 1000 impressions in the account currency.\"),\n placement,\n target: targetSchema,\n photo_id: z.string().min(1).optional(),\n video_id: z.string().min(1).optional(),\n website_name: z.string().min(1).max(40).optional(),\n website_photo_id: z.string().optional(),\n button: button.optional(),\n conversion_event_id: z.string().optional(),\n additional_info: z.string().optional(),\n show_userpic: z.boolean().optional(),\n impression_frequency: z.number().int().min(1).max(4).optional(),\n initial_budget: money.optional().describe(\"Defaults to 0, which keeps the ad unfunded.\"),\n daily_budget_limit: money.optional().describe(\"0 disables the daily limit.\"),\n activate_date: z.number().int().positive().optional().describe(\"Unix seconds.\"),\n deactivate_date: z.number().int().positive().optional().describe(\"Unix seconds.\"),\n schedule: schedule.optional(),\n is_paused: z.boolean().optional().describe(\"Defaults to true.\"),\n account_id: z.string().optional(),\n dry_run: z.boolean().optional(),\n confirm: z.boolean().optional(),\n idempotency_key: z.string().min(1).max(128).optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_create_ad\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n assertTargetLimits(input.target);\n if (input.photo_id && input.video_id) {\n throw new Error(\"Only one of photo_id or video_id may be provided.\");\n }\n if (\n (input.photo_id || input.video_id) &&\n ![\"channels\", \"users\"].includes(input.target.type)\n ) {\n throw new Error(\n \"photo_id and video_id are only supported for channels or users targeting.\",\n );\n }\n if (!input.text && input.target.type !== \"search\") {\n throw new Error(\"text is required unless target.type is search.\");\n }\n\n const currency = await ctx.client.resolveCurrency(input.account_id);\n ctx.policy.assertCpm(input.cpm, currency);\n\n const initialBudget = input.initial_budget ?? 0;\n if (initialBudget > 0) ctx.policy.assertAdBudget(initialBudget, currency);\n if (input.daily_budget_limit !== undefined && input.daily_budget_limit > 0) {\n ctx.policy.assertDailyBudget(input.daily_budget_limit, currency);\n }\n\n const params = compact({\n account_id: input.account_id,\n title: input.title,\n text: input.text,\n promote_url: input.promote_url,\n cpm: input.cpm,\n placement: input.placement,\n target: input.target,\n photo_id: input.photo_id,\n video_id: input.video_id,\n website_name: input.website_name,\n website_photo_id: input.website_photo_id,\n button: input.button,\n conversion_event_id: input.conversion_event_id,\n additional_info: input.additional_info,\n show_userpic: input.show_userpic,\n impression_frequency: input.impression_frequency,\n initial_budget: initialBudget,\n daily_budget_limit: input.daily_budget_limit,\n activate_date: input.activate_date,\n deactivate_date: input.deactivate_date,\n schedule: input.schedule,\n is_paused: input.is_paused ?? true,\n });\n\n if (input.dry_run) {\n return { dry_run: true, currency, request: params };\n }\n\n ctx.policy.assertWrite(input.confirm);\n const result = await ctx.client.write<Ad>(\"createAd\", params, {\n ...(input.idempotency_key ? { idempotencyKey: input.idempotency_key } : {}),\n });\n return { ad: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n\n server.registerTool(\n \"tg_update_ad\",\n {\n title: \"Update ad\",\n description:\n \"Edit an existing advertisement. Only provided fields change. Use is_paused to pause or resume. \" +\n \"Set submit_for_review: true to move a ready_for_review ad into review after editing. \" +\n \"Changing cpm or budget requires the same currency precision rules as creation. \" +\n \"Use dry_run: true to validate without calling the API. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n ad_id: z.number().int().positive(),\n title: z.string().min(1).max(128).optional(),\n text: z.string().min(1).max(160).optional(),\n promote_url: httpUrl.optional(),\n cpm: z.number().positive().optional(),\n photo_id: z.string().min(1).optional(),\n video_id: z.string().min(1).optional(),\n website_name: z.string().min(1).max(40).optional(),\n website_photo_id: z.string().optional(),\n button: button.optional(),\n conversion_event_id: z.string().optional(),\n additional_info: z.string().optional(),\n show_userpic: z.boolean().optional(),\n impression_frequency: z.number().int().min(1).max(4).optional(),\n daily_budget_limit: money.optional(),\n is_paused: z.boolean().optional(),\n activate_date: z.number().int().positive().optional(),\n deactivate_date: z.number().int().positive().optional(),\n schedule: schedule.optional(),\n submit_for_review: z.boolean().optional(),\n include_targeting: z.boolean().optional(),\n account_id: z.string().optional(),\n dry_run: z.boolean().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_update_ad\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n const {\n ad_id,\n submit_for_review,\n include_targeting,\n dry_run,\n confirm,\n account_id,\n ...fields\n } = input;\n const provided = Object.entries(fields).filter(([, value]) => value !== undefined);\n if (provided.length === 0 && !submit_for_review) {\n throw new Error(\"Provide at least one field to update, or set submit_for_review: true.\");\n }\n if (fields.photo_id && fields.video_id) {\n throw new Error(\"Only one of photo_id or video_id may be provided.\");\n }\n\n const currency = await ctx.client.resolveCurrency(account_id);\n if (fields.cpm !== undefined) ctx.policy.assertCpm(fields.cpm, currency);\n if (fields.daily_budget_limit !== undefined && fields.daily_budget_limit > 0) {\n ctx.policy.assertDailyBudget(fields.daily_budget_limit, currency);\n }\n\n const params = compact({\n account_id,\n ad_id,\n ...fields,\n return_target: include_targeting,\n });\n\n if (dry_run) {\n return {\n dry_run: true,\n currency,\n request: params,\n submit_for_review: submit_for_review ?? false,\n };\n }\n\n ctx.policy.assertWrite(confirm);\n const response: Record<string, unknown> = {};\n\n if (provided.length > 0) {\n const result = await ctx.client.write<Ad>(\"editAd\", params);\n response.ad = result.data;\n response.idempotency_key = result.idempotencyKey;\n }\n\n if (submit_for_review) {\n const review = await ctx.client.write<Ad>(\n \"submitAdForReview\",\n compact({ account_id, ad_id }),\n );\n response.submitted = review.data;\n response.submit_idempotency_key = review.idempotencyKey;\n }\n\n return response;\n }),\n );\n\n server.registerTool(\n \"tg_ad_budget\",\n {\n title: \"Increase or decrease ad budget\",\n description:\n \"Move funds into or out of an ad. amount is in the account currency and must respect its precision. \" +\n \"Telegram only allows decreasing budget when the ad has been inactive for at least 10 minutes. \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n ad_id: z.number().int().positive(),\n direction: z.enum([\"increase\", \"decrease\"]),\n amount: z.number().positive(),\n include_targeting: z.boolean().optional(),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_ad_budget\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const currency = await ctx.client.resolveCurrency(input.account_id);\n ctx.policy.assertAmount(input.amount, currency);\n ctx.policy.assertWrite(input.confirm);\n\n const method = input.direction === \"increase\" ? \"increaseAdBudget\" : \"decreaseAdBudget\";\n const result = await ctx.client.write<Ad>(\n method,\n compact({\n account_id: input.account_id,\n ad_id: input.ad_id,\n amount: input.amount,\n return_target: input.include_targeting,\n }),\n );\n return { ad: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n\n server.registerTool(\n \"tg_delete_ad\",\n {\n title: \"Delete ad\",\n description:\n \"Permanently delete an advertisement. Telegram requires the ad to be inactive for at least 10 minutes \" +\n \"and to have no remaining budget. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n ad_id: z.number().int().positive(),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_delete_ad\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n ctx.policy.assertWrite(input.confirm);\n await ctx.client.write(\n \"deleteAd\",\n compact({ account_id: input.account_id, ad_id: input.ad_id }),\n );\n return { deleted: true, ad_id: input.ad_id };\n }),\n );\n\n const uploadLimits = {\n ad_photo: {\n method: \"uploadAdPhoto\",\n maxBytes: 5 * 1024 * 1024,\n extensions: [\".jpg\", \".jpeg\", \".png\"],\n },\n ad_video: { method: \"uploadAdVideo\", maxBytes: 20 * 1024 * 1024, extensions: [\".mp4\"] },\n website_photo: {\n method: \"uploadWebsitePhoto\",\n maxBytes: 1 * 1024 * 1024,\n extensions: [\".jpg\", \".jpeg\", \".png\"],\n },\n } as const;\n\n server.registerTool(\n \"tg_upload_media\",\n {\n title: \"Upload ad media\",\n description:\n \"Upload a local file to Telegram Ads and return its media ID. Limits: ad_photo JPEG/PNG up to 5 MiB \" +\n \"and at least 640px wide; ad_video MP4 up to 20 MiB, 16:9, 3-60 seconds; website_photo JPEG/PNG up to \" +\n \"1 MiB and at least 150x150. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n kind: z.enum([\"ad_photo\", \"ad_video\", \"website_photo\"]),\n path: z\n .string()\n .min(1)\n .describe(\"Absolute path, or a path relative to the server process.\"),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_upload_media\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const limits = uploadLimits[input.kind];\n const filePath = resolve(input.path);\n const info = await stat(filePath);\n if (!info.isFile()) throw new Error(`${filePath} is not a file.`);\n\n const extension = extname(filePath).toLowerCase();\n if (!(limits.extensions as readonly string[]).includes(extension)) {\n throw new Error(\n `${input.kind} must be one of ${limits.extensions.join(\", \")}; received ${extension || \"no extension\"}.`,\n );\n }\n if (info.size > limits.maxBytes) {\n throw new Error(\n `${filePath} is ${info.size} bytes, above the ${limits.maxBytes} byte limit for ${input.kind}.`,\n );\n }\n\n ctx.policy.assertWrite(input.confirm);\n const result = await ctx.client.upload<Record<string, string>>(\n limits.method,\n compact({ account_id: input.account_id }),\n { path: filePath },\n );\n return { kind: input.kind, ...result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n}\n","import { z } from \"zod\";\n\nexport const idOrUsername = z.union([z.string().min(1), z.number().int().positive()]);\n\nconst languages = z.array(z.string().min(2).max(16)).max(8);\nconst topicIds = z.array(z.number().int().positive()).max(20);\nconst channelIds = z.array(idOrUsername).max(100);\nconst audienceIds = z.array(z.number().int().positive()).max(10);\n\nexport const targetSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"channels\"),\n language_codes: languages\n .optional()\n .describe(\"Channel languages (up to 8 IETF tags). Must be empty when channel_ids is used.\"),\n topic_ids: topicIds\n .optional()\n .describe(\"Channel topics (up to 20). Must be empty when channel_ids is used.\"),\n exclude_topic_ids: topicIds.optional(),\n channel_ids: channelIds\n .optional()\n .describe(\"Channels to include, as @username or numeric ID resolved by this account.\"),\n exclude_channel_ids: channelIds.optional(),\n }),\n z.object({\n type: z.literal(\"users\"),\n country_codes: z\n .array(z.string().length(2))\n .max(8)\n .describe(\n \"ISO 3166-1 alpha-2 country codes (up to 8). Exactly one when location_ids is used.\",\n ),\n location_ids: z.array(z.number().int().positive()).max(20).optional(),\n language_codes: languages.optional(),\n topic_ids: topicIds.optional(),\n intersect_topics: z.boolean().optional(),\n exclude_topic_ids: topicIds.optional(),\n channel_ids: channelIds.optional(),\n exclude_channel_ids: channelIds.optional(),\n audience_ids: audienceIds.optional(),\n exclude_audience_ids: audienceIds.optional(),\n device: z.enum([\"ios\", \"android\", \"mobile\", \"desktop\"]).optional(),\n exclude_political_channels: z.boolean().optional(),\n political_channels_only: z.boolean().optional(),\n }),\n z.object({\n type: z.literal(\"bots\"),\n bot_ids: z.array(idOrUsername).max(100).describe(\"Bots to target, as @username or numeric ID.\"),\n }),\n z.object({\n type: z.literal(\"search\"),\n search_queries: z.array(z.string().min(1).max(64)).min(1).max(10),\n }),\n]);\n\nexport type Target = z.infer<typeof targetSchema>;\n\n/**\n * Telegram limits included and excluded values together, so per-field array\n * limits are not enough. Catching this here produces a clearer error than the\n * API response.\n */\nexport function assertTargetLimits(target: Target): void {\n if (target.type === \"channels\") {\n if (target.channel_ids?.length && (target.topic_ids?.length || target.language_codes?.length)) {\n throw new Error(\"channel_ids cannot be combined with topic_ids or language_codes.\");\n }\n assertCombined(target.topic_ids, target.exclude_topic_ids, 20, \"topics\");\n assertCombined(target.channel_ids, target.exclude_channel_ids, 100, \"channels\");\n }\n\n if (target.type === \"users\") {\n assertCombined(target.topic_ids, target.exclude_topic_ids, 20, \"topics\");\n assertCombined(target.channel_ids, target.exclude_channel_ids, 100, \"channels\");\n assertCombined(target.audience_ids, target.exclude_audience_ids, 10, \"audiences\");\n if (target.location_ids?.length && target.country_codes.length !== 1) {\n throw new Error(\"country_codes must contain exactly one country when location_ids is used.\");\n }\n }\n}\n\nfunction assertCombined(\n included: unknown[] | undefined,\n excluded: unknown[] | undefined,\n limit: number,\n label: string,\n): void {\n const total = (included?.length ?? 0) + (excluded?.length ?? 0);\n if (total > limit) {\n throw new Error(\n `Included and excluded ${label} may contain at most ${limit} entries combined.`,\n );\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { Audience, AudiencesList } from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nconst phone = z\n .string()\n .refine(\n (value) => /^\\+?[0-9]{7,15}$/.test(value) || /^[a-f0-9]{64}$/i.test(value),\n \"Use a phone number (7-15 digits, optional +) or a 64-character SHA256 hash.\",\n );\n\nexport function registerAudienceTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_audiences\",\n {\n title: \"List audiences\",\n description:\n \"List retargeting audiences for an account, or fetch specific audiences by ID. \" +\n \"Audience sizes are in phone numbers.\",\n inputSchema: z.object({\n audience_ids: z.array(z.number().int().positive()).max(100).optional(),\n account_id: z.string().optional(),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_audiences\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n if (input.audience_ids && input.audience_ids.length > 0) {\n const audiences = await ctx.client.call<Audience[]>(\n \"getAudiencesById\",\n compact({ account_id: input.account_id, audience_ids: input.audience_ids }),\n );\n return { audiences };\n }\n\n const result = await ctx.client.call<AudiencesList>(\n \"getAudiencesList\",\n compact({ account_id: input.account_id, offset: input.offset, limit: input.limit }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_manage_audience\",\n {\n title: \"Create, update or delete an audience\",\n description:\n \"Manage phone-number retargeting audiences. action=create needs title and add_phones; \" +\n \"action=update needs audience_id plus at least one change; action=delete needs audience_id. \" +\n \"Phone numbers are sent to Telegram and are never written to the audit log. \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n action: z.enum([\"create\", \"update\", \"delete\"]),\n audience_id: z.number().int().positive().optional(),\n title: z.string().min(1).max(64).optional(),\n add_phones: z.array(phone).max(10_000).optional(),\n remove_phones: z.array(phone).max(10_000).optional(),\n reset_phones: z.boolean().optional(),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_manage_audience\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n ctx.policy.assertWrite(input.confirm);\n\n if (input.action === \"create\") {\n if (!input.title) throw new Error(\"title is required when action=create.\");\n if (!input.add_phones?.length)\n throw new Error(\"add_phones is required when action=create.\");\n const result = await ctx.client.write<Audience>(\n \"createAudience\",\n compact({\n account_id: input.account_id,\n title: input.title,\n add_phones: input.add_phones,\n }),\n );\n return { audience: result.data, idempotency_key: result.idempotencyKey };\n }\n\n if (input.audience_id === undefined) {\n throw new Error(\"audience_id is required when action=update or action=delete.\");\n }\n\n if (input.action === \"delete\") {\n await ctx.client.write(\n \"deleteAudience\",\n compact({\n account_id: input.account_id,\n audience_id: input.audience_id,\n }),\n );\n return { deleted: true, audience_id: input.audience_id };\n }\n\n if (\n input.title === undefined &&\n !input.add_phones?.length &&\n !input.remove_phones?.length &&\n input.reset_phones === undefined\n ) {\n throw new Error(\n \"Provide title, add_phones, remove_phones or reset_phones to update an audience.\",\n );\n }\n\n const result = await ctx.client.write<Audience>(\n \"editAudience\",\n compact({\n account_id: input.account_id,\n audience_id: input.audience_id,\n title: input.title,\n add_phones: input.add_phones,\n remove_phones: input.remove_phones,\n reset_phones: input.reset_phones,\n }),\n );\n return { audience: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { buildSdkDts, searchMethods } from \"../code-mode/sdk.js\";\nimport { runCode } from \"../code-mode/run.js\";\nimport { isWriteMethod } from \"../api/catalog.js\";\nimport type { Params } from \"../api/client.js\";\nimport { toolHandler, type ToolContext } from \"./helpers.js\";\n\nexport function registerCodeTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_search\",\n {\n title: \"Search Telegram Ads methods\",\n description:\n \"Search the official Telegram Ads API methods by name, description or parameter. \" +\n \"Use this to discover the right method before calling tg_api_call or writing a tg_execute script. \" +\n \"Returns names, descriptions, write flags, return types and full parameter signatures.\",\n inputSchema: z.object({\n query: z.string().optional().describe(\"Empty returns all methods.\"),\n write: z.boolean().optional().describe(\"Only return methods that change state.\"),\n limit: z.number().int().min(1).max(50).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n toolHandler(ctx, \"tg_search\", async (input) => {\n const methods = searchMethods(input.query ?? \"\", input.limit ?? 10, input.write);\n return { count: methods.length, methods };\n }),\n );\n\n server.registerTool(\n \"tg_get_sdk\",\n {\n title: \"Get the Code Mode TypeScript SDK\",\n description:\n \"Return the TypeScript declarations for the tg namespace available inside tg_execute. \" +\n \"Read this before writing a non-trivial script; it documents every method signature.\",\n inputSchema: z.object({}),\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n toolHandler(ctx, \"tg_get_sdk\", async () => ({ sdk: buildSdkDts() })),\n );\n\n server.registerTool(\n \"tg_execute\",\n {\n title: \"Execute a Telegram Ads script\",\n description:\n \"Run JavaScript in an isolated QuickJS sandbox with a typed tg object, for multi-step work that \" +\n \"would otherwise need many tool calls: bulk edits, cross-ad analysis, pagination, joins and reports. \" +\n \"Only console.log output and the returned value come back. No network, filesystem, process or env \" +\n \"access. Calls run sequentially; the limit is 25 API calls, 15 seconds and 64 KB of output. \" +\n \"Example: `const ads = await tg.getAdsList({limit: 100}); return ads.ads.length`. \" +\n \"Write methods require TG_ADS_MODE=write, TG_ADS_CODE_MODE=write and confirm: true.\",\n inputSchema: z.object({\n code: z\n .string()\n .min(1)\n .max(20_000)\n .describe(\"An async arrow function, a function expression, or a plain statement body.\"),\n confirm: z.boolean().optional().describe(\"Required before any write method can run.\"),\n idempotency_key: z\n .string()\n .min(1)\n .max(64)\n .optional()\n .describe(\"Prefix for write idempotency keys, useful when retrying a script.\"),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_execute\", async (input) => {\n if (!ctx.policy.codeModeEnabled) {\n throw new Error(\n \"Code Mode is disabled. Set TG_ADS_CODE_MODE=read-only or write to enable it.\",\n );\n }\n\n const allowWrite =\n ctx.policy.canWrite && ctx.policy.codeModeCanWrite && input.confirm === true;\n let writeIndex = 0;\n\n const result = await runCode({\n code: input.code,\n allowWrite,\n isWrite: isWriteMethod,\n call: async (method: string, params: Params) => {\n if (!isWriteMethod(method)) return ctx.client.call(method, params);\n\n ctx.policy.assertCodeModeWrite(input.confirm);\n writeIndex += 1;\n const key = input.idempotency_key\n ? `${input.idempotency_key}-${writeIndex}`.slice(0, 128)\n : undefined;\n const written = await ctx.client.write(\n method,\n params,\n key ? { idempotencyKey: key } : {},\n );\n return written.data;\n },\n });\n\n return result;\n }),\n );\n}\n","import {\n getQuickJS,\n type QuickJSContext,\n type QuickJSDeferredPromise,\n type QuickJSHandle,\n} from \"quickjs-emscripten\";\nimport type { Params } from \"../api/client.js\";\nimport { API_METHODS } from \"../api/catalog.js\";\n\nexport interface CodeRunOptions {\n code: string;\n call: (method: string, params: Params) => Promise<unknown>;\n allowWrite: boolean;\n isWrite: (method: string) => boolean;\n maxCalls?: number;\n timeoutMs?: number;\n maxOutputBytes?: number;\n}\n\nexport interface CodeRunResult {\n ok: boolean;\n result?: unknown;\n logs: string[];\n calls: Array<{ method: string; duration_ms: number; ok: boolean }>;\n duration_ms: number;\n error?: string;\n}\n\nconst PRELUDE = `\n(() => {\n const host = globalThis.__host;\n const log = globalThis.__log;\n delete globalThis.__host;\n delete globalThis.__log;\n\n const tg = {};\n for (const name of Object.keys(host)) {\n tg[name] = async (params) =>\n JSON.parse(await host[name](name, JSON.stringify(params === undefined ? {} : params)));\n }\n globalThis.tg = tg;\n\n const format = (value) => {\n if (typeof value === \"string\") return value;\n try { return JSON.stringify(value); } catch { return String(value); }\n };\n const write = (level) => (...args) =>\n log((level ? level + \" \" : \"\") + args.map(format).join(\" \").slice(0, 2000));\n globalThis.console = { log: write(\"\"), warn: write(\"[warn]\"), error: write(\"[error]\") };\n})();\n`;\n\nfunction looksLikeFunction(code: string): boolean {\n return /^\\s*(async\\s+)?(\\(|function\\b|[A-Za-z_$][\\w$]*\\s*=>)/.test(code);\n}\n\nfunction wrapCode(code: string): string {\n return looksLikeFunction(code) ? `(${code})()` : `(async () => {\\n${code}\\n})()`;\n}\n\nfunction errorMessage(context: QuickJSContext, handle: QuickJSHandle): string {\n const dumped: unknown = context.dump(handle);\n if (dumped instanceof Error) return dumped.message;\n if (dumped && typeof dumped === \"object\" && \"message\" in dumped) {\n const message = (dumped as { message?: unknown }).message;\n if (typeof message === \"string\" && message.length > 0) return message;\n }\n return String(dumped);\n}\n\n/**\n * Executes model-written JavaScript inside QuickJS (WebAssembly), with no\n * filesystem, network, process or environment access. The only capability is\n * the `tg` object, whose calls are bridged back to the host through deferred\n * promises. API calls run one at a time, in script order.\n */\nexport async function runCode(options: CodeRunOptions): Promise<CodeRunResult> {\n const started = Date.now();\n const timeoutMs = options.timeoutMs ?? 15_000;\n const deadline = started + timeoutMs;\n const maxCalls = options.maxCalls ?? 25;\n const maxOutputBytes = options.maxOutputBytes ?? 64 * 1024;\n const logs: string[] = [];\n const calls: CodeRunResult[\"calls\"] = [];\n const module = await getQuickJS();\n const context = module.newContext();\n\n const failed = (error: string): CodeRunResult => ({\n ok: false,\n error,\n logs,\n calls,\n duration_ms: Date.now() - started,\n });\n\n try {\n context.runtime.setMemoryLimit(64 * 1024 * 1024);\n context.runtime.setMaxStackSize(1024 * 1024);\n context.runtime.setInterruptHandler(() => Date.now() > deadline);\n\n interface PendingCall {\n deferred: QuickJSDeferredPromise;\n method: string;\n params: Params;\n }\n const queue: PendingCall[] = [];\n let callCount = 0;\n\n const rejected = (message: string): QuickJSHandle => {\n const promise = context.newPromise();\n const error = context.newError(new Error(message));\n promise.reject(error);\n error.dispose();\n const handle = promise.handle.dup();\n promise.dispose();\n return handle;\n };\n\n const callHandle = context.newFunction(\n \"__call\",\n (methodHandle: QuickJSHandle, paramsHandle: QuickJSHandle) => {\n const method = context.getString(methodHandle);\n\n if (callCount >= maxCalls) {\n return rejected(`Call limit reached (${maxCalls}). Reduce the number of API calls.`);\n }\n if (Date.now() > deadline) {\n return rejected(\"Execution deadline reached.\");\n }\n if (options.isWrite(method) && !options.allowWrite) {\n return rejected(\n `${method} changes state, but Code Mode is read-only. ` +\n \"Set TG_ADS_CODE_MODE=write and pass confirm: true to allow writes.\",\n );\n }\n\n let params: Params;\n try {\n const parsed: unknown = JSON.parse(context.getString(paramsHandle));\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n return rejected(`${method} expects a plain object of parameters.`);\n }\n params = parsed as Params;\n } catch {\n return rejected(`${method} expects a plain object of parameters.`);\n }\n\n callCount += 1;\n const deferred = context.newPromise();\n queue.push({ deferred, method, params });\n return deferred.handle.dup();\n },\n );\n\n const logHandle = context.newFunction(\"__log\", (messageHandle: QuickJSHandle) => {\n if (logs.length < 200) logs.push(context.getString(messageHandle));\n });\n\n const hostHandle = context.newObject();\n for (const method of API_METHODS) {\n if (method.deprecated) continue;\n context.setProp(hostHandle, method.name, callHandle);\n }\n\n context.setProp(context.global, \"__host\", hostHandle);\n context.setProp(context.global, \"__log\", logHandle);\n hostHandle.dispose();\n callHandle.dispose();\n logHandle.dispose();\n\n const prelude = context.evalCode(PRELUDE);\n context.unwrapResult(prelude).dispose();\n\n const evaluation = context.evalCode(wrapCode(options.code), \"tg-execute.js\");\n if (evaluation.error) {\n const message = errorMessage(context, evaluation.error);\n evaluation.error.dispose();\n return failed(message);\n }\n\n const handle = context.unwrapResult(evaluation);\n try {\n // Alternate between host API calls and guest microtasks. Every guest\n // await is backed by a deferred promise resolved from this loop.\n for (;;) {\n const next = queue.shift();\n if (next) {\n const callStarted = Date.now();\n try {\n const value = await options.call(next.method, next.params);\n const serialized = context.newString(JSON.stringify(value ?? null));\n next.deferred.resolve(serialized);\n serialized.dispose();\n calls.push({ method: next.method, duration_ms: Date.now() - callStarted, ok: true });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const errorHandle = context.newError(new Error(message));\n next.deferred.reject(errorHandle);\n errorHandle.dispose();\n calls.push({ method: next.method, duration_ms: Date.now() - callStarted, ok: false });\n }\n next.deferred.dispose();\n continue;\n }\n\n const jobs = context.runtime.executePendingJobs();\n if (jobs.error) {\n const message = errorMessage(context, jobs.error);\n jobs.error.dispose();\n return failed(message);\n }\n if (jobs.value === 0) break;\n }\n\n const state = context.getPromiseState(handle);\n if (state.type === \"pending\") {\n return failed(\"Script returned a promise that never settled.\");\n }\n if (state.type === \"rejected\") {\n const message = errorMessage(context, state.error);\n state.error.dispose();\n return failed(message);\n }\n\n const value = context.dump(state.value);\n state.value.dispose();\n let serialized: string;\n try {\n serialized = JSON.stringify(value ?? null);\n } catch {\n serialized = String(value);\n }\n if (serialized.length > maxOutputBytes) {\n return failed(\n `Result is ${serialized.length} bytes, above the ${maxOutputBytes} byte limit. ` +\n \"Filter or aggregate inside the script and return a smaller object.\",\n );\n }\n\n return {\n ok: true,\n result: value,\n logs,\n calls,\n duration_ms: Date.now() - started,\n };\n } finally {\n handle.dispose();\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return failed(\n message.includes(\"interrupted\") ? `Execution exceeded the ${timeoutMs} ms limit.` : message,\n );\n } finally {\n context.dispose();\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { Pixel, PixelEvent, PixelEventsList } from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nconst eventType = z.enum([\n \"page_view\",\n \"add_to_cart\",\n \"add_to_wishlist\",\n \"customize_product\",\n \"initiate_checkout\",\n \"add_payment_info\",\n \"purchase\",\n \"contact\",\n \"lead\",\n \"schedule\",\n \"complete_registration\",\n \"submit_application\",\n \"start_trial\",\n \"subscribe\",\n \"view_content\",\n \"search\",\n \"find_location\",\n \"donate\",\n \"custom\",\n]);\n\nexport function registerPixelTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_get_pixel\",\n {\n title: \"Get pixel\",\n description:\n \"Get the account's Pixel Tag, including its ID and the HTML code snippet used to install it on a website.\",\n inputSchema: z.object({\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_pixel\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const pixel = await ctx.client.call<Pixel>(\n \"getPixel\",\n compact({ account_id: input.account_id }),\n );\n return { pixel };\n }),\n );\n\n server.registerTool(\n \"tg_list_pixel_events\",\n {\n title: \"List pixel events\",\n description:\n \"List conversion events for the account's pixel, or fetch specific events by ID.\",\n inputSchema: z.object({\n event_ids: z.array(z.string().min(1)).max(100).optional(),\n account_id: z.string().optional(),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_pixel_events\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n if (input.event_ids && input.event_ids.length > 0) {\n const events = await ctx.client.call<PixelEvent[]>(\n \"getPixelEventsById\",\n compact({ account_id: input.account_id, event_ids: input.event_ids }),\n );\n return { events };\n }\n\n const result = await ctx.client.call<PixelEventsList>(\n \"getPixelEventsList\",\n compact({ account_id: input.account_id, offset: input.offset, limit: input.limit }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_manage_pixel\",\n {\n title: \"Manage pixel and conversion events\",\n description:\n \"action=create_pixel creates the account's Pixel Tag (only one per account); \" +\n \"action=create_event needs title and type; action=update_event renames an event; \" +\n \"action=delete_event removes an event that is not used by any ad. \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n action: z.enum([\"create_pixel\", \"create_event\", \"update_event\", \"delete_event\"]),\n event_id: z.string().min(1).optional(),\n title: z.string().min(1).max(64).optional(),\n type: eventType.optional().describe(\"Event type, for example purchase or lead.\"),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_manage_pixel\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n ctx.policy.assertWrite(input.confirm);\n\n if (input.action === \"create_pixel\") {\n const result = await ctx.client.write<Pixel>(\n \"createPixel\",\n compact({ account_id: input.account_id }),\n );\n return { pixel: result.data, idempotency_key: result.idempotencyKey };\n }\n\n if (input.action === \"create_event\") {\n if (!input.title) throw new Error(\"title is required when action=create_event.\");\n if (!input.type) throw new Error(\"type is required when action=create_event.\");\n const result = await ctx.client.write<PixelEvent>(\n \"createPixelEvent\",\n compact({\n account_id: input.account_id,\n title: input.title,\n type: input.type,\n }),\n );\n return { event: result.data, idempotency_key: result.idempotencyKey };\n }\n\n if (!input.event_id) throw new Error(\"event_id is required for event actions.\");\n\n if (input.action === \"update_event\") {\n if (!input.title) throw new Error(\"title is required when action=update_event.\");\n const result = await ctx.client.write<PixelEvent>(\n \"editPixelEvent\",\n compact({\n account_id: input.account_id,\n event_id: input.event_id,\n title: input.title,\n }),\n );\n return { event: result.data, idempotency_key: result.idempotencyKey };\n }\n\n await ctx.client.write(\n \"deletePixelEvent\",\n compact({\n account_id: input.account_id,\n event_id: input.event_id,\n }),\n );\n return { deleted: true, event_id: input.event_id };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { getMethod, isWriteMethod } from \"../api/catalog.js\";\nimport type { Params } from \"../api/client.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\ninterface MoneyRule {\n field: string;\n kind: \"cpm\" | \"ad\" | \"daily\" | \"amount\";\n}\n\nconst MONEY_RULES: Record<string, MoneyRule[]> = {\n createAd: [\n { field: \"cpm\", kind: \"cpm\" },\n { field: \"initial_budget\", kind: \"ad\" },\n { field: \"daily_budget_limit\", kind: \"daily\" },\n ],\n editAd: [\n { field: \"cpm\", kind: \"cpm\" },\n { field: \"daily_budget_limit\", kind: \"daily\" },\n ],\n increaseAdBudget: [{ field: \"amount\", kind: \"amount\" }],\n decreaseAdBudget: [{ field: \"amount\", kind: \"amount\" }],\n increaseAccountBudget: [{ field: \"amount\", kind: \"amount\" }],\n decreaseAccountBudget: [{ field: \"amount\", kind: \"amount\" }],\n};\n\nexport function registerRawTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_api_call\",\n {\n title: \"Call any Telegram Ads API method\",\n description:\n \"Escape hatch for methods that do not have a dedicated tool. Pass the exact method name from \" +\n \"tg_search and its parameters. Read methods run immediately; write methods require \" +\n \"TG_ADS_MODE=write and confirm: true, and receive an idempotency key automatically.\",\n inputSchema: z.object({\n method: z\n .string()\n .min(1)\n .describe(\"Exact method name, for example getTargetLocationsList.\"),\n params: z.record(z.string(), z.unknown()).optional(),\n confirm: z.boolean().optional(),\n idempotency_key: z.string().min(1).max(128).optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_api_call\", async (input) => {\n const method = getMethod(input.method);\n if (!method) {\n throw new Error(\n `Unknown method ${input.method}. Use tg_search to find the exact name. Names are case-sensitive.`,\n );\n }\n if (method.deprecated) {\n throw new Error(`${method.name} is deprecated: ${method.description}`);\n }\n\n const params: Params = input.params ?? {};\n const accountId = typeof params.account_id === \"string\" ? params.account_id : undefined;\n ctx.policy.assertAccount(accountId);\n\n const rules = MONEY_RULES[method.name];\n if (rules && rules.length > 0) {\n const currency = await ctx.client.resolveCurrency(accountId);\n for (const rule of rules) {\n const value = params[rule.field];\n if (typeof value !== \"number\") continue;\n if (rule.kind === \"cpm\") ctx.policy.assertCpm(value, currency);\n else if (rule.kind === \"ad\") ctx.policy.assertAdBudget(value, currency, rule.field);\n else if (rule.kind === \"daily\") ctx.policy.assertDailyBudget(value, currency);\n else ctx.policy.assertAmount(value, currency);\n }\n }\n\n if (isWriteMethod(method.name)) {\n ctx.policy.assertWrite(input.confirm);\n const result = await ctx.client.write(method.name, params, {\n ...(input.idempotency_key ? { idempotencyKey: input.idempotency_key } : {}),\n });\n return { method: method.name, result: result.data, idempotency_key: result.idempotencyKey };\n }\n\n const result = await ctx.client.call(method.name, compact(params));\n return { method: method.name, result };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { AccountReportItem, AdStatItem } from \"../api/types.js\";\nimport {\n compact,\n parseRange,\n planWindows,\n summarizeStats,\n toolHandler,\n type ToolContext,\n} from \"./helpers.js\";\n\nconst time = z.union([z.string().min(1), z.number().int().positive()]);\n\nexport function registerStatsTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_get_stats\",\n {\n title: \"Get advertising stats\",\n description:\n \"Get account or per-ad statistics for a time range. from/to accept Unix seconds, milliseconds, or \" +\n \"ISO 8601. interval is 86400 (daily, default) or 300 (5 minutes). Ranges above 1000 intervals are \" +\n \"split automatically. Always returns totals and derived CTR/CPM/CPC; set include_series for the \" +\n \"raw time series. Timestamps are inclusive for from and exclusive for to.\",\n inputSchema: z.object({\n scope: z.enum([\"account\", \"ad\"]),\n ad_ids: z.array(z.number().int().positive()).max(100).optional(),\n account_id: z.string().optional(),\n from: time,\n to: time,\n interval: z.union([z.literal(300), z.literal(86400)]).optional(),\n include_series: z\n .boolean()\n .optional()\n .describe(\"Include raw per-interval rows (default false).\"),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_stats\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const interval = input.interval ?? 86400;\n const range = parseRange(input.from, input.to);\n const windows = planWindows(range, interval);\n\n if (input.scope === \"account\") {\n const items: AdStatItem[] = [];\n for (const window of windows) {\n const chunk = await ctx.client.call<AdStatItem[]>(\n \"getAccountStats\",\n compact({\n account_id: input.account_id,\n from_time: window.from,\n to_time: window.to,\n interval,\n }),\n );\n items.push(...chunk);\n }\n\n return {\n scope: \"account\",\n interval,\n from: range.from,\n to: range.to,\n requests: windows.length,\n totals: summarizeStats(items),\n ...(input.include_series ? { series: items } : {}),\n };\n }\n\n const adIds = input.ad_ids ?? [];\n if (adIds.length === 0) {\n throw new Error(\"ad_ids is required when scope is ad.\");\n }\n\n const byAd: Array<{\n ad_id: number;\n totals: ReturnType<typeof summarizeStats>;\n series?: AdStatItem[];\n }> = [];\n const allItems: AdStatItem[] = [];\n\n for (const adId of adIds) {\n const items: AdStatItem[] = [];\n for (const window of windows) {\n const chunk = await ctx.client.call<AdStatItem[]>(\n \"getAdStats\",\n compact({\n account_id: input.account_id,\n ad_id: adId,\n from_time: window.from,\n to_time: window.to,\n interval,\n }),\n );\n items.push(...chunk);\n }\n allItems.push(...items);\n byAd.push({\n ad_id: adId,\n totals: summarizeStats(items),\n ...(input.include_series ? { series: items } : {}),\n });\n }\n\n return {\n scope: \"ad\",\n interval,\n from: range.from,\n to: range.to,\n requests: windows.length * adIds.length,\n totals: summarizeStats(allItems),\n by_ad: byAd,\n };\n }),\n );\n\n server.registerTool(\n \"tg_get_report\",\n {\n title: \"Get monthly account report\",\n description:\n \"Get Telegram's monthly report for all active ads in an account, including views, opens, clicks, \" +\n \"actions and spend per ad.\",\n inputSchema: z.object({\n year: z.number().int().min(2024).max(2100),\n month: z.number().int().min(1).max(12),\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_report\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const report = await ctx.client.call<AccountReportItem[]>(\n \"getAccountReport\",\n compact({ account_id: input.account_id, year: input.year, month: input.month }),\n );\n return { year: input.year, month: input.month, items: report };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type {\n TargetBot,\n TargetChannel,\n TargetCountry,\n TargetLanguage,\n TargetLocation,\n TargetLocationList,\n TargetTopic,\n} from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\nimport { idOrUsername } from \"./schemas.js\";\n\nexport function registerTargetingTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_targeting\",\n {\n title: \"List targeting options\",\n description:\n \"Look up targeting catalogs. kind=languages, topics or countries takes no extra arguments. \" +\n \"kind=locations searches by country_code and/or query, or resolves location_ids. \" +\n \"kind=channel resolves a channel by @username or numeric ID; kind=bot does the same for bots. \" +\n \"Prefer @username for channels and bots: numeric IDs only work after this account has resolved them.\",\n inputSchema: z.object({\n kind: z.enum([\"languages\", \"topics\", \"countries\", \"locations\", \"channel\", \"bot\"]),\n country_code: z.string().length(2).optional().describe(\"Required for location search.\"),\n query: z.string().optional().describe(\"Location search text.\"),\n location_ids: z.array(z.number().int().positive()).max(100).optional(),\n offset: z.string().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n channel: idOrUsername.optional(),\n bot: idOrUsername.optional(),\n for_excluding: z.boolean().optional(),\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_targeting\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n switch (input.kind) {\n case \"languages\": {\n const languages = await ctx.client.call<TargetLanguage[]>(\"getTargetLanguagesList\");\n return { languages };\n }\n case \"topics\": {\n const topics = await ctx.client.call<TargetTopic[]>(\"getTargetTopicsList\");\n return { topics };\n }\n case \"countries\": {\n const countries = await ctx.client.call<TargetCountry[]>(\"getTargetCountriesList\");\n return { countries };\n }\n case \"locations\": {\n if (input.location_ids && input.location_ids.length > 0) {\n const locations = await ctx.client.call<TargetLocation[]>(\"getTargetLocationsById\", {\n location_ids: input.location_ids,\n });\n return { locations };\n }\n if (!input.country_code) {\n throw new Error(\"country_code is required when searching locations by text.\");\n }\n const result = await ctx.client.call<TargetLocationList>(\n \"getTargetLocationsList\",\n compact({\n country_code: input.country_code,\n query: input.query,\n offset: input.offset,\n limit: input.limit,\n }),\n );\n return result;\n }\n case \"channel\": {\n if (input.channel === undefined) throw new Error(\"channel is required for kind=channel.\");\n const channel = await ctx.client.call<TargetChannel>(\n \"getTargetChannel\",\n compact({ channel_id: input.channel, for_excluding: input.for_excluding }),\n );\n return { channel };\n }\n case \"bot\": {\n if (input.bot === undefined) throw new Error(\"bot is required for kind=bot.\");\n const bot = await ctx.client.call<TargetBot>(\"getTargetBot\", { bot_id: input.bot });\n return { bot };\n }\n }\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type {\n AccountTransactionsList,\n AdTransactionsList,\n TransactionStatus,\n} from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nexport function registerTransactionTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_transactions\",\n {\n title: \"List transactions\",\n description:\n \"List account-level or ad-level transactions. Use next_offset to page. \" +\n \"Transactions explain where budget was added or spent.\",\n inputSchema: z.object({\n scope: z.enum([\"account\", \"ad\"]),\n ad_id: z.number().int().positive().optional(),\n account_id: z.string().optional(),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_transactions\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n if (input.scope === \"ad\") {\n if (input.ad_id === undefined) throw new Error(\"ad_id is required when scope=ad.\");\n const result = await ctx.client.call<AdTransactionsList>(\n \"getAdTransactionsList\",\n compact({\n account_id: input.account_id,\n ad_id: input.ad_id,\n offset: input.offset,\n limit: input.limit,\n }),\n );\n return result;\n }\n\n const result = await ctx.client.call<AccountTransactionsList>(\n \"getAccountTransactionsList\",\n compact({ account_id: input.account_id, offset: input.offset, limit: input.limit }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_get_transaction\",\n {\n title: \"Get transaction status\",\n description: \"Check the status of a budget transaction by its transaction ID.\",\n inputSchema: z.object({\n transaction_id: z.string().min(1),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_transaction\", async (input) => {\n const status = await ctx.client.call<TransactionStatus>(\"getTransactionStatus\", {\n transaction_id: input.transaction_id,\n });\n return { transaction: status };\n }),\n );\n}\n","import { registerAccountTools } from \"./account.js\";\nimport { registerAdTools } from \"./ads.js\";\nimport { registerAudienceTools } from \"./audiences.js\";\nimport { registerCodeTools } from \"./code.js\";\nimport { registerPixelTools } from \"./pixels.js\";\nimport { registerRawTools } from \"./raw.js\";\nimport { registerStatsTools } from \"./stats.js\";\nimport { registerTargetingTools } from \"./targeting.js\";\nimport { registerTransactionTools } from \"./transactions.js\";\nimport type { ToolContext } from \"./helpers.js\";\nimport type { McpServer } from \"@modelcontextprotocol/server\";\n\nexport function registerTools(server: McpServer, ctx: ToolContext): void {\n registerAccountTools(server, ctx);\n registerAdTools(server, ctx);\n registerStatsTools(server, ctx);\n registerTargetingTools(server, ctx);\n registerAudienceTools(server, ctx);\n registerPixelTools(server, ctx);\n registerTransactionTools(server, ctx);\n registerCodeTools(server, ctx);\n registerRawTools(server, ctx);\n}\n\nexport type { ToolContext };\n"],"mappings":";;;AACA,SAAS,eAAe;AACxB,OAAO,QAAQ;AACf,SAAS,QAAQ,UAAU,SAAAA,QAAO,YAAAC,WAAU,iBAAiB;AAC7D,SAAS,eAAe;AACxB,SAAS,WAAAC,UAAS,MAAM,WAAAC,gBAAe;;;ACLvC,SAAS,gBAAgB;AACzB,SAAS,UAAU,eAAe;AAClC,SAAS,kBAAkB;;;ACEpB,IAAM,cAAoC;AAAA,EAC/C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,WAAW;AAAA,IACX,SAAS;AAAA,IACT,cAAc;AAAA,IACd,UAAU;AAAA,MACR;AAAA,QACE,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,eAAe;AAAA,MACjB;AAAA,MACA;AAAA,QACE,QAAQ;AAAA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Q,aAAa,UAAU;AACjC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO,KAAK,QAAQ,GAAG,WAAW,UAAU,4BAA4B;AAC1E;AAEA,SAAS,OAAO,OAAuB;AACrC,MAAI,MAAM,UAAU,EAAG,QAAO;AAC9B,SAAO,GAAG,MAAM,MAAM,GAAG,CAAC,CAAC,SAAI,MAAM,MAAM,EAAE,CAAC;AAChD;AAEA,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,UAAmB;AACzD,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,UAAQ,OAAO,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,OAAO;AAAA,CAAI;AACvD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["mkdir","readFile","dirname","resolve","resolve","dot","z","z","z","extname","z","z","z","extname","z","z","result","z","handle","value","serialized","z","z","z","z","z","result","z","z","z","z","languages","z","z","result","resolve","readFile","mkdir","dirname"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/api/client.ts","../src/api/catalog.ts","../src/errors.ts","../src/version.ts","../src/config.ts","../src/server.ts","../src/audit.ts","../src/money.ts","../src/policy.ts","../src/prompts.ts","../src/code-mode/sdk.ts","../src/resources.ts","../src/tools/account.ts","../src/tools/helpers.ts","../src/tools/ads.ts","../src/tools/schemas.ts","../src/tools/audiences.ts","../src/tools/code.ts","../src/code-mode/run.ts","../src/tools/pixels.ts","../src/tools/raw.ts","../src/tools/stats.ts","../src/tools/targeting.ts","../src/tools/transactions.ts","../src/tools/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport pc from \"picocolors\";\nimport { access, copyFile, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { TelegramAdsClient } from \"./api/client.js\";\nimport { loadConfig } from \"./config.js\";\nimport { ConfigError } from \"./errors.js\";\nimport { createServer } from \"./server.js\";\nimport { SERVER_NAME, VERSION } from \"./version.js\";\n\nconst program = new Command();\n\nprogram\n .name(SERVER_NAME)\n .description(\"MCP server for the official Telegram Ads API\")\n .version(VERSION, \"-v, --version\", \"Print the version\");\n\nprogram\n .command(\"serve\", { isDefault: true })\n .description(\"Start the MCP server over stdio\")\n .action(async () => {\n const config = loadConfig();\n const { serveStdio } = await import(\"@modelcontextprotocol/server/stdio\");\n const handle = serveStdio(() => createServer({ config }), {\n onerror: (error) => process.stderr.write(`[${SERVER_NAME}] ${error.message}\\n`),\n });\n\n const shutdown = () => {\n void handle.close().finally(() => process.exit(0));\n };\n process.once(\"SIGINT\", shutdown);\n process.once(\"SIGTERM\", shutdown);\n\n process.stderr.write(\n `[${SERVER_NAME}] ready on stdio (mode=${config.mode}, code_mode=${config.codeMode})\\n`,\n );\n });\n\nprogram\n .command(\"doctor\")\n .description(\"Check configuration and verify the access token against the API\")\n .action(async () => {\n const config = loadConfig();\n const client = new TelegramAdsClient({\n token: config.token,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n\n console.log(`${pc.bold(\"Node\")} ${process.version}`);\n console.log(`${pc.bold(\"Token\")} ${redact(config.token)}`);\n console.log(`${pc.bold(\"Mode\")} ${config.mode}`);\n console.log(`${pc.bold(\"Code Mode\")} ${config.codeMode}`);\n console.log(`${pc.bold(\"Base URL\")} ${config.baseUrl}`);\n console.log(`${pc.bold(\"Audit log\")} ${config.auditLog ?? pc.dim(\"disabled\")}`);\n console.log(\n `${pc.bold(\"Caps\")} cpm=${config.maxCpm ?? \"∞\"} ad=${config.maxAdBudget ?? \"∞\"} daily=${\n config.maxDailyBudget ?? \"∞\"\n }`,\n );\n\n const account = await client.getCurrentAccount();\n console.log(\"\");\n console.log(pc.green(\"✓ Connected to the Telegram Ads API\"));\n console.log(` account_id: ${account.account_id}`);\n console.log(` title: ${account.title ?? \"—\"}`);\n console.log(` currency: ${account.currency}`);\n console.log(` remaining: ${account.remaining_budget ?? \"—\"}`);\n console.log(` ads budget: ${account.ads_budget ?? \"—\"}`);\n });\n\nprogram\n .command(\"init\")\n .description(\"Write MCP client configuration for local use\")\n .option(\"--client <client...>\", \"claude-desktop, cursor, opencode, claude-code, codex, or all\", [\n \"claude-desktop\",\n ])\n .option(\"--token <token>\", \"Telegram Ads token (defaults to TELEGRAM_ADS_TOKEN)\")\n .option(\"--mode <mode>\", \"read-only or write\", \"read-only\")\n .option(\"--code-mode <mode>\", \"off, read-only or write\", \"read-only\")\n .option(\n \"--local <path>\",\n \"Run a local checkout instead of npx (path to the repository root, must be built)\",\n )\n .option(\"--github\", \"Launch the GitHub package instead of the npm package\", false)\n .option(\"--print\", \"Print the configuration instead of writing files\", false)\n .action(async (options: InitOptions) => {\n const token = options.token ?? process.env.TELEGRAM_ADS_TOKEN;\n if (!token) {\n throw new ConfigError(\n \"Provide --token or set TELEGRAM_ADS_TOKEN. Create a token at https://ads.telegram.org/account/api.\",\n );\n }\n if (![\"read-only\", \"write\"].includes(options.mode)) {\n throw new ConfigError(\"--mode must be read-only or write.\");\n }\n if (![\"off\", \"read-only\", \"write\"].includes(options.codeMode)) {\n throw new ConfigError(\"--code-mode must be off, read-only or write.\");\n }\n\n const clients = expandClients(options.client);\n const env = {\n TELEGRAM_ADS_TOKEN: token,\n TG_ADS_MODE: options.mode,\n TG_ADS_CODE_MODE: options.codeMode,\n };\n\n if (options.local && options.github) {\n throw new ConfigError(\"Use either --local or --github, not both.\");\n }\n\n let launch: { command: string; args: string[] } = {\n command: \"npx\",\n args: [\"-y\", options.github ? GITHUB_PACKAGE : SERVER_NAME],\n };\n if (options.local) {\n const root = resolve(options.local);\n const entry = join(root, \"dist\", \"cli.js\");\n try {\n await access(entry);\n } catch {\n throw new ConfigError(`${entry} was not found. Run \"npm run build\" in ${root} first.`);\n }\n launch = { command: \"node\", args: [entry] };\n }\n\n const standardEntry = { ...launch, env };\n const openCodeEntry = {\n type: \"local\",\n command: [launch.command, ...launch.args],\n environment: env,\n codemode: false,\n };\n\n for (const client of clients) {\n if (client === \"claude-desktop\") {\n await writeConfig(\n claudeDesktopPath(),\n (config) => ({\n ...config,\n mcpServers: { ...asObject(config.mcpServers), \"telegram-ads\": standardEntry },\n }),\n options.print,\n );\n } else if (client === \"cursor\") {\n await writeConfig(\n join(homedir(), \".cursor\", \"mcp.json\"),\n (config) => ({\n ...config,\n mcpServers: { ...asObject(config.mcpServers), \"telegram-ads\": standardEntry },\n }),\n options.print,\n );\n } else if (client === \"opencode\") {\n await writeConfig(\n join(homedir(), \".config\", \"opencode\", \"opencode.json\"),\n (config) => {\n const mcp = asObject(config.mcp);\n return {\n ...config,\n mcp: {\n ...mcp,\n servers: { ...asObject(mcp.servers), \"telegram-ads\": openCodeEntry },\n },\n };\n },\n options.print,\n );\n } else if (client === \"claude-code\") {\n console.log(\n `\\n${pc.bold(\"Claude Code\")}\\n claude mcp add telegram-ads --scope user \\\\\\n` +\n ` --env TELEGRAM_ADS_TOKEN=<your-token> --env TG_ADS_MODE=${options.mode} \\\\\\n` +\n ` -- ${shellLaunch(launch)}\\n`,\n );\n } else if (client === \"codex\") {\n console.log(\n `\\n${pc.bold(\"Codex\")}\\n codex mcp add telegram-ads \\\\\\n` +\n ` --env TELEGRAM_ADS_TOKEN=<your-token> --env TG_ADS_MODE=${options.mode} \\\\\\n` +\n ` -- ${shellLaunch(launch)}\\n`,\n );\n }\n }\n\n if (!options.print) {\n console.log(\n pc.yellow(\n \"\\nThe token is stored in plain text in the files above. Keep them private and revoke the token if exposed.\",\n ),\n );\n console.log(`Restart the client, then ask it to run ${pc.cyan(\"tg_get_account\")}.`);\n }\n });\n\nconst GITHUB_PACKAGE = \"github:furkankoykiran/telegram-ads-mcp\";\n\ninterface InitOptions {\n client: string[];\n token?: string;\n mode: string;\n codeMode: string;\n local?: string;\n github: boolean;\n print: boolean;\n}\n\nfunction shellLaunch(launch: { command: string; args: string[] }): string {\n return [launch.command, ...launch.args]\n .map((part) => (/\\s/.test(part) ? `\"${part}\"` : part))\n .join(\" \");\n}\n\nfunction expandClients(requested: string[]): string[] {\n const valid = new Set([\"claude-desktop\", \"cursor\", \"opencode\", \"claude-code\", \"codex\"]);\n const result = new Set<string>();\n\n for (const value of requested) {\n if (value === \"all\") {\n for (const client of valid) result.add(client);\n continue;\n }\n if (!valid.has(value)) {\n throw new ConfigError(`Unknown client \"${value}\". Use: ${[...valid].join(\", \")}, or all.`);\n }\n result.add(value);\n }\n return [...result];\n}\n\nfunction asObject(value: unknown): Record<string, unknown> {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n}\n\nasync function writeConfig(\n path: string,\n update: (config: Record<string, unknown>) => Record<string, unknown>,\n print: boolean,\n): Promise<void> {\n let current: Record<string, unknown> = {};\n try {\n current = JSON.parse(await readFile(path, \"utf8\")) as Record<string, unknown>;\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== \"ENOENT\") {\n throw new ConfigError(`Could not read ${path}: ${(error as Error).message}`);\n }\n }\n\n const next = update(current);\n\n if (print) {\n console.log(`\\n${pc.bold(path)}\\n${JSON.stringify(next, null, 2)}\\n`);\n return;\n }\n\n await mkdir(dirname(path), { recursive: true });\n if (Object.keys(current).length > 0) {\n await copyFile(path, `${path}.bak`);\n }\n await writeFile(path, `${JSON.stringify(next, null, 2)}\\n`, \"utf8\");\n console.log(`${pc.green(\"✓\")} ${path}`);\n}\n\nfunction claudeDesktopPath(): string {\n if (process.platform === \"win32\") {\n const appData = process.env.APPDATA ?? join(homedir(), \"AppData\", \"Roaming\");\n return join(appData, \"Claude\", \"claude_desktop_config.json\");\n }\n if (process.platform === \"darwin\") {\n return join(\n homedir(),\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\",\n );\n }\n return join(homedir(), \".config\", \"Claude\", \"claude_desktop_config.json\");\n}\n\nfunction redact(token: string): string {\n if (token.length <= 8) return \"****\";\n return `${token.slice(0, 4)}…${token.slice(-4)}`;\n}\n\nprogram.parseAsync(process.argv).catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`${pc.red(\"Error:\")} ${message}\\n`);\n process.exit(1);\n});\n","import { readFile } from \"node:fs/promises\";\nimport { basename, extname } from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport type { Account, Currency } from \"./types.js\";\nimport { getMethod } from \"./catalog.js\";\nimport { TelegramAdsError } from \"../errors.js\";\nimport { VERSION } from \"../version.js\";\n\nexport const DEFAULT_BASE_URL = \"https://promoteapi.telegram.org\";\nconst RETRYABLE_STATUS = new Set([408, 425, 429, 500, 502, 503, 504]);\n\nexport type Params = Record<string, unknown>;\n\nexport interface TelegramAdsClientOptions {\n token: string;\n baseUrl?: string;\n timeoutMs?: number;\n maxRetries?: number;\n maxConcurrent?: number;\n fetch?: typeof globalThis.fetch;\n userAgent?: string;\n}\n\nexport interface CallOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport interface WriteResult<T> {\n data: T;\n idempotencyKey: string;\n attempts: number;\n}\n\nexport interface UploadFile {\n path: string;\n contentType?: string;\n}\n\ninterface RawResponse<T> {\n data: T;\n attempts: number;\n}\n\nclass Semaphore {\n private active = 0;\n private readonly queue: Array<() => void> = [];\n\n constructor(private readonly limit: number) {}\n\n async run<T>(fn: () => Promise<T>): Promise<T> {\n if (this.active >= this.limit) {\n await new Promise<void>((resolve) => this.queue.push(resolve));\n } else {\n this.active += 1;\n }\n\n try {\n return await fn();\n } finally {\n const next = this.queue.shift();\n if (next) next();\n else this.active -= 1;\n }\n }\n}\n\nconst MIME_BY_EXTENSION: Record<string, string> = {\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".png\": \"image/png\",\n \".mp4\": \"video/mp4\",\n};\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseRetryAfter(header: string | null): number | undefined {\n if (!header) return undefined;\n const seconds = Number(header);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000);\n const date = Date.parse(header);\n if (Number.isFinite(date)) return Math.max(0, date - Date.now());\n return undefined;\n}\n\nfunction backoff(attempt: number): number {\n const ceiling = Math.min(500 * 2 ** attempt, 8_000);\n return Math.round(ceiling * (0.5 + Math.random() * 0.5));\n}\n\nconst sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));\n\n/**\n * Thin, dependency-free client for https://promoteapi.telegram.org.\n *\n * Responsibilities kept deliberately small: authentication, JSON/multipart\n * encoding, retries with jitter, idempotency keys and error normalisation.\n */\nexport class TelegramAdsClient {\n private readonly token: string;\n private readonly baseUrl: string;\n private readonly timeoutMs: number;\n private readonly maxRetries: number;\n private readonly fetchImpl: typeof globalThis.fetch;\n private readonly userAgent: string;\n private readonly semaphore: Semaphore;\n private readonly accountCache = new Map<string, { account: Account; expires: number }>();\n\n constructor(options: TelegramAdsClientOptions) {\n if (!options.token) throw new Error(\"A Telegram Ads access token is required.\");\n this.token = options.token;\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeoutMs = options.timeoutMs ?? 30_000;\n this.maxRetries = options.maxRetries ?? 2;\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n this.userAgent = options.userAgent ?? `telegram-ads-mcp/${VERSION}`;\n this.semaphore = new Semaphore(options.maxConcurrent ?? 4);\n }\n\n /** Read-only call. Write methods are rejected so callers cannot bypass policy by accident. */\n async call<T>(method: string, params: Params = {}, options: CallOptions = {}): Promise<T> {\n if (getMethod(method)?.write) {\n throw new Error(`${method} changes state. Use write() so an idempotency key is attached.`);\n }\n const response = await this.request<T>(method, params, options);\n return response.data;\n }\n\n /** Write call. Always carries an idempotency key, including across retries. */\n async write<T>(\n method: string,\n params: Params = {},\n options: CallOptions = {},\n ): Promise<WriteResult<T>> {\n const idempotencyKey = options.idempotencyKey ?? randomUUID();\n const response = await this.request<T>(method, params, { ...options, idempotencyKey });\n return { data: response.data, idempotencyKey, attempts: response.attempts };\n }\n\n /** Multipart upload for uploadAdPhoto, uploadAdVideo and uploadWebsitePhoto. */\n async upload<T>(\n method: string,\n params: Params,\n file: UploadFile,\n options: CallOptions = {},\n ): Promise<WriteResult<T>> {\n const idempotencyKey = options.idempotencyKey ?? randomUUID();\n const buffer = await readFile(file.path);\n const contentType =\n file.contentType ??\n MIME_BY_EXTENSION[extname(file.path).toLowerCase()] ??\n \"application/octet-stream\";\n\n const form = new FormData();\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n form.append(key, typeof value === \"object\" ? JSON.stringify(value) : String(value));\n }\n form.append(\"file\", new Blob([buffer], { type: contentType }), basename(file.path));\n\n const response = await this.request<T>(method, form, { ...options, idempotencyKey }, true);\n return { data: response.data, idempotencyKey, attempts: response.attempts };\n }\n\n async getCurrentAccount(): Promise<Account> {\n return this.resolveAccount();\n }\n\n async resolveAccount(accountId?: string): Promise<Account> {\n const key = accountId ?? \"__current__\";\n const cached = this.accountCache.get(key);\n if (cached && cached.expires > Date.now()) return cached.account;\n\n const account = accountId\n ? await this.call<Account[]>(\"getAccountsById\", { account_ids: [accountId] }).then(\n (accounts) => {\n const first = accounts[0];\n if (!first) {\n throw new TelegramAdsError({\n code: \"ACCOUNT_NOT_FOUND\",\n message: `Account ${accountId} was not returned by the API.`,\n });\n }\n return first;\n },\n )\n : await this.call<Account>(\"getCurrentAccount\");\n\n this.accountCache.set(key, { account, expires: Date.now() + 60_000 });\n return account;\n }\n\n async resolveCurrency(accountId?: string): Promise<Currency> {\n return (await this.resolveAccount(accountId)).currency;\n }\n\n clearCache(): void {\n this.accountCache.clear();\n }\n\n private async request<T>(\n method: string,\n params: Params | FormData,\n options: CallOptions,\n multipart = false,\n ): Promise<RawResponse<T>> {\n const url = `${this.baseUrl}/${method}`;\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.token}`,\n Accept: \"application/json\",\n \"User-Agent\": this.userAgent,\n };\n if (!multipart) headers[\"Content-Type\"] = \"application/json\";\n if (options.idempotencyKey) headers[\"Idempotency-Key\"] = options.idempotencyKey;\n\n const body = multipart ? (params as FormData) : JSON.stringify(params);\n\n let lastError: unknown;\n for (let attempt = 0; attempt <= this.maxRetries; attempt += 1) {\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, this.timeoutMs);\n const onAbort = () => controller.abort();\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n try {\n const response = await this.semaphore.run(() =>\n this.fetchImpl(url, { method: \"POST\", headers, body, signal: controller.signal }),\n );\n\n if (RETRYABLE_STATUS.has(response.status) && attempt < this.maxRetries) {\n const retryAfter = parseRetryAfter(response.headers.get(\"retry-after\"));\n await response.body?.cancel().catch(() => undefined);\n await sleep(retryAfter ?? backoff(attempt));\n continue;\n }\n\n const payload = await this.parseBody(response);\n if (!response.ok) {\n throw this.toError(method, response.status, payload);\n }\n if (isRecord(payload) && payload.ok === false) {\n throw this.toError(method, response.status, payload);\n }\n const data =\n isRecord(payload) && \"result\" in payload ? (payload.result as T) : (payload as T);\n return { data, attempts: attempt + 1 };\n } catch (error) {\n if (error instanceof TelegramAdsError) throw error;\n\n const aborted = error instanceof Error && error.name === \"AbortError\";\n if (timedOut) {\n lastError = new TelegramAdsError({\n code: \"REQUEST_TIMEOUT\",\n message: `Request to ${method} timed out after ${this.timeoutMs} ms.`,\n method,\n retryable: true,\n });\n } else if (aborted) {\n throw new TelegramAdsError({\n code: \"REQUEST_ABORTED\",\n message: `Request to ${method} was aborted.`,\n method,\n retryable: false,\n });\n } else {\n lastError = new TelegramAdsError({\n code: \"NETWORK_ERROR\",\n message:\n error instanceof Error ? error.message : `Network error while calling ${method}.`,\n method,\n retryable: true,\n details: error,\n });\n }\n\n if (attempt < this.maxRetries) {\n await sleep(backoff(attempt));\n continue;\n }\n throw lastError;\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n\n throw lastError instanceof Error\n ? lastError\n : new TelegramAdsError({ code: \"UNKNOWN\", message: `Request to ${method} failed.`, method });\n }\n\n private async parseBody(response: Response): Promise<unknown> {\n const text = await response.text();\n if (!text) return {};\n try {\n return JSON.parse(text);\n } catch {\n return { ok: false, error: `HTTP_${response.status}`, description: text.slice(0, 500) };\n }\n }\n\n private toError(method: string, status: number, payload: unknown): TelegramAdsError {\n const record = isRecord(payload) ? payload : {};\n const rawCode = record.error ?? record.error_code;\n const code =\n typeof rawCode === \"string\" ? rawCode : status === 401 ? \"UNAUTHORIZED\" : `HTTP_${status}`;\n const description =\n typeof record.description === \"string\"\n ? record.description\n : typeof record.message === \"string\"\n ? record.message\n : undefined;\n\n return new TelegramAdsError({\n code,\n message: description ? `${code}: ${description}` : code,\n httpStatus: status,\n method,\n retryable: RETRYABLE_STATUS.has(status),\n details: record,\n });\n }\n}\n","// Generated by scripts/sync-catalog.mjs from https://ads.telegram.org/docs/api\n// Do not edit by hand. Re-run the script to refresh.\nimport type { ApiMethod } from \"./types.js\";\n\nexport const API_METHODS: readonly ApiMethod[] = [\n {\n \"id\": \"createaccount\",\n \"name\": \"createAccount\",\n \"description\": \"Use this method to create a new account. This method can only be called from the main advertiser's account. An account created in this way can only be managed through the main account from which it was created. On success, returns an AccountInfo object.\",\n \"returns\": \"AccountInfo\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Title of the account is being created, 1-128 characters.\"\n },\n {\n \"name\": \"full_name\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Full company name for which the account is being created, 1-256 characters.\"\n },\n {\n \"name\": \"email\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Company email for which the account is being created, 1-64 characters.\"\n },\n {\n \"name\": \"phone_number\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Phone number of the company for which the account is being created.\"\n },\n {\n \"name\": \"country\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Company's country for which the account is being created, 1-128 characters.\"\n },\n {\n \"name\": \"city\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Company's city for which the account is being created, 1-128 characters.\"\n },\n {\n \"name\": \"legal_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Advertiser's legal name for which the account is being created, 0-256 characters. Additional information that can be viewed by users.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editaccountinfo\",\n \"name\": \"editAccountInfo\",\n \"description\": \"Use this method to edit the info of the account. On success, returns an AccountInfo object.\",\n \"returns\": \"AccountInfo\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit info. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New title of the account, 1-128 characters.\"\n },\n {\n \"name\": \"full_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New full company name of the account, 1-256 characters.\"\n },\n {\n \"name\": \"email\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New company email of the account, 1-64 characters.\"\n },\n {\n \"name\": \"phone_number\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New phone number of the company of the account.\"\n },\n {\n \"name\": \"country\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New company's country of the account, 1-128 characters.\"\n },\n {\n \"name\": \"city\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New company's city of the account, 1-128 characters.\"\n },\n {\n \"name\": \"legal_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New advertiser's legal name of the account, 0-256 characters.\"\n }\n ]\n },\n {\n \"id\": \"getaccountinfo\",\n \"name\": \"getAccountInfo\",\n \"description\": \"Use this method to get the info of the account. On success, returns an AccountInfo object.\",\n \"returns\": \"AccountInfo\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get info. If not specified, the current account will be used.\"\n }\n ]\n },\n {\n \"id\": \"getrelatedaccountslist\",\n \"name\": \"getRelatedAccountsList\",\n \"description\": \"Use this method to get a list of related accounts. Budgets of related accounts can be replenished using the budget of the main account. On success, returns a RelatedAccountsList object.\",\n \"returns\": \"RelatedAccountsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the related accounts list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of the related accounts to be retrieved. By default, all related accounts are returned.\"\n }\n ]\n },\n {\n \"id\": \"increaseaccountbudget\",\n \"name\": \"increaseAccountBudget\",\n \"description\": \"Use this method to increase the budget of a related account. The current account budget must have enough funds. On success, returns a TransactionStatus object.\",\n \"returns\": \"TransactionStatus\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the account to increase budget.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be added to the account budget from the current account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"decreaseaccountbudget\",\n \"name\": \"decreaseAccountBudget\",\n \"description\": \"Use this method to decrease the budget of a related account. The target account budget must have enough funds. On success, returns a TransactionStatus object.\",\n \"returns\": \"TransactionStatus\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the account to decrease budget.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be withdrawn from the account budget to the current account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"gettransactionstatus\",\n \"name\": \"getTransactionStatus\",\n \"description\": \"Use this method to get the status of transaction. On success, returns a TransactionStatus object.\",\n \"returns\": \"TransactionStatus\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"transaction_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the transaction to get status.\"\n }\n ]\n },\n {\n \"id\": \"getcurrentaccount\",\n \"name\": \"getCurrentAccount\",\n \"description\": \"Use this method to get the current account. Requires no parameters. On success, returns an Account object.\",\n \"returns\": \"Account\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"getaccountsbyid\",\n \"name\": \"getAccountsById\",\n \"description\": \"Use this method to get accounts by their identifiers. On success, an array of Account objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_ids\",\n \"type\": \"Array of String\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of account identifiers.\"\n }\n ]\n },\n {\n \"id\": \"getaccounttransactionslist\",\n \"name\": \"getAccountTransactionsList\",\n \"description\": \"Use this method to get a list of transactions related to an account. On success, returns an AccountTransactionsList object.\",\n \"returns\": \"AccountTransactionsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account whose transaction list will be returned. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the transaction list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of transactions to be retrieved. Defaults to 100.\"\n }\n ]\n },\n {\n \"id\": \"getaccountstats\",\n \"name\": \"getAccountStats\",\n \"description\": \"Use this method to get statistics related to the account. On success, returns an array of AdStatItem objects.\",\n \"returns\": \"Array<AdStatItem>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get statistics. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"from_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Start of the period, in Unix time. It will be rounded to the start of the interval. The start point is included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"to_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"End of the period, in Unix time. It will be rounded to the start of the interval. The end point is not included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"interval\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Interval in seconds, can be either 300 (5 min) or 86400 (1 day).\"\n }\n ]\n },\n {\n \"id\": \"getaccountreport\",\n \"name\": \"getAccountReport\",\n \"description\": \"Use this method to get a report of the active advertisements for the account. On success, returns an array of AccountReportItem objects.\",\n \"returns\": \"Array<AccountReportItem>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get a report. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"year\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Year of the report, 2021-2100.\"\n },\n {\n \"name\": \"month\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Month of the report, 1-12.\"\n }\n ]\n },\n {\n \"id\": \"uploadadphoto\",\n \"name\": \"uploadAdPhoto\",\n \"description\": \"Use this method to upload a photo to be displayed in the advertisement. On success, returns an AdPhoto object.\",\n \"returns\": \"AdPhoto\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to upload the photo. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"InputFile\",\n \"required\": true,\n \"description\": \"Photo to upload. The photo should be in JPEG or PNG format, up to 5 MB in size, and at least 640 pixels in width with a 16:9 aspect ratio.\"\n }\n ]\n },\n {\n \"id\": \"uploadadvideo\",\n \"name\": \"uploadAdVideo\",\n \"description\": \"Use this method to upload a video to be displayed in the advertisement. On success, returns an AdVideo object.\",\n \"returns\": \"AdVideo\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to upload the video. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"InputFile\",\n \"required\": true,\n \"description\": \"Video to upload. The video should be in MP4 format, up to 20 MB in size, at least 640 pixels in width with a 16:9 aspect ratio, and with a duration between 3 and 60 seconds.\"\n }\n ]\n },\n {\n \"id\": \"uploadwebsitephoto\",\n \"name\": \"uploadWebsitePhoto\",\n \"description\": \"Use this method to upload a photo of the website you want to promote. On success, returns an WebsitePhoto object.\",\n \"returns\": \"WebsitePhoto\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to upload a photo of the website. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"InputFile\",\n \"required\": true,\n \"description\": \"Photo to upload. The photo should be in JPEG or PNG format, up to 1 MB in size, and at least 150x150 pixels in dimensions.\"\n }\n ]\n },\n {\n \"id\": \"createad\",\n \"name\": \"createAd\",\n \"description\": \"Use this method to create a new advertisement. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create an ad. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New ad title, 1-128 bytes. Only displayed in the Telegram Ads interface.\"\n },\n {\n \"name\": \"text\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Text of the advertisement, 1-160 characters. This is what your target audience will see. Required for all targeting types except search .\"\n },\n {\n \"name\": \"photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo to be displayed in the advertisement. To upload a photo, use the uploadAdPhoto method. On average, ads with a photo require a 50-80% higher CPM to be displayed. Applicable for targeting types channels or users only. Only one of photo_id or video_id can be used.\"\n },\n {\n \"name\": \"video_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded video to be displayed in the advertisement. To upload a video, use the uploadAdVideo method. On average, ads with a video require a 70-100% higher CPM to be displayed. Applicable for targeting types channels or users only. Only one of video_id or photo_id can be used.\"\n },\n {\n \"name\": \"promote_url\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"A valid URL of the channel, post, bot or website you want to promote, 1-256 characters. The button below the ad will open this link.\"\n },\n {\n \"name\": \"cpm\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"The price per 1000 impressions in the account's currency. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). The minimum value depends on the account's currency and other advertisement parameters.\"\n },\n {\n \"name\": \"placement\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Placement of the advertisement. Must be one of “channel_post”, “bot_banner”, “search_result” or “video_banner”. This field determines where the ad will be shown. While currently optional for backward compatibility – if not specified, the value will be inferred from target.type – it is strongly recommended to always provide this field explicitly , as missing placement may lead to errors in future versions.\"\n },\n {\n \"name\": \"target\",\n \"type\": \"InputAdTarget\",\n \"required\": true,\n \"description\": \"Target settings.\"\n },\n {\n \"name\": \"impression_frequency\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Frequency of ad impressions to a single user per day, 1-4. Defaults to 1.\"\n },\n {\n \"name\": \"website_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Name of the website you want to promote, 1-40 characters. Required if the URL you want to promote is an external link.\"\n },\n {\n \"name\": \"website_photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo of the website you want to promote. To upload a photo, use the uploadWebsitePhoto method.\"\n },\n {\n \"name\": \"button\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Type of the button to be displayed in the advertisement. Applicable only if the URL you want to promote is an external link. Can be either “subscribe”, “view”, “read”, “learn_more”, “download”, “open”, “sign_up”, “buy”, “order”, “play”, “try” or “leave_request”. If empty, the default button labeled “Open Website” will be displayed.\"\n },\n {\n \"name\": \"conversion_event_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A pixel event used to track conversions. Applicable only if the URL you want to promote is an external link.\"\n },\n {\n \"name\": \"additional_info\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Additional information that can be viewed by users, 0-64 characters. This information can be viewed by users only if the legal_name field is filled in the AccountInfo .\"\n },\n {\n \"name\": \"show_userpic\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement should contain a picture of the promoted channel or bot. On average, ads with a picture require a 30% higher CPM to be displayed.\"\n },\n {\n \"name\": \"initial_budget\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"Amount in the account's currency that will be added to the ad budget from the account budget. The account budget must have enough funds. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). Defaults to 0.\"\n },\n {\n \"name\": \"daily_budget_limit\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"Amount limit in the account's currency that can be spent daily. If 0, the limit is not applied. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). Defaults to 0.\"\n },\n {\n \"name\": \"is_paused\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement should remain on hold after creation. Ignored if activate_date or deactivate_date are passed.\"\n },\n {\n \"name\": \"activate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be activated. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to True if the value is in the future, otherwise, is_paused will be set to False .\"\n },\n {\n \"name\": \"deactivate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be paused. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to False if the value is in the future and activate_date is not set, otherwise, is_paused will be set to True .\"\n },\n {\n \"name\": \"schedule\",\n \"type\": \"InputAdSchedule\",\n \"required\": false,\n \"description\": \"Schedule for displaying the advertisement by hours.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editad\",\n \"name\": \"editAd\",\n \"description\": \"Use this method to edit an existing advertisement. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit an ad. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad to edit.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New ad title, 1-128 bytes. Only displayed in the ad interface.\"\n },\n {\n \"name\": \"text\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Text of the advertisement, 1-160 characters. This is what your target audience will see.\"\n },\n {\n \"name\": \"photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo to be displayed in the advertisement. To upload a photo, use the uploadAdPhoto method. On average, ads with a photo require a 50-80% higher CPM to be displayed. Applicable for targeting types channels or users only. If passed, any previously set photo or video will be removed. Only one of photo_id or video_id can be used.\"\n },\n {\n \"name\": \"video_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded video to be displayed in the advertisement. To upload a video, use the uploadAdVideo method. On average, ads with a video require a 70-100% higher CPM to be displayed. Applicable for targeting types channels or users only. If passed, any previously set photo or video will be removed. Only one of video_id or photo_id can be used.\"\n },\n {\n \"name\": \"promote_url\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A valid URL of the channel, post, bot or website you want to promote, 1-256 characters. The button below the ad will open this link.\"\n },\n {\n \"name\": \"cpm\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"The price per 1000 impressions in the account's currency. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ). The minimum value depends on the account's currency and other advertisement parameters.\"\n },\n {\n \"name\": \"impression_frequency\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Frequency of ad impressions to a single user per day, 1-4. Defaults to 1.\"\n },\n {\n \"name\": \"website_name\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Name of the website you want to promote, 1-40 characters.\"\n },\n {\n \"name\": \"website_photo_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the uploaded photo of the website you want to promote. To upload a photo, use the uploadWebsitePhoto method.\"\n },\n {\n \"name\": \"button\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Type of the button to be displayed in the advertisement. Applicable only if the URL you want to promote is an external link. Can be either “subscribe”, “view”, “read”, “learn_more”, “download”, “open”, “sign_up”, “buy”, “order”, “play”, “try” or “leave_request”. If empty, the default button labeled “Open Website” will be displayed.\"\n },\n {\n \"name\": \"conversion_event_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A pixel event used to track conversions. Applicable only if the URL you want to promote is an external link. Can't be changed if already set.\"\n },\n {\n \"name\": \"additional_info\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Additional information that can be viewed by users, 0-64 characters. This information can be viewed by users only if the legal_name field is filled in the AccountInfo . Can't be changed if already set.\"\n },\n {\n \"name\": \"show_userpic\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement should contain a picture of the promoted channel or bot. On average, ads with a picture require a 30% higher CPM to be displayed.\"\n },\n {\n \"name\": \"daily_budget_limit\",\n \"type\": \"Float\",\n \"required\": false,\n \"description\": \"Amount limit in the account's currency that can be spent daily. If 0, the limit is not applied. The value will be rounded to the cpm & budget precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"is_paused\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if the advertisement needs to be paused. Pass False if the paused advertisement needs to be resumed. If passed, previously set activate_date and deactivate_date will be reset. Ignored if activate_date or deactivate_date are passed.\"\n },\n {\n \"name\": \"activate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be activated. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to True if the value is in the future, otherwise, is_paused will be set to False .\"\n },\n {\n \"name\": \"deactivate_date\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Date in Unix time when the advertisement will be paused. It will be rounded to the start of a minute. The date should be later than the current time but not more than 365 days from the current time. If passed, is_paused will be set to False if the value is in the future and activate_date is not set, otherwise, is_paused will be set to True .\"\n },\n {\n \"name\": \"schedule\",\n \"type\": \"InputAdSchedule\",\n \"required\": false,\n \"description\": \"Schedule for displaying the advertisement by hours.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n }\n ]\n },\n {\n \"id\": \"editadstatus\",\n \"name\": \"editAdStatus\",\n \"description\": \"Deprecated. Use method editAd with parameter is_paused instead.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": true,\n \"params\": []\n },\n {\n \"id\": \"increaseadbudget\",\n \"name\": \"increaseAdBudget\",\n \"description\": \"Use this method to increase the budget of an advertisement. The account budget must have enough funds. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to increase an ad budget. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the advertisement to increase budget.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be added to the ad budget from the account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"decreaseadbudget\",\n \"name\": \"decreaseAdBudget\",\n \"description\": \"Use this method to decrease the budget of an advertisement. The ad budget must have enough funds. To decrease the budget of an ad, it must be inactive for at least 10 minutes. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to decrease an ad budget. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the advertisement whose budget should be decreased.\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"Float\",\n \"required\": true,\n \"description\": \"Amount in the account's currency that will be withdrawn from the ad budget to the account budget. The value will be rounded to the amount precision of the account's currency (see Currencies ).\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"submitadforreview\",\n \"name\": \"submitAdForReview\",\n \"description\": \"Use this method to submit an advertisement for review. Can only be used for ads with the “ready_for_review” status. Ads are submitted for review automatically when they are created or edited, provided the ad's budget is not empty. If an ad has the “ready_for_review” status, it will not be submitted for review automatically and must be submitted using this method. On success, returns an Ad object.\",\n \"returns\": \"Ad\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to submit an ad for review. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad to submit for review.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad object.\"\n }\n ]\n },\n {\n \"id\": \"deletead\",\n \"name\": \"deleteAd\",\n \"description\": \"Use this method to delete an existing advertisement. To delete an ad, it must be inactive for at least 10 minutes. Returns True on success.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to delete an ad. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the advertisement to delete.\"\n }\n ]\n },\n {\n \"id\": \"getadsbyid\",\n \"name\": \"getAdsById\",\n \"description\": \"Use this method to get advertisements by their identifiers. On success, an array of Ad objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get ads. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_ids\",\n \"type\": \"Array of Integer\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of unique ad identifiers.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad objects.\"\n }\n ]\n },\n {\n \"id\": \"getadslist\",\n \"name\": \"getAdsList\",\n \"description\": \"Use this method to get a list of advertisements for the current account. On success, returns an AdList object.\",\n \"returns\": \"AdList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get ads list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Offset of the ads list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of ads to be retrieved. Values between 0-100 are accepted. Defaults to 100.\"\n },\n {\n \"name\": \"return_target\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to retrieve target settings in the returned Ad objects.\"\n }\n ]\n },\n {\n \"id\": \"getadtransactionslist\",\n \"name\": \"getAdTransactionsList\",\n \"description\": \"Use this method to get a list of transactions for an advertisement. On success, returns an AdTransactionsList object.\",\n \"returns\": \"AdTransactionsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get an ad transactions list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad whose transaction list will be returned.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the transaction list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of the transactions to be retrieved. Defaults to 100.\"\n }\n ]\n },\n {\n \"id\": \"getadstats\",\n \"name\": \"getAdStats\",\n \"description\": \"Use this method to get statistics for an advertisement. On success, returns an array of AdStatItem objects.\",\n \"returns\": \"Array<AdStatItem>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get an ad stats. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"ad_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the ad to get statistics.\"\n },\n {\n \"name\": \"from_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Start of the period, in Unix time. It will be rounded to the start of the interval. The start point is included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"to_time\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"End of the period, in Unix time. It will be rounded to the start of the interval. The end point is not included in the result. The period should not be longer than 1000*interval.\"\n },\n {\n \"name\": \"interval\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Interval in seconds, can be either 300 (5 min) or 86400 (1 day).\"\n }\n ]\n },\n {\n \"id\": \"createaudience\",\n \"name\": \"createAudience\",\n \"description\": \"Use this method to create a new audience. On success, returns an Audience object.\",\n \"returns\": \"Audience\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create an audience. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New audience title, 1-64 characters. Only displayed in the Telegram Ads interface.\"\n },\n {\n \"name\": \"add_phones\",\n \"type\": \"Array of String\",\n \"required\": false,\n \"description\": \"List of 0-10000 phone numbers or their SHA256 hashes.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editaudience\",\n \"name\": \"editAudience\",\n \"description\": \"Use this method to edit an existing audience. If the fields add_phones and remove_phones or reset_phones are passed simultaneously, the deletions will be performed first, followed by the addition of new ones. On success, returns an Audience object.\",\n \"returns\": \"Audience\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit an audience. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"audience_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the audience to edit.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"New audience title, 1-64 bytes. If not provided, the title will not be changed.\"\n },\n {\n \"name\": \"add_phones\",\n \"type\": \"Array of String\",\n \"required\": false,\n \"description\": \"List of 0-10000 phone numbers or their SHA256 hashes to include in the audience.\"\n },\n {\n \"name\": \"remove_phones\",\n \"type\": \"Array of String\",\n \"required\": false,\n \"description\": \"List of 0-10000 phone numbers or their SHA256 hashes to remove from the audience. Will be ignored if reset_phones is passed.\"\n },\n {\n \"name\": \"reset_phones\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True to reset all phone numbers from the audience.\"\n }\n ]\n },\n {\n \"id\": \"deleteaudience\",\n \"name\": \"deleteAudience\",\n \"description\": \"Use this method to delete an existing audience. You can only delete an audience that is not currently used in any advertisements. Returns True on success.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to delele an audience. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"audience_id\",\n \"type\": \"Integer\",\n \"required\": true,\n \"description\": \"Unique identifier of the audience to delete.\"\n }\n ]\n },\n {\n \"id\": \"getaudiencesbyid\",\n \"name\": \"getAudiencesById\",\n \"description\": \"Use this method to get audiences by their identifiers. On success, an array of Audience objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get audiences. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"audience_ids\",\n \"type\": \"Array of Integer\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of audience identifiers.\"\n }\n ]\n },\n {\n \"id\": \"getaudienceslist\",\n \"name\": \"getAudiencesList\",\n \"description\": \"Use this method to get the list of audiences. On success, returns an AudiencesList object.\",\n \"returns\": \"AudiencesList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get audiences list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the audiences list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of audiences to be retrieved. By default, all audiences are returned.\"\n }\n ]\n },\n {\n \"id\": \"createpixel\",\n \"name\": \"createPixel\",\n \"description\": \"Use this method to create a Pixel Tag. On success, returns a Pixel object.\",\n \"returns\": \"Pixel\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create a pixel. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"getpixel\",\n \"name\": \"getPixel\",\n \"description\": \"Use this method to get a Pixel Tag related to the account. On success, returns a Pixel object.\",\n \"returns\": \"Pixel\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get a pixel. If not specified, the current account will be used.\"\n }\n ]\n },\n {\n \"id\": \"createpixelevent\",\n \"name\": \"createPixelEvent\",\n \"description\": \"Use this method to create a new pixel event. On success, returns a PixelEvent object.\",\n \"returns\": \"PixelEvent\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to create an event. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New event title, 1-64 characters. Only displayed in the Telegram Ads interface.\"\n },\n {\n \"name\": \"type\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Type of the event that most closely matches the action you want to track. Can be either “page_view”, “add_to_cart”, “add_to_wishlist”, “customize_product”, “initiate_checkout”, “add_payment_info”, “purchase”, “contact”, “lead”, “schedule”, “complete_registration”, “submit_application”, “start_trial”, “subscribe”, “view_content”, “search”, “find_location”, “donate”, “custom”.\"\n },\n {\n \"name\": \"idempotency_key\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"A unique key to perform an idempotent request, 0-128 characters. You can also pass this key in the HTTP header Idempotency-Key: <key> instead.\"\n }\n ]\n },\n {\n \"id\": \"editpixelevent\",\n \"name\": \"editPixelEvent\",\n \"description\": \"Use this method to edit an existing pixel event. You can't edit a pixel event that was automatically created. On success, returns a PixelEvent object.\",\n \"returns\": \"PixelEvent\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to edit the pixel event. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"event_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the pixel event to edit.\"\n },\n {\n \"name\": \"title\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"New event title, 1-64 bytes.\"\n }\n ]\n },\n {\n \"id\": \"deletepixelevent\",\n \"name\": \"deletePixelEvent\",\n \"description\": \"Use this method to delete an existing pixel event. You can only delete a pixel event that is not currently used in any advertisements and was not automatically created. Returns True on success.\",\n \"returns\": \"unknown\",\n \"write\": true,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to delete the pixel event. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"event_id\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Unique identifier of the pixel event to delete.\"\n }\n ]\n },\n {\n \"id\": \"getpixeleventsbyid\",\n \"name\": \"getPixelEventsById\",\n \"description\": \"Use this method to get pixel events by their identifiers. On success, an array of PixelEvent objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get pixel events. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"event_ids\",\n \"type\": \"Array of String\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of pixel event identifiers.\"\n }\n ]\n },\n {\n \"id\": \"getpixeleventslist\",\n \"name\": \"getPixelEventsList\",\n \"description\": \"Use this method to get a list of pixel events. On success, returns a PixelEventsList object.\",\n \"returns\": \"PixelEventsList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"account_id\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Unique identifier of the account to get pixel events list. If not specified, the current account will be used.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Offset of the list of pixel events to return.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of pixel events to be retrieved. By default, all pixel events are returned.\"\n }\n ]\n },\n {\n \"id\": \"gettargetlanguageslist\",\n \"name\": \"getTargetLanguagesList\",\n \"description\": \"Use this method to get the list of available target languages. Requires no parameters. On success, returns an array of TargetLanguage objects.\",\n \"returns\": \"Array<TargetLanguage>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"gettargettopicslist\",\n \"name\": \"getTargetTopicsList\",\n \"description\": \"Use this method to get the list of available target topics. Requires no parameters. On success, returns an array of TargetTopic objects.\",\n \"returns\": \"Array<TargetTopic>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"gettargetcountrieslist\",\n \"name\": \"getTargetCountriesList\",\n \"description\": \"Use this method to get the list of available target countries. Requires no parameters. On success, returns an array of TargetCountry objects.\",\n \"returns\": \"Array<TargetCountry>\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": []\n },\n {\n \"id\": \"gettargetlocationsbyid\",\n \"name\": \"getTargetLocationsById\",\n \"description\": \"Use this method to get locations by their identifiers. On success, an array of TargetLocation objects is returned.\",\n \"returns\": \"unknown\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"location_ids\",\n \"type\": \"Array of Integer\",\n \"required\": true,\n \"description\": \"A JSON-serialized list of unique location identifiers.\"\n }\n ]\n },\n {\n \"id\": \"gettargetlocationslist\",\n \"name\": \"getTargetLocationsList\",\n \"description\": \"Use this method to get target locations. On success, returns a TargetLocationList object.\",\n \"returns\": \"TargetLocationList\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"country_code\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Two-letter ISO 3166-1 alpha-2 country code.\"\n },\n {\n \"name\": \"query\",\n \"type\": \"String\",\n \"required\": true,\n \"description\": \"Text of the query.\"\n },\n {\n \"name\": \"offset\",\n \"type\": \"String\",\n \"required\": false,\n \"description\": \"Offset of the locations list to be returned.\"\n },\n {\n \"name\": \"limit\",\n \"type\": \"Integer\",\n \"required\": false,\n \"description\": \"Limits the number of locations to be retrieved. Defaults to 100.\"\n }\n ]\n },\n {\n \"id\": \"gettargetchannel\",\n \"name\": \"getTargetChannel\",\n \"description\": \"Use this method to get target channel. On success, returns a TargetChannel object.\",\n \"returns\": \"TargetChannel\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"channel_id\",\n \"type\": \"Integer or String\",\n \"required\": true,\n \"description\": \"Unique identifier for the target channel or username of the target channel (in the format @channelusername ). Numeric identifiers can only be used if they were previously resolved by this account via username (see Resolving channels and bots ).\"\n },\n {\n \"name\": \"for_excluding\",\n \"type\": \"Boolean\",\n \"required\": false,\n \"description\": \"Pass True if you want to exclude the channel.\"\n }\n ]\n },\n {\n \"id\": \"gettargetbot\",\n \"name\": \"getTargetBot\",\n \"description\": \"Use this method to get target bot. On success, returns a TargetBot object.\",\n \"returns\": \"TargetBot\",\n \"write\": false,\n \"deprecated\": false,\n \"params\": [\n {\n \"name\": \"bot_id\",\n \"type\": \"Integer or String\",\n \"required\": true,\n \"description\": \"Unique identifier for the target bot or username of the target bot (in the format @usernamebot ). Numeric identifiers can only be used if they were previously resolved by this account via username (see Resolving channels and bots ).\"\n }\n ]\n }\n];\n\nexport const METHOD_NAMES: readonly string[] = API_METHODS.map((method) => method.name);\n\nconst BY_NAME = new Map(API_METHODS.map((method) => [method.name, method]));\n\nexport function getMethod(name: string): ApiMethod | undefined {\n return BY_NAME.get(name);\n}\n\nexport function isWriteMethod(name: string): boolean {\n return BY_NAME.get(name)?.write ?? false;\n}\n","/** Error types surfaced by the server. */\n\nexport class TelegramAdsError extends Error {\n readonly code: string;\n readonly httpStatus: number | undefined;\n readonly method: string | undefined;\n readonly retryable: boolean;\n readonly details: unknown;\n\n constructor(options: {\n message: string;\n code: string;\n httpStatus?: number;\n method?: string;\n retryable?: boolean;\n details?: unknown;\n }) {\n super(options.message);\n this.name = \"TelegramAdsError\";\n this.code = options.code;\n this.httpStatus = options.httpStatus;\n this.method = options.method;\n this.retryable = options.retryable ?? false;\n this.details = options.details;\n }\n}\n\nexport class ConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n\nexport class PolicyError extends Error {\n readonly code: string;\n\n constructor(code: string, message: string) {\n super(message);\n this.name = \"PolicyError\";\n this.code = code;\n }\n}\n\n/** Human-readable hint appended to tool errors for common failure modes. */\nexport function hintFor(error: unknown): string | undefined {\n if (error instanceof PolicyError) return undefined;\n if (!(error instanceof TelegramAdsError)) return undefined;\n\n if (error.code === \"UNAUTHORIZED\" || error.httpStatus === 401) {\n return \"The access token was rejected. Create a new token at https://ads.telegram.org/account/api and update TELEGRAM_ADS_TOKEN.\";\n }\n if (error.code === \"CHANNEL_ID_UNKNOWN\") {\n return \"Pass the channel as @username so this account can resolve it first, then retry with the numeric ID if needed.\";\n }\n if (error.code === \"BOT_ID_UNKNOWN\") {\n return \"Pass the bot as @username so this account can resolve it first, then retry with the numeric ID if needed.\";\n }\n if (error.code === \"MAIN_ACCOUNT_REQUIRED\") {\n return \"This method is only available to main (agency) accounts. Use a token from the main account.\";\n }\n if (error.code === \"IDEMPOTENT_PARAM_MISMATCH\") {\n return \"This idempotency key was already used with different parameters. Retry with a new key.\";\n }\n if (error.code === \"IDEMPOTENT_REQUEST_IN_PROGRESS\") {\n return \"An identical request is still in progress. Wait a moment, then retry with the same key.\";\n }\n if (error.httpStatus === 429) {\n return \"Telegram Ads is rate limiting this account. Wait before retrying.\";\n }\n return undefined;\n}\n","import { readFileSync } from \"node:fs\";\n\nconst pkg = JSON.parse(readFileSync(new URL(\"../package.json\", import.meta.url), \"utf8\")) as {\n version: string;\n};\n\nexport const VERSION = pkg.version;\nexport const SERVER_NAME = \"telegram-ads-mcp\";\n","import { z } from \"zod\";\nimport { ConfigError } from \"./errors.js\";\nimport { DEFAULT_BASE_URL } from \"./api/client.js\";\n\nconst optionalNumber = z.preprocess(\n (value) => (value === undefined || value === \"\" ? undefined : Number(value)),\n z.number().finite().nonnegative().optional(),\n);\n\nconst optionalString = z.preprocess(\n (value) => (typeof value === \"string\" && value.trim() === \"\" ? undefined : value),\n z.string().optional(),\n);\n\nconst schema = z.object({\n token: z.string().min(1, \"TELEGRAM_ADS_TOKEN is required.\"),\n mode: z.enum([\"read-only\", \"write\"]).default(\"read-only\"),\n codeMode: z.enum([\"off\", \"read-only\", \"write\"]).default(\"read-only\"),\n allowedAccounts: z.array(z.string()).default([]),\n maxCpm: optionalNumber,\n maxAdBudget: optionalNumber,\n maxDailyBudget: optionalNumber,\n auditLog: optionalString,\n timeoutMs: z.number().int().positive().default(30_000),\n baseUrl: z.string().url().default(DEFAULT_BASE_URL),\n});\n\nexport type Config = z.infer<typeof schema>;\n\nexport interface LoadConfigOptions {\n /** Allow commands such as `init` and `--help` to run without a token. */\n requireToken?: boolean;\n}\n\nexport function loadConfig(\n env: NodeJS.ProcessEnv = process.env,\n options: LoadConfigOptions = {},\n): Config {\n const raw = {\n token:\n env.TELEGRAM_ADS_TOKEN ?? env.TG_ADS_TOKEN ?? (options.requireToken === false ? \"-\" : \"\"),\n mode: env.TG_ADS_MODE,\n codeMode: env.TG_ADS_CODE_MODE,\n allowedAccounts: (env.TG_ADS_ALLOWED_ACCOUNTS ?? \"\")\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean),\n maxCpm: env.TG_ADS_MAX_CPM,\n maxAdBudget: env.TG_ADS_MAX_AD_BUDGET,\n maxDailyBudget: env.TG_ADS_MAX_DAILY_BUDGET,\n auditLog: env.TG_ADS_AUDIT_LOG,\n timeoutMs: env.TG_ADS_TIMEOUT_MS ? Number(env.TG_ADS_TIMEOUT_MS) : 30_000,\n baseUrl: env.TG_ADS_BASE_URL ?? DEFAULT_BASE_URL,\n };\n\n const parsed = schema.safeParse(raw);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`);\n throw new ConfigError(`Invalid configuration:\\n- ${issues.join(\"\\n- \")}`);\n }\n return parsed.data;\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { TelegramAdsClient } from \"./api/client.js\";\nimport { AuditLogger } from \"./audit.js\";\nimport type { Config } from \"./config.js\";\nimport { Policy } from \"./policy.js\";\nimport { registerPrompts } from \"./prompts.js\";\nimport { registerResources } from \"./resources.js\";\nimport { registerTools } from \"./tools/index.js\";\nimport { SERVER_NAME, VERSION } from \"./version.js\";\n\nexport interface CreateServerOptions {\n config: Config;\n client?: TelegramAdsClient;\n audit?: AuditLogger;\n}\n\nexport function createServer(options: CreateServerOptions): McpServer {\n const { config } = options;\n const client =\n options.client ??\n new TelegramAdsClient({\n token: config.token,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n\n const context = {\n client,\n config,\n policy: new Policy(config),\n audit: options.audit ?? new AuditLogger(config.auditLog),\n };\n\n const server = new McpServer(\n { name: SERVER_NAME, version: VERSION },\n { capabilities: { tools: {}, resources: {}, prompts: {} } },\n );\n\n registerTools(server, context);\n registerResources(server);\n registerPrompts(server);\n\n return server;\n}\n","import { appendFile, mkdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nexport interface AuditEvent {\n ts: string;\n tool: string;\n outcome: \"ok\" | \"error\";\n duration_ms: number;\n account_id?: string;\n method?: string;\n idempotency_key?: string;\n error?: string;\n params?: unknown;\n}\n\nconst SENSITIVE_KEYS = new Set([\n \"add_phones\",\n \"remove_phones\",\n \"phone_number\",\n \"email\",\n \"legal_name\",\n]);\n\n/** Keeps PII and long payloads out of the audit log. */\nexport function summarizeParams(params: unknown): unknown {\n if (!params || typeof params !== \"object\") return params;\n if (Array.isArray(params)) return params.map(summarizeParams);\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(params)) {\n if (SENSITIVE_KEYS.has(key)) {\n result[key] = { count: Array.isArray(value) ? value.length : 1 };\n } else if (key === \"text\" && typeof value === \"string\") {\n result[key] = { length: value.length };\n } else if (key === \"code\" && typeof value === \"string\") {\n result[key] = { length: value.length };\n } else if (typeof value === \"string\" && value.length > 200) {\n result[key] = `${value.slice(0, 200)}…`;\n } else if (typeof value === \"object\" && value !== null) {\n result[key] = summarizeParams(value);\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\n/**\n * Optional JSONL audit trail. Disabled unless TG_ADS_AUDIT_LOG is set.\n * Writes are serialised so concurrent tool calls cannot interleave lines.\n */\nexport class AuditLogger {\n private queue: Promise<void> = Promise.resolve();\n\n constructor(private readonly path?: string) {}\n\n get enabled(): boolean {\n return Boolean(this.path);\n }\n\n record(event: Omit<AuditEvent, \"ts\">): void {\n if (!this.path) return;\n const line = `${JSON.stringify({ ts: new Date().toISOString(), ...event })}\\n`;\n this.queue = this.queue\n .then(async () => {\n await mkdir(dirname(this.path as string), { recursive: true });\n await appendFile(this.path as string, line, \"utf8\");\n })\n .catch((error: unknown) => {\n process.stderr.write(\n `[telegram-ads-mcp] audit log write failed: ${\n error instanceof Error ? error.message : String(error)\n }\\n`,\n );\n });\n }\n\n async flush(): Promise<void> {\n await this.queue;\n }\n}\n","import type { Currency } from \"./api/types.js\";\n\n/**\n * Currency precision rules from the Telegram Ads documentation.\n * CPM and budget values use `budget` decimals; account amounts use `amount`.\n */\nconst PRECISION: Record<Currency, { budget: number; amount: number }> = {\n EUR: { budget: 2, amount: 5 },\n TON: { budget: 2, amount: 5 },\n XTR: { budget: 0, amount: 3 },\n};\n\nexport type MoneyKind = \"budget\" | \"amount\";\n\nexport function precisionFor(currency: Currency, kind: MoneyKind): number {\n return PRECISION[currency][kind];\n}\n\nexport function decimalPlaces(value: number): number {\n if (!Number.isFinite(value)) return Number.POSITIVE_INFINITY;\n const text = value.toString();\n if (!text.includes(\"e\")) {\n const dot = text.indexOf(\".\");\n return dot === -1 ? 0 : text.length - dot - 1;\n }\n // Normalise exponential notation (e.g. 1e-7) before counting decimals.\n const normalised = value.toFixed(12).replace(/0+$/, \"\").replace(/\\.$/, \"\");\n const dot = normalised.indexOf(\".\");\n return dot === -1 ? 0 : normalised.length - dot - 1;\n}\n\nexport function assertMoney(\n value: number,\n currency: Currency,\n kind: MoneyKind,\n field: string,\n): void {\n if (!Number.isFinite(value) || value < 0) {\n throw new Error(`${field} must be a non-negative number.`);\n }\n const allowed = precisionFor(currency, kind);\n const actual = decimalPlaces(value);\n if (actual > allowed) {\n throw new Error(\n `${field} has ${actual} decimal places, but ${currency} allows ${allowed} for ${kind} values. ` +\n `Round the value before sending it.`,\n );\n }\n}\n\nexport function roundMoney(value: number, currency: Currency, kind: MoneyKind): number {\n return Number(value.toFixed(precisionFor(currency, kind)));\n}\n\n/** Ratios used in summaries, rounded to keep tool output compact. */\nexport function ratio(numerator: number, denominator: number, scale = 1): number {\n if (!denominator) return 0;\n return Number(((numerator / denominator) * scale).toFixed(6));\n}\n","import type { Config } from \"./config.js\";\nimport type { Currency } from \"./api/types.js\";\nimport { PolicyError } from \"./errors.js\";\nimport { assertMoney } from \"./money.js\";\n\nconst WRITE_HINT =\n \"Write access is disabled. Set TG_ADS_MODE=write in the server environment and restart the server.\";\n\n/**\n * Central guard for anything that can spend money or change account state.\n * Every write tool must pass through here before touching the API.\n */\nexport class Policy {\n constructor(private readonly config: Config) {}\n\n get canWrite(): boolean {\n return this.config.mode === \"write\";\n }\n\n get codeModeEnabled(): boolean {\n return this.config.codeMode !== \"off\";\n }\n\n get codeModeCanWrite(): boolean {\n return this.config.codeMode === \"write\";\n }\n\n assertWrite(confirm: boolean | undefined): void {\n if (!this.canWrite) throw new PolicyError(\"WRITE_DISABLED\", WRITE_HINT);\n if (confirm !== true) {\n throw new PolicyError(\n \"CONFIRMATION_REQUIRED\",\n \"This operation changes the account. Re-run with confirm: true after verifying the parameters. \" +\n \"Use dry_run: true to validate without calling the API.\",\n );\n }\n }\n\n assertCodeModeWrite(confirm: boolean | undefined): void {\n if (!this.canWrite) throw new PolicyError(\"WRITE_DISABLED\", WRITE_HINT);\n if (!this.codeModeCanWrite) {\n throw new PolicyError(\n \"CODE_MODE_WRITE_DISABLED\",\n \"Code Mode can only read. Set TG_ADS_CODE_MODE=write to allow write methods inside tg_execute.\",\n );\n }\n if (confirm !== true) {\n throw new PolicyError(\n \"CONFIRMATION_REQUIRED\",\n \"Code Mode may change the account. Re-run tg_execute with confirm: true.\",\n );\n }\n }\n\n assertAccount(accountId: string | undefined): void {\n if (!accountId || this.config.allowedAccounts.length === 0) return;\n if (!this.config.allowedAccounts.includes(accountId)) {\n throw new PolicyError(\n \"ACCOUNT_NOT_ALLOWED\",\n `Account ${accountId} is not in TG_ADS_ALLOWED_ACCOUNTS.`,\n );\n }\n }\n\n assertCpm(cpm: number, currency: Currency): void {\n assertMoney(cpm, currency, \"budget\", \"cpm\");\n if (this.config.maxCpm !== undefined && cpm > this.config.maxCpm) {\n throw new PolicyError(\n \"CPM_LIMIT_EXCEEDED\",\n `cpm ${cpm} exceeds TG_ADS_MAX_CPM (${this.config.maxCpm}).`,\n );\n }\n }\n\n assertAdBudget(amount: number, currency: Currency, field = \"initial_budget\"): void {\n assertMoney(amount, currency, \"budget\", field);\n if (this.config.maxAdBudget !== undefined && amount > this.config.maxAdBudget) {\n throw new PolicyError(\n \"BUDGET_LIMIT_EXCEEDED\",\n `${field} ${amount} exceeds TG_ADS_MAX_AD_BUDGET (${this.config.maxAdBudget}).`,\n );\n }\n }\n\n assertDailyBudget(amount: number, currency: Currency): void {\n assertMoney(amount, currency, \"budget\", \"daily_budget_limit\");\n if (this.config.maxDailyBudget !== undefined && amount > this.config.maxDailyBudget) {\n throw new PolicyError(\n \"DAILY_BUDGET_LIMIT_EXCEEDED\",\n `daily_budget_limit ${amount} exceeds TG_ADS_MAX_DAILY_BUDGET (${this.config.maxDailyBudget}).`,\n );\n }\n }\n\n assertAmount(amount: number, currency: Currency): void {\n assertMoney(amount, currency, \"amount\", \"amount\");\n if (this.config.maxAdBudget !== undefined && amount > this.config.maxAdBudget) {\n throw new PolicyError(\n \"BUDGET_LIMIT_EXCEEDED\",\n `amount ${amount} exceeds TG_ADS_MAX_AD_BUDGET (${this.config.maxAdBudget}).`,\n );\n }\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\n\nexport function registerPrompts(server: McpServer): void {\n server.registerPrompt(\n \"launch-ad\",\n {\n title: \"Launch a Telegram ad safely\",\n description:\n \"Walk through account discovery, targeting, paused ad creation, validation and funding.\",\n argsSchema: z.object({\n brief: z.string().min(1).describe(\"What to promote, the target audience and the budget.\"),\n }),\n },\n ({ brief }) => ({\n messages: [\n {\n role: \"user\",\n content: {\n type: \"text\",\n text:\n `Plan and launch a Telegram ad for this brief:\\n\\n${brief}\\n\\n` +\n `Follow this order strictly:\\n` +\n `1. Call tg_get_account to learn the account currency and available budget.\\n` +\n `2. Use tg_list_targeting to resolve languages, topics, countries, locations, channels or bots. ` +\n `Prefer @username for channels and bots.\\n` +\n `3. Call tg_create_ad with dry_run: true and is_paused: true. Show me the exact payload and cost implications.\\n` +\n `4. Ask for my approval before creating anything that spends money.\\n` +\n `5. Create the ad paused with a zero initial budget, then show me its ad_id.\\n` +\n `6. Only after I approve the budget, call tg_ad_budget and tg_update_ad to unpause it.\\n\\n` +\n `Never submit an ad for review without asking me. Never exceed the configured budget caps.`,\n },\n },\n ],\n }),\n );\n\n server.registerPrompt(\n \"audit-account\",\n {\n title: \"Audit account performance\",\n description: \"Read-only review of spend, delivery and underperforming ads.\",\n argsSchema: z.object({\n days: z.string().optional().describe(\"Lookback window in days, default 30.\"),\n }),\n },\n ({ days }) => ({\n messages: [\n {\n role: \"user\",\n content: {\n type: \"text\",\n text:\n `Audit my Telegram Ads account for the last ${days ?? \"30\"} days. Stay read-only.\\n\\n` +\n `1. tg_get_account for currency and remaining budget.\\n` +\n `2. tg_list_ads with include_targeting: false, paging through all active ads.\\n` +\n `3. tg_get_stats for those ads with include_series: true and interval 86400.\\n` +\n `4. Identify: zero-delivery ads, CTR outliers, CPM outliers, ads with spend but no clicks, ` +\n `and ads whose budget is nearly exhausted.\\n` +\n `5. Return a compact table plus a prioritized list of actions. Do not change anything.`,\n },\n },\n ],\n }),\n );\n\n server.registerPrompt(\n \"weekly-report\",\n {\n title: \"Weekly performance report\",\n description: \"Aggregate a week of stats into a compact report.\",\n argsSchema: z.object({\n week_offset: z.string().optional().describe(\"0 is the current week, 1 is last week.\"),\n }),\n },\n ({ week_offset }) => ({\n messages: [\n {\n role: \"user\",\n content: {\n type: \"text\",\n text:\n `Build a weekly Telegram Ads report for week offset ${week_offset ?? \"1\"} (0 = current week).\\n\\n` +\n `Use tg_execute for efficiency: fetch the active ads, pull daily stats for the week, then return ` +\n `per-ad spend, views, clicks, CTR, CPM and week-over-week change. Keep the returned object small ` +\n `and sorted by spend. Do not make any write calls.`,\n },\n },\n ],\n }),\n );\n}\n","import { API_METHODS } from \"../api/catalog.js\";\nimport type { ApiMethod } from \"../api/types.js\";\n\nconst PRIMITIVES: Record<string, string> = {\n String: \"string\",\n Integer: \"number\",\n Float: \"number\",\n Boolean: \"boolean\",\n \"Integer or String\": \"number | string\",\n InputFile: \"never\",\n};\n\nfunction tsType(docType: string): string {\n if (docType.startsWith(\"Array of \")) return `${tsType(docType.slice(\"Array of \".length))}[]`;\n return PRIMITIVES[docType] ?? \"Record<string, unknown>\";\n}\n\nfunction paramsType(method: ApiMethod): string {\n const fields = method.params\n .filter((param) => param.name !== \"idempotency_key\")\n .map((param) => ` ${param.name}${param.required ? \"\" : \"?\"}: ${tsType(param.type)};`);\n return fields.length === 0 ? \"{}\" : `{\\n${fields.join(\"\\n\")}\\n }`;\n}\n\n/** Compact one-line signature used by tg_search output. */\nexport function signature(method: ApiMethod): string {\n const params = method.params\n .filter((param) => param.name !== \"idempotency_key\")\n .map((param) => `${param.name}${param.required ? \"\" : \"?\"}: ${tsType(param.type)}`);\n return `${method.name}({ ${params.join(\"; \")} })`;\n}\n\n/** TypeScript declarations for the tg namespace inside tg_execute. */\nexport function buildSdkDts(): string {\n const declarations = API_METHODS.filter((method) => !method.deprecated)\n .map((method) => {\n const doc = method.description.replace(/\\*\\//g, \"*\\\\/\");\n return ` /**\\n * ${doc}\\n *\\n * Returns: ${method.returns}\\n */\\n ${method.name}(params${method.params.some((p) => p.required) ? \"\" : \"?\"}: ${paramsType(method)}): Promise<any>;`;\n })\n .join(\"\\n\\n\");\n\n return `/**\n * Type declarations for the \\`tg\\` object available inside tg_execute.\n *\n * Calls are executed sequentially. Write methods only work when the server runs\n * with TG_ADS_MODE=write and TG_ADS_CODE_MODE=write, and tg_execute is called\n * with confirm: true.\n *\n * @example\n * const ads = await tg.getAdsList({ limit: 100 });\n * const active = ads.ads.filter((ad) => ad.status === \"active\");\n * return active.map((ad) => ({ id: ad.ad_id, title: ad.title, spent: ad.spent_budget }));\n */\ndeclare const tg: {\n${declarations}\n};\n\ndeclare const console: {\n log(...args: unknown[]): void;\n warn(...args: unknown[]): void;\n error(...args: unknown[]): void;\n};\n`;\n}\n\nexport interface MethodMatch {\n name: string;\n description: string;\n write: boolean;\n returns: string;\n signature: string;\n}\n\nexport function searchMethods(query: string, limit: number, write?: boolean): MethodMatch[] {\n const needle = query.trim().toLowerCase();\n const scored: Array<{ score: number; method: ApiMethod }> = [];\n\n for (const method of API_METHODS) {\n if (method.deprecated) continue;\n if (write !== undefined && method.write !== write) continue;\n\n if (!needle) {\n scored.push({ score: 0, method });\n continue;\n }\n\n const name = method.name.toLowerCase();\n let score = 0;\n if (name === needle) score = 100;\n else if (name.includes(needle)) score = 60;\n else if (method.description.toLowerCase().includes(needle)) score = 30;\n else if (method.params.some((param) => param.name.includes(needle))) score = 15;\n\n if (score > 0) scored.push({ score, method });\n }\n\n return scored\n .sort((a, b) => b.score - a.score || a.method.name.localeCompare(b.method.name))\n .slice(0, limit)\n .map(({ method }) => ({\n name: method.name,\n description: method.description,\n write: method.write,\n returns: method.returns,\n signature: signature(method),\n }));\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { API_METHODS } from \"./api/catalog.js\";\nimport { buildSdkDts } from \"./code-mode/sdk.js\";\n\nconst GUIDE = `# Telegram Ads MCP\n\nThis server wraps the official Telegram Ads API (https://ads.telegram.org/docs/api).\nIt is unofficial and not affiliated with Telegram.\n\n## Safe workflow\n\n1. Read first: tg_get_account, tg_list_ads, tg_get_ads, tg_get_stats.\n2. Validate writes with dry_run: true when the tool supports it.\n3. Writes require TG_ADS_MODE=write and an explicit confirm: true.\n4. New ads default to paused with a zero budget. Fund them deliberately.\n5. Budget changes are real money. Check the account currency and precision first.\n\n## Currency precision\n\n- EUR and TON: CPM/budget 2 decimals, amounts 5 decimals.\n- XTR: CPM/budget 0 decimals, amounts 3 decimals.\n\n## Channels and bots\n\nPrefer @username. Numeric IDs only work after this account has resolved the\nsame channel or bot via its username.\n\n## Code Mode\n\ntg_execute runs JavaScript in QuickJS with a tg object. Use tg_get_sdk for the\nfull TypeScript surface, or tg_search to discover methods. Code Mode is\nread-only unless TG_ADS_MODE=write and TG_ADS_CODE_MODE=write are both set and\nthe call includes confirm: true.\n\n## Limits\n\n- Stats: interval 300 or 86400 seconds, at most 1000 intervals per request.\n- getAdsById/getAccountsById/getAudiencesById: up to 100 IDs.\n- Ad photo: JPEG/PNG, 5 MiB, at least 640px wide, 16:9.\n- Ad video: MP4, 20 MiB, 16:9, 3-60 seconds.\n- Website photo: JPEG/PNG, 1 MiB, at least 150x150.\n- No published rate limits. Calls are sequential and retried with backoff.\n`;\n\nexport function registerResources(server: McpServer): void {\n server.registerResource(\n \"method-catalog\",\n \"telegram-ads://method-catalog\",\n {\n title: \"Telegram Ads method catalog\",\n description:\n \"All 45 official methods with parameters, required flags, descriptions and return types.\",\n mimeType: \"application/json\",\n },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: \"application/json\",\n text: JSON.stringify(\n {\n source: \"https://ads.telegram.org/docs/api\",\n count: API_METHODS.length,\n methods: API_METHODS,\n },\n null,\n 2,\n ),\n },\n ],\n }),\n );\n\n server.registerResource(\n \"code-mode-sdk\",\n \"telegram-ads://sdk.d.ts\",\n {\n title: \"Code Mode TypeScript SDK\",\n description: \"Type declarations for the tg object available inside tg_execute.\",\n mimeType: \"text/plain\",\n },\n async (uri) => ({\n contents: [{ uri: uri.href, mimeType: \"text/plain\", text: buildSdkDts() }],\n }),\n );\n\n server.registerResource(\n \"guide\",\n \"telegram-ads://guide\",\n {\n title: \"Usage and safety guide\",\n description: \"Workflow, currency precision, limits and Code Mode rules.\",\n mimeType: \"text/markdown\",\n },\n async (uri) => ({\n contents: [{ uri: uri.href, mimeType: \"text/markdown\", text: GUIDE }],\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { RelatedAccountsList, TransactionStatus } from \"../api/types.js\";\nimport { TelegramAdsError } from \"../errors.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nexport function registerAccountTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_get_account\",\n {\n title: \"Get Telegram Ads account\",\n description:\n \"Get the current Telegram Ads account: account_id, title, currency, remaining budget and ad budget. \" +\n \"Set include_related to also list accounts whose budgets this account can replenish. \" +\n \"Start here to learn the account currency, which determines valid CPM and budget precision.\",\n inputSchema: z.object({\n include_related: z\n .boolean()\n .optional()\n .describe(\"Also list related accounts that this account can fund.\"),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_account\", async (input) => {\n const account = await ctx.client.getCurrentAccount();\n if (!input.include_related) return { account };\n\n try {\n const related = await ctx.client.call<RelatedAccountsList>(\n \"getRelatedAccountsList\",\n compact({ offset: input.offset, limit: input.limit }),\n );\n return { account, related };\n } catch (error) {\n if (error instanceof TelegramAdsError && error.code === \"MAIN_ACCOUNT_REQUIRED\") {\n return {\n account,\n related: null,\n note: \"Related accounts are only available to main (agency) accounts.\",\n };\n }\n throw error;\n }\n }),\n );\n\n server.registerTool(\n \"tg_get_account_info\",\n {\n title: \"Get account profile\",\n description:\n \"Get the billing/profile details of an account (company name, email, phone, country, city). \" +\n \"Omit account_id to read the current account.\",\n inputSchema: z.object({\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_account_info\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const info = await ctx.client.call(\n \"getAccountInfo\",\n compact({ account_id: input.account_id }),\n );\n return { account_info: info };\n }),\n );\n\n server.registerTool(\n \"tg_account_budget\",\n {\n title: \"Move budget between accounts\",\n description:\n \"Increase or decrease the budget of a related account from the current account. \" +\n \"amount uses the currency's amount precision (EUR/TON: 5 decimals, XTR: 3). \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n account_id: z.string().min(1).describe(\"Related account to fund or withdraw from.\"),\n direction: z.enum([\"increase\", \"decrease\"]),\n amount: z.number().positive(),\n confirm: z.boolean().optional(),\n idempotency_key: z.string().min(1).max(128).optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_account_budget\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const currency = await ctx.client.resolveCurrency(input.account_id);\n ctx.policy.assertAmount(input.amount, currency);\n ctx.policy.assertWrite(input.confirm);\n\n const method =\n input.direction === \"increase\" ? \"increaseAccountBudget\" : \"decreaseAccountBudget\";\n const result = await ctx.client.write<TransactionStatus>(\n method,\n { account_id: input.account_id, amount: input.amount },\n input.idempotency_key ? { idempotencyKey: input.idempotency_key } : {},\n );\n return { transaction: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n}\n","import type { CallToolResult } from \"@modelcontextprotocol/server\";\nimport type { AdStatItem } from \"../api/types.js\";\nimport type { AuditLogger } from \"../audit.js\";\nimport { summarizeParams } from \"../audit.js\";\nimport type { TelegramAdsClient } from \"../api/client.js\";\nimport type { Config } from \"../config.js\";\nimport type { Policy } from \"../policy.js\";\nimport { hintFor, PolicyError, TelegramAdsError } from \"../errors.js\";\nimport { ratio } from \"../money.js\";\n\nexport interface ToolContext {\n client: TelegramAdsClient;\n config: Config;\n policy: Policy;\n audit: AuditLogger;\n}\n\nexport function ok(data: unknown): CallToolResult {\n return {\n content: [{ type: \"text\", text: JSON.stringify(data, null, 2) }],\n };\n}\n\nexport function fail(error: unknown): CallToolResult {\n const code =\n error instanceof TelegramAdsError || error instanceof PolicyError ? error.code : \"ERROR\";\n const message = error instanceof Error ? error.message : String(error);\n const hint = hintFor(error);\n const text = `Error [${code}]: ${message}${hint ? `\\n\\nHint: ${hint}` : \"\"}`;\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/**\n * Wraps a tool body with error normalisation and audit logging.\n * Tool implementations stay focused on their actual job.\n */\nexport function toolHandler<Input>(\n ctx: ToolContext,\n tool: string,\n fn: (input: Input) => Promise<unknown>,\n): (input: Input) => Promise<CallToolResult> {\n return async (input: Input): Promise<CallToolResult> => {\n const started = Date.now();\n const record = (input ?? {}) as Record<string, unknown>;\n const accountId = typeof record.account_id === \"string\" ? record.account_id : undefined;\n const method = typeof record.method === \"string\" ? record.method : undefined;\n\n try {\n const data = await fn(input);\n const idempotencyKey =\n data && typeof data === \"object\" && \"idempotency_key\" in data\n ? (data as { idempotency_key?: unknown }).idempotency_key\n : undefined;\n ctx.audit.record({\n tool,\n outcome: \"ok\",\n duration_ms: Date.now() - started,\n ...(accountId ? { account_id: accountId } : {}),\n ...(method ? { method } : {}),\n ...(typeof idempotencyKey === \"string\" ? { idempotency_key: idempotencyKey } : {}),\n params: summarizeParams(input),\n });\n return ok(data);\n } catch (error) {\n const code =\n error instanceof TelegramAdsError || error instanceof PolicyError ? error.code : \"ERROR\";\n ctx.audit.record({\n tool,\n outcome: \"error\",\n duration_ms: Date.now() - started,\n ...(accountId ? { account_id: accountId } : {}),\n ...(method ? { method } : {}),\n error: code,\n params: summarizeParams(input),\n });\n return fail(error);\n }\n };\n}\n\n/** Drops undefined/null so optional fields are not sent to the API. */\nexport function compact(input: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input)) {\n if (value !== undefined && value !== null) result[key] = value;\n }\n return result;\n}\n\nexport function toUnixSeconds(value: string | number, field: string): number {\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new Error(`${field} must be a finite number.`);\n const seconds = value > 1e12 ? Math.floor(value / 1000) : Math.floor(value);\n return seconds;\n }\n\n const trimmed = value.trim();\n if (/^\\d+$/.test(trimmed)) return toUnixSeconds(Number(trimmed), field);\n\n const parsed = Date.parse(trimmed);\n if (!Number.isFinite(parsed)) {\n throw new Error(`${field} must be Unix seconds, milliseconds, or an ISO 8601 date.`);\n }\n return Math.floor(parsed / 1000);\n}\n\nexport interface TimeRange {\n from: number;\n to: number;\n}\n\nexport function parseRange(from: string | number, to: string | number): TimeRange {\n const start = toUnixSeconds(from, \"from\");\n const end = toUnixSeconds(to, \"to\");\n if (start >= end) throw new Error(\"from must be earlier than to.\");\n return { from: start, to: end };\n}\n\n/**\n * Telegram accepts at most 1000 intervals per stats request.\n * Split larger ranges into contiguous windows so callers can ask for a year.\n */\nexport function planWindows(range: TimeRange, interval: number): TimeRange[] {\n const maxIntervals = 1000;\n const span = interval * maxIntervals;\n if (range.to - range.from <= span) return [range];\n\n const windows: TimeRange[] = [];\n for (let start = range.from; start < range.to; start += span) {\n windows.push({ from: start, to: Math.min(start + span, range.to) });\n }\n return windows;\n}\n\nexport interface StatsSummary {\n views: number;\n opens: number;\n clicks: number;\n actions: number;\n spent_budget: number;\n ctr: number;\n cpm: number;\n cpc: number;\n}\n\nexport function summarizeStats(items: AdStatItem[]): StatsSummary {\n let views = 0;\n let opens = 0;\n let clicks = 0;\n let actions = 0;\n let spent = 0;\n\n for (const item of items) {\n views += item.views ?? 0;\n opens += item.opens ?? 0;\n clicks += item.clicks ?? 0;\n actions += item.actions ?? 0;\n spent += item.spent_budget ?? 0;\n }\n\n return {\n views,\n opens,\n clicks,\n actions,\n spent_budget: Number(spent.toFixed(6)),\n ctr: ratio(clicks, views),\n cpm: ratio(spent, views, 1000),\n cpc: ratio(spent, clicks),\n };\n}\n","import { stat } from \"node:fs/promises\";\nimport { extname, resolve } from \"node:path\";\nimport type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { Ad, AdList } from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\nimport { assertTargetLimits, targetSchema } from \"./schemas.js\";\n\nconst placement = z.enum([\"channel_post\", \"bot_banner\", \"search_result\", \"video_banner\"]);\nconst button = z.enum([\n \"subscribe\",\n \"view\",\n \"read\",\n \"learn_more\",\n \"download\",\n \"open\",\n \"sign_up\",\n \"buy\",\n \"order\",\n \"play\",\n \"try\",\n \"leave_request\",\n]);\n\nconst schedule = z.object({\n week_hours_mask: z\n .array(z.number().int().min(0).max(16_777_215))\n .length(7)\n .describe(\n \"Exactly 7 bitmasks, Monday first. Bit 0 is 00:00-01:00, bit 23 is 23:00-00:00. All zeros means no schedule.\",\n ),\n timezone: z\n .number()\n .int()\n .min(-43_200)\n .max(50_400)\n .multipleOf(900)\n .optional()\n .describe(\"Offset in seconds from UTC. Required unless use_viewer_timezone is true.\"),\n use_viewer_timezone: z\n .boolean()\n .optional()\n .describe(\"Apply the schedule in the viewer's timezone. Users targeting only.\"),\n});\n\nconst money = z.number().nonnegative();\n\nconst httpUrl = z\n .string()\n .url()\n .max(256)\n .refine((value) => /^https?:\\/\\//i.test(value), \"Use an http:// or https:// URL.\");\n\nexport function registerAdTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_ads\",\n {\n title: \"List ads\",\n description:\n \"List advertisements for an account, newest first, with status, budgets and lifetime metrics. \" +\n \"Use next_offset from the response to fetch the next page. \" +\n \"Set include_targeting to receive targeting settings (larger response).\",\n inputSchema: z.object({\n account_id: z.string().optional(),\n offset: z.string().optional().describe(\"Pagination cursor from a previous response.\"),\n limit: z.number().int().min(1).max(100).optional(),\n include_targeting: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_ads\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const result = await ctx.client.call<AdList>(\n \"getAdsList\",\n compact({\n account_id: input.account_id,\n offset: input.offset,\n limit: input.limit,\n return_target: input.include_targeting,\n }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_get_ads\",\n {\n title: \"Get ads by ID\",\n description:\n \"Fetch up to 100 advertisements by ad_id, including status, budgets, metrics and decline reasons.\",\n inputSchema: z.object({\n ad_ids: z.array(z.number().int().positive()).min(1).max(100),\n account_id: z.string().optional(),\n include_targeting: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_ads\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const ads = await ctx.client.call<Ad[]>(\n \"getAdsById\",\n compact({\n account_id: input.account_id,\n ad_ids: input.ad_ids,\n return_target: input.include_targeting,\n }),\n );\n return { ads };\n }),\n );\n\n server.registerTool(\n \"tg_create_ad\",\n {\n title: \"Create ad\",\n description:\n \"Create one advertisement. New ads are paused with a zero budget unless you pass is_paused: false \" +\n \"and initial_budget. Money values must match the account currency precision (EUR/TON: 2 decimals, \" +\n \"XTR: 0). Telegram requires text unless target.type is search, and at most one of photo_id/video_id. \" +\n \"Use dry_run: true to validate without calling the API. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n title: z.string().min(1).max(128),\n text: z.string().min(1).max(160).optional(),\n promote_url: httpUrl,\n cpm: z.number().positive().describe(\"Price per 1000 impressions in the account currency.\"),\n placement,\n target: targetSchema,\n photo_id: z.string().min(1).optional(),\n video_id: z.string().min(1).optional(),\n website_name: z.string().min(1).max(40).optional(),\n website_photo_id: z.string().optional(),\n button: button.optional(),\n conversion_event_id: z.string().optional(),\n additional_info: z.string().optional(),\n show_userpic: z.boolean().optional(),\n impression_frequency: z.number().int().min(1).max(4).optional(),\n initial_budget: money.optional().describe(\"Defaults to 0, which keeps the ad unfunded.\"),\n daily_budget_limit: money.optional().describe(\"0 disables the daily limit.\"),\n activate_date: z.number().int().positive().optional().describe(\"Unix seconds.\"),\n deactivate_date: z.number().int().positive().optional().describe(\"Unix seconds.\"),\n schedule: schedule.optional(),\n is_paused: z.boolean().optional().describe(\"Defaults to true.\"),\n account_id: z.string().optional(),\n dry_run: z.boolean().optional(),\n confirm: z.boolean().optional(),\n idempotency_key: z.string().min(1).max(128).optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_create_ad\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n assertTargetLimits(input.target);\n if (input.photo_id && input.video_id) {\n throw new Error(\"Only one of photo_id or video_id may be provided.\");\n }\n if (\n (input.photo_id || input.video_id) &&\n ![\"channels\", \"users\"].includes(input.target.type)\n ) {\n throw new Error(\n \"photo_id and video_id are only supported for channels or users targeting.\",\n );\n }\n if (!input.text && input.target.type !== \"search\") {\n throw new Error(\"text is required unless target.type is search.\");\n }\n\n const currency = await ctx.client.resolveCurrency(input.account_id);\n ctx.policy.assertCpm(input.cpm, currency);\n\n const initialBudget = input.initial_budget ?? 0;\n if (initialBudget > 0) ctx.policy.assertAdBudget(initialBudget, currency);\n if (input.daily_budget_limit !== undefined && input.daily_budget_limit > 0) {\n ctx.policy.assertDailyBudget(input.daily_budget_limit, currency);\n }\n\n const params = compact({\n account_id: input.account_id,\n title: input.title,\n text: input.text,\n promote_url: input.promote_url,\n cpm: input.cpm,\n placement: input.placement,\n target: input.target,\n photo_id: input.photo_id,\n video_id: input.video_id,\n website_name: input.website_name,\n website_photo_id: input.website_photo_id,\n button: input.button,\n conversion_event_id: input.conversion_event_id,\n additional_info: input.additional_info,\n show_userpic: input.show_userpic,\n impression_frequency: input.impression_frequency,\n initial_budget: initialBudget,\n daily_budget_limit: input.daily_budget_limit,\n activate_date: input.activate_date,\n deactivate_date: input.deactivate_date,\n schedule: input.schedule,\n is_paused: input.is_paused ?? true,\n });\n\n if (input.dry_run) {\n return { dry_run: true, currency, request: params };\n }\n\n ctx.policy.assertWrite(input.confirm);\n const result = await ctx.client.write<Ad>(\"createAd\", params, {\n ...(input.idempotency_key ? { idempotencyKey: input.idempotency_key } : {}),\n });\n return { ad: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n\n server.registerTool(\n \"tg_update_ad\",\n {\n title: \"Update ad\",\n description:\n \"Edit an existing advertisement. Only provided fields change. Use is_paused to pause or resume. \" +\n \"Set submit_for_review: true to move a ready_for_review ad into review after editing. \" +\n \"Changing cpm or budget requires the same currency precision rules as creation. \" +\n \"Use dry_run: true to validate without calling the API. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n ad_id: z.number().int().positive(),\n title: z.string().min(1).max(128).optional(),\n text: z.string().min(1).max(160).optional(),\n promote_url: httpUrl.optional(),\n cpm: z.number().positive().optional(),\n photo_id: z.string().min(1).optional(),\n video_id: z.string().min(1).optional(),\n website_name: z.string().min(1).max(40).optional(),\n website_photo_id: z.string().optional(),\n button: button.optional(),\n conversion_event_id: z.string().optional(),\n additional_info: z.string().optional(),\n show_userpic: z.boolean().optional(),\n impression_frequency: z.number().int().min(1).max(4).optional(),\n daily_budget_limit: money.optional(),\n is_paused: z.boolean().optional(),\n activate_date: z.number().int().positive().optional(),\n deactivate_date: z.number().int().positive().optional(),\n schedule: schedule.optional(),\n submit_for_review: z.boolean().optional(),\n include_targeting: z.boolean().optional(),\n account_id: z.string().optional(),\n dry_run: z.boolean().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_update_ad\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n const {\n ad_id,\n submit_for_review,\n include_targeting,\n dry_run,\n confirm,\n account_id,\n ...fields\n } = input;\n const provided = Object.entries(fields).filter(([, value]) => value !== undefined);\n if (provided.length === 0 && !submit_for_review) {\n throw new Error(\"Provide at least one field to update, or set submit_for_review: true.\");\n }\n if (fields.photo_id && fields.video_id) {\n throw new Error(\"Only one of photo_id or video_id may be provided.\");\n }\n\n const currency = await ctx.client.resolveCurrency(account_id);\n if (fields.cpm !== undefined) ctx.policy.assertCpm(fields.cpm, currency);\n if (fields.daily_budget_limit !== undefined && fields.daily_budget_limit > 0) {\n ctx.policy.assertDailyBudget(fields.daily_budget_limit, currency);\n }\n\n const params = compact({\n account_id,\n ad_id,\n ...fields,\n return_target: include_targeting,\n });\n\n if (dry_run) {\n return {\n dry_run: true,\n currency,\n request: params,\n submit_for_review: submit_for_review ?? false,\n };\n }\n\n ctx.policy.assertWrite(confirm);\n const response: Record<string, unknown> = {};\n\n if (provided.length > 0) {\n const result = await ctx.client.write<Ad>(\"editAd\", params);\n response.ad = result.data;\n response.idempotency_key = result.idempotencyKey;\n }\n\n if (submit_for_review) {\n const review = await ctx.client.write<Ad>(\n \"submitAdForReview\",\n compact({ account_id, ad_id }),\n );\n response.submitted = review.data;\n response.submit_idempotency_key = review.idempotencyKey;\n }\n\n return response;\n }),\n );\n\n server.registerTool(\n \"tg_ad_budget\",\n {\n title: \"Increase or decrease ad budget\",\n description:\n \"Move funds into or out of an ad. amount is in the account currency and must respect its precision. \" +\n \"Telegram only allows decreasing budget when the ad has been inactive for at least 10 minutes. \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n ad_id: z.number().int().positive(),\n direction: z.enum([\"increase\", \"decrease\"]),\n amount: z.number().positive(),\n include_targeting: z.boolean().optional(),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_ad_budget\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const currency = await ctx.client.resolveCurrency(input.account_id);\n ctx.policy.assertAmount(input.amount, currency);\n ctx.policy.assertWrite(input.confirm);\n\n const method = input.direction === \"increase\" ? \"increaseAdBudget\" : \"decreaseAdBudget\";\n const result = await ctx.client.write<Ad>(\n method,\n compact({\n account_id: input.account_id,\n ad_id: input.ad_id,\n amount: input.amount,\n return_target: input.include_targeting,\n }),\n );\n return { ad: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n\n server.registerTool(\n \"tg_delete_ad\",\n {\n title: \"Delete ad\",\n description:\n \"Permanently delete an advertisement. Telegram requires the ad to be inactive for at least 10 minutes \" +\n \"and to have no remaining budget. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n ad_id: z.number().int().positive(),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_delete_ad\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n ctx.policy.assertWrite(input.confirm);\n await ctx.client.write(\n \"deleteAd\",\n compact({ account_id: input.account_id, ad_id: input.ad_id }),\n );\n return { deleted: true, ad_id: input.ad_id };\n }),\n );\n\n const uploadLimits = {\n ad_photo: {\n method: \"uploadAdPhoto\",\n maxBytes: 5 * 1024 * 1024,\n extensions: [\".jpg\", \".jpeg\", \".png\"],\n },\n ad_video: { method: \"uploadAdVideo\", maxBytes: 20 * 1024 * 1024, extensions: [\".mp4\"] },\n website_photo: {\n method: \"uploadWebsitePhoto\",\n maxBytes: 1 * 1024 * 1024,\n extensions: [\".jpg\", \".jpeg\", \".png\"],\n },\n } as const;\n\n server.registerTool(\n \"tg_upload_media\",\n {\n title: \"Upload ad media\",\n description:\n \"Upload a local file to Telegram Ads and return its media ID. Limits: ad_photo JPEG/PNG up to 5 MiB \" +\n \"and at least 640px wide; ad_video MP4 up to 20 MiB, 16:9, 3-60 seconds; website_photo JPEG/PNG up to \" +\n \"1 MiB and at least 150x150. Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n kind: z.enum([\"ad_photo\", \"ad_video\", \"website_photo\"]),\n path: z\n .string()\n .min(1)\n .describe(\"Absolute path, or a path relative to the server process.\"),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_upload_media\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const limits = uploadLimits[input.kind];\n const filePath = resolve(input.path);\n const info = await stat(filePath);\n if (!info.isFile()) throw new Error(`${filePath} is not a file.`);\n\n const extension = extname(filePath).toLowerCase();\n if (!(limits.extensions as readonly string[]).includes(extension)) {\n throw new Error(\n `${input.kind} must be one of ${limits.extensions.join(\", \")}; received ${extension || \"no extension\"}.`,\n );\n }\n if (info.size > limits.maxBytes) {\n throw new Error(\n `${filePath} is ${info.size} bytes, above the ${limits.maxBytes} byte limit for ${input.kind}.`,\n );\n }\n\n ctx.policy.assertWrite(input.confirm);\n const result = await ctx.client.upload<Record<string, string>>(\n limits.method,\n compact({ account_id: input.account_id }),\n { path: filePath },\n );\n return { kind: input.kind, ...result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n}\n","import { z } from \"zod\";\n\nexport const idOrUsername = z.union([z.string().min(1), z.number().int().positive()]);\n\nconst languages = z.array(z.string().min(2).max(16)).max(8);\nconst topicIds = z.array(z.number().int().positive()).max(20);\nconst channelIds = z.array(idOrUsername).max(100);\nconst audienceIds = z.array(z.number().int().positive()).max(10);\n\nexport const targetSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"channels\"),\n language_codes: languages\n .optional()\n .describe(\"Channel languages (up to 8 IETF tags). Must be empty when channel_ids is used.\"),\n topic_ids: topicIds\n .optional()\n .describe(\"Channel topics (up to 20). Must be empty when channel_ids is used.\"),\n exclude_topic_ids: topicIds.optional(),\n channel_ids: channelIds\n .optional()\n .describe(\"Channels to include, as @username or numeric ID resolved by this account.\"),\n exclude_channel_ids: channelIds.optional(),\n }),\n z.object({\n type: z.literal(\"users\"),\n country_codes: z\n .array(z.string().length(2))\n .max(8)\n .describe(\n \"ISO 3166-1 alpha-2 country codes (up to 8). Exactly one when location_ids is used.\",\n ),\n location_ids: z.array(z.number().int().positive()).max(20).optional(),\n language_codes: languages.optional(),\n topic_ids: topicIds.optional(),\n intersect_topics: z.boolean().optional(),\n exclude_topic_ids: topicIds.optional(),\n channel_ids: channelIds.optional(),\n exclude_channel_ids: channelIds.optional(),\n audience_ids: audienceIds.optional(),\n exclude_audience_ids: audienceIds.optional(),\n device: z.enum([\"ios\", \"android\", \"mobile\", \"desktop\"]).optional(),\n exclude_political_channels: z.boolean().optional(),\n political_channels_only: z.boolean().optional(),\n }),\n z.object({\n type: z.literal(\"bots\"),\n bot_ids: z.array(idOrUsername).max(100).describe(\"Bots to target, as @username or numeric ID.\"),\n }),\n z.object({\n type: z.literal(\"search\"),\n search_queries: z.array(z.string().min(1).max(64)).min(1).max(10),\n }),\n]);\n\nexport type Target = z.infer<typeof targetSchema>;\n\n/**\n * Telegram limits included and excluded values together, so per-field array\n * limits are not enough. Catching this here produces a clearer error than the\n * API response.\n */\nexport function assertTargetLimits(target: Target): void {\n if (target.type === \"channels\") {\n if (target.channel_ids?.length && (target.topic_ids?.length || target.language_codes?.length)) {\n throw new Error(\"channel_ids cannot be combined with topic_ids or language_codes.\");\n }\n assertCombined(target.topic_ids, target.exclude_topic_ids, 20, \"topics\");\n assertCombined(target.channel_ids, target.exclude_channel_ids, 100, \"channels\");\n }\n\n if (target.type === \"users\") {\n assertCombined(target.topic_ids, target.exclude_topic_ids, 20, \"topics\");\n assertCombined(target.channel_ids, target.exclude_channel_ids, 100, \"channels\");\n assertCombined(target.audience_ids, target.exclude_audience_ids, 10, \"audiences\");\n if (target.location_ids?.length && target.country_codes.length !== 1) {\n throw new Error(\"country_codes must contain exactly one country when location_ids is used.\");\n }\n }\n}\n\nfunction assertCombined(\n included: unknown[] | undefined,\n excluded: unknown[] | undefined,\n limit: number,\n label: string,\n): void {\n const total = (included?.length ?? 0) + (excluded?.length ?? 0);\n if (total > limit) {\n throw new Error(\n `Included and excluded ${label} may contain at most ${limit} entries combined.`,\n );\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { Audience, AudiencesList } from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nconst phone = z\n .string()\n .refine(\n (value) => /^\\+?[0-9]{7,15}$/.test(value) || /^[a-f0-9]{64}$/i.test(value),\n \"Use a phone number (7-15 digits, optional +) or a 64-character SHA256 hash.\",\n );\n\nexport function registerAudienceTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_audiences\",\n {\n title: \"List audiences\",\n description:\n \"List retargeting audiences for an account, or fetch specific audiences by ID. \" +\n \"Audience sizes are in phone numbers.\",\n inputSchema: z.object({\n audience_ids: z.array(z.number().int().positive()).max(100).optional(),\n account_id: z.string().optional(),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_audiences\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n if (input.audience_ids && input.audience_ids.length > 0) {\n const audiences = await ctx.client.call<Audience[]>(\n \"getAudiencesById\",\n compact({ account_id: input.account_id, audience_ids: input.audience_ids }),\n );\n return { audiences };\n }\n\n const result = await ctx.client.call<AudiencesList>(\n \"getAudiencesList\",\n compact({ account_id: input.account_id, offset: input.offset, limit: input.limit }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_manage_audience\",\n {\n title: \"Create, update or delete an audience\",\n description:\n \"Manage phone-number retargeting audiences. action=create needs title and add_phones; \" +\n \"action=update needs audience_id plus at least one change; action=delete needs audience_id. \" +\n \"Phone numbers are sent to Telegram and are never written to the audit log. \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n action: z.enum([\"create\", \"update\", \"delete\"]),\n audience_id: z.number().int().positive().optional(),\n title: z.string().min(1).max(64).optional(),\n add_phones: z.array(phone).max(10_000).optional(),\n remove_phones: z.array(phone).max(10_000).optional(),\n reset_phones: z.boolean().optional(),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_manage_audience\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n ctx.policy.assertWrite(input.confirm);\n\n if (input.action === \"create\") {\n if (!input.title) throw new Error(\"title is required when action=create.\");\n if (!input.add_phones?.length)\n throw new Error(\"add_phones is required when action=create.\");\n const result = await ctx.client.write<Audience>(\n \"createAudience\",\n compact({\n account_id: input.account_id,\n title: input.title,\n add_phones: input.add_phones,\n }),\n );\n return { audience: result.data, idempotency_key: result.idempotencyKey };\n }\n\n if (input.audience_id === undefined) {\n throw new Error(\"audience_id is required when action=update or action=delete.\");\n }\n\n if (input.action === \"delete\") {\n await ctx.client.write(\n \"deleteAudience\",\n compact({\n account_id: input.account_id,\n audience_id: input.audience_id,\n }),\n );\n return { deleted: true, audience_id: input.audience_id };\n }\n\n if (\n input.title === undefined &&\n !input.add_phones?.length &&\n !input.remove_phones?.length &&\n input.reset_phones === undefined\n ) {\n throw new Error(\n \"Provide title, add_phones, remove_phones or reset_phones to update an audience.\",\n );\n }\n\n const result = await ctx.client.write<Audience>(\n \"editAudience\",\n compact({\n account_id: input.account_id,\n audience_id: input.audience_id,\n title: input.title,\n add_phones: input.add_phones,\n remove_phones: input.remove_phones,\n reset_phones: input.reset_phones,\n }),\n );\n return { audience: result.data, idempotency_key: result.idempotencyKey };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { buildSdkDts, searchMethods } from \"../code-mode/sdk.js\";\nimport { runCode } from \"../code-mode/run.js\";\nimport { isWriteMethod } from \"../api/catalog.js\";\nimport type { Params } from \"../api/client.js\";\nimport { toolHandler, type ToolContext } from \"./helpers.js\";\n\nexport function registerCodeTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_search\",\n {\n title: \"Search Telegram Ads methods\",\n description:\n \"Search the official Telegram Ads API methods by name, description or parameter. \" +\n \"Use this to discover the right method before calling tg_api_call or writing a tg_execute script. \" +\n \"Returns names, descriptions, write flags, return types and full parameter signatures.\",\n inputSchema: z.object({\n query: z.string().optional().describe(\"Empty returns all methods.\"),\n write: z.boolean().optional().describe(\"Only return methods that change state.\"),\n limit: z.number().int().min(1).max(50).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n toolHandler(ctx, \"tg_search\", async (input) => {\n const methods = searchMethods(input.query ?? \"\", input.limit ?? 10, input.write);\n return { count: methods.length, methods };\n }),\n );\n\n server.registerTool(\n \"tg_get_sdk\",\n {\n title: \"Get the Code Mode TypeScript SDK\",\n description:\n \"Return the TypeScript declarations for the tg namespace available inside tg_execute. \" +\n \"Read this before writing a non-trivial script; it documents every method signature.\",\n inputSchema: z.object({}),\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n toolHandler(ctx, \"tg_get_sdk\", async () => ({ sdk: buildSdkDts() })),\n );\n\n server.registerTool(\n \"tg_execute\",\n {\n title: \"Execute a Telegram Ads script\",\n description:\n \"Run JavaScript in an isolated QuickJS sandbox with a typed tg object, for multi-step work that \" +\n \"would otherwise need many tool calls: bulk edits, cross-ad analysis, pagination, joins and reports. \" +\n \"Only console.log output and the returned value come back. No network, filesystem, process or env \" +\n \"access. Calls run sequentially; the limit is 25 API calls, 15 seconds and 64 KB of output. \" +\n \"Example: `const ads = await tg.getAdsList({limit: 100}); return ads.ads.length`. \" +\n \"Write methods require TG_ADS_MODE=write, TG_ADS_CODE_MODE=write and confirm: true.\",\n inputSchema: z.object({\n code: z\n .string()\n .min(1)\n .max(20_000)\n .describe(\"An async arrow function, a function expression, or a plain statement body.\"),\n confirm: z.boolean().optional().describe(\"Required before any write method can run.\"),\n idempotency_key: z\n .string()\n .min(1)\n .max(64)\n .optional()\n .describe(\"Prefix for write idempotency keys, useful when retrying a script.\"),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_execute\", async (input) => {\n if (!ctx.policy.codeModeEnabled) {\n throw new Error(\n \"Code Mode is disabled. Set TG_ADS_CODE_MODE=read-only or write to enable it.\",\n );\n }\n\n const allowWrite =\n ctx.policy.canWrite && ctx.policy.codeModeCanWrite && input.confirm === true;\n let writeIndex = 0;\n\n const result = await runCode({\n code: input.code,\n allowWrite,\n isWrite: isWriteMethod,\n call: async (method: string, params: Params) => {\n if (!isWriteMethod(method)) return ctx.client.call(method, params);\n\n ctx.policy.assertCodeModeWrite(input.confirm);\n writeIndex += 1;\n const key = input.idempotency_key\n ? `${input.idempotency_key}-${writeIndex}`.slice(0, 128)\n : undefined;\n const written = await ctx.client.write(\n method,\n params,\n key ? { idempotencyKey: key } : {},\n );\n return written.data;\n },\n });\n\n return result;\n }),\n );\n}\n","import {\n getQuickJS,\n type QuickJSContext,\n type QuickJSDeferredPromise,\n type QuickJSHandle,\n} from \"quickjs-emscripten\";\nimport type { Params } from \"../api/client.js\";\nimport { API_METHODS } from \"../api/catalog.js\";\n\nexport interface CodeRunOptions {\n code: string;\n call: (method: string, params: Params) => Promise<unknown>;\n allowWrite: boolean;\n isWrite: (method: string) => boolean;\n maxCalls?: number;\n timeoutMs?: number;\n maxOutputBytes?: number;\n}\n\nexport interface CodeRunResult {\n ok: boolean;\n result?: unknown;\n logs: string[];\n calls: Array<{ method: string; duration_ms: number; ok: boolean }>;\n duration_ms: number;\n error?: string;\n}\n\nconst PRELUDE = `\n(() => {\n const host = globalThis.__host;\n const log = globalThis.__log;\n delete globalThis.__host;\n delete globalThis.__log;\n\n const tg = {};\n for (const name of Object.keys(host)) {\n tg[name] = async (params) =>\n JSON.parse(await host[name](name, JSON.stringify(params === undefined ? {} : params)));\n }\n globalThis.tg = tg;\n\n const format = (value) => {\n if (typeof value === \"string\") return value;\n try { return JSON.stringify(value); } catch { return String(value); }\n };\n const write = (level) => (...args) =>\n log((level ? level + \" \" : \"\") + args.map(format).join(\" \").slice(0, 2000));\n globalThis.console = { log: write(\"\"), warn: write(\"[warn]\"), error: write(\"[error]\") };\n})();\n`;\n\nfunction looksLikeFunction(code: string): boolean {\n return /^\\s*(async\\s+)?(\\(|function\\b|[A-Za-z_$][\\w$]*\\s*=>)/.test(code);\n}\n\nfunction wrapCode(code: string): string {\n return looksLikeFunction(code) ? `(${code})()` : `(async () => {\\n${code}\\n})()`;\n}\n\nfunction errorMessage(context: QuickJSContext, handle: QuickJSHandle): string {\n const dumped: unknown = context.dump(handle);\n if (dumped instanceof Error) return dumped.message;\n if (dumped && typeof dumped === \"object\" && \"message\" in dumped) {\n const message = (dumped as { message?: unknown }).message;\n if (typeof message === \"string\" && message.length > 0) return message;\n }\n return String(dumped);\n}\n\n/**\n * Executes model-written JavaScript inside QuickJS (WebAssembly), with no\n * filesystem, network, process or environment access. The only capability is\n * the `tg` object, whose calls are bridged back to the host through deferred\n * promises. API calls run one at a time, in script order.\n */\nexport async function runCode(options: CodeRunOptions): Promise<CodeRunResult> {\n const started = Date.now();\n const timeoutMs = options.timeoutMs ?? 15_000;\n const deadline = started + timeoutMs;\n const maxCalls = options.maxCalls ?? 25;\n const maxOutputBytes = options.maxOutputBytes ?? 64 * 1024;\n const logs: string[] = [];\n const calls: CodeRunResult[\"calls\"] = [];\n const module = await getQuickJS();\n const context = module.newContext();\n\n const failed = (error: string): CodeRunResult => ({\n ok: false,\n error,\n logs,\n calls,\n duration_ms: Date.now() - started,\n });\n\n try {\n context.runtime.setMemoryLimit(64 * 1024 * 1024);\n context.runtime.setMaxStackSize(1024 * 1024);\n context.runtime.setInterruptHandler(() => Date.now() > deadline);\n\n interface PendingCall {\n deferred: QuickJSDeferredPromise;\n method: string;\n params: Params;\n }\n const queue: PendingCall[] = [];\n let callCount = 0;\n\n const rejected = (message: string): QuickJSHandle => {\n const promise = context.newPromise();\n const error = context.newError(new Error(message));\n promise.reject(error);\n error.dispose();\n const handle = promise.handle.dup();\n promise.dispose();\n return handle;\n };\n\n const callHandle = context.newFunction(\n \"__call\",\n (methodHandle: QuickJSHandle, paramsHandle: QuickJSHandle) => {\n const method = context.getString(methodHandle);\n\n if (callCount >= maxCalls) {\n return rejected(`Call limit reached (${maxCalls}). Reduce the number of API calls.`);\n }\n if (Date.now() > deadline) {\n return rejected(\"Execution deadline reached.\");\n }\n if (options.isWrite(method) && !options.allowWrite) {\n return rejected(\n `${method} changes state, but Code Mode is read-only. ` +\n \"Set TG_ADS_CODE_MODE=write and pass confirm: true to allow writes.\",\n );\n }\n\n let params: Params;\n try {\n const parsed: unknown = JSON.parse(context.getString(paramsHandle));\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n return rejected(`${method} expects a plain object of parameters.`);\n }\n params = parsed as Params;\n } catch {\n return rejected(`${method} expects a plain object of parameters.`);\n }\n\n callCount += 1;\n const deferred = context.newPromise();\n queue.push({ deferred, method, params });\n return deferred.handle.dup();\n },\n );\n\n const logHandle = context.newFunction(\"__log\", (messageHandle: QuickJSHandle) => {\n if (logs.length < 200) logs.push(context.getString(messageHandle));\n });\n\n const hostHandle = context.newObject();\n for (const method of API_METHODS) {\n if (method.deprecated) continue;\n context.setProp(hostHandle, method.name, callHandle);\n }\n\n context.setProp(context.global, \"__host\", hostHandle);\n context.setProp(context.global, \"__log\", logHandle);\n hostHandle.dispose();\n callHandle.dispose();\n logHandle.dispose();\n\n const prelude = context.evalCode(PRELUDE);\n context.unwrapResult(prelude).dispose();\n\n const evaluation = context.evalCode(wrapCode(options.code), \"tg-execute.js\");\n if (evaluation.error) {\n const message = errorMessage(context, evaluation.error);\n evaluation.error.dispose();\n return failed(message);\n }\n\n const handle = context.unwrapResult(evaluation);\n try {\n // Alternate between host API calls and guest microtasks. Every guest\n // await is backed by a deferred promise resolved from this loop.\n for (;;) {\n const next = queue.shift();\n if (next) {\n const callStarted = Date.now();\n try {\n const value = await options.call(next.method, next.params);\n const serialized = context.newString(JSON.stringify(value ?? null));\n next.deferred.resolve(serialized);\n serialized.dispose();\n calls.push({ method: next.method, duration_ms: Date.now() - callStarted, ok: true });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const errorHandle = context.newError(new Error(message));\n next.deferred.reject(errorHandle);\n errorHandle.dispose();\n calls.push({ method: next.method, duration_ms: Date.now() - callStarted, ok: false });\n }\n next.deferred.dispose();\n continue;\n }\n\n const jobs = context.runtime.executePendingJobs();\n if (jobs.error) {\n const message = errorMessage(context, jobs.error);\n jobs.error.dispose();\n return failed(message);\n }\n if (jobs.value === 0) break;\n }\n\n const state = context.getPromiseState(handle);\n if (state.type === \"pending\") {\n return failed(\"Script returned a promise that never settled.\");\n }\n if (state.type === \"rejected\") {\n const message = errorMessage(context, state.error);\n state.error.dispose();\n return failed(message);\n }\n\n const value = context.dump(state.value);\n state.value.dispose();\n let serialized: string;\n try {\n serialized = JSON.stringify(value ?? null);\n } catch {\n serialized = String(value);\n }\n if (serialized.length > maxOutputBytes) {\n return failed(\n `Result is ${serialized.length} bytes, above the ${maxOutputBytes} byte limit. ` +\n \"Filter or aggregate inside the script and return a smaller object.\",\n );\n }\n\n return {\n ok: true,\n result: value,\n logs,\n calls,\n duration_ms: Date.now() - started,\n };\n } finally {\n handle.dispose();\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return failed(\n message.includes(\"interrupted\") ? `Execution exceeded the ${timeoutMs} ms limit.` : message,\n );\n } finally {\n context.dispose();\n }\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { Pixel, PixelEvent, PixelEventsList } from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nconst eventType = z.enum([\n \"page_view\",\n \"add_to_cart\",\n \"add_to_wishlist\",\n \"customize_product\",\n \"initiate_checkout\",\n \"add_payment_info\",\n \"purchase\",\n \"contact\",\n \"lead\",\n \"schedule\",\n \"complete_registration\",\n \"submit_application\",\n \"start_trial\",\n \"subscribe\",\n \"view_content\",\n \"search\",\n \"find_location\",\n \"donate\",\n \"custom\",\n]);\n\nexport function registerPixelTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_get_pixel\",\n {\n title: \"Get pixel\",\n description:\n \"Get the account's Pixel Tag, including its ID and the HTML code snippet used to install it on a website.\",\n inputSchema: z.object({\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_pixel\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const pixel = await ctx.client.call<Pixel>(\n \"getPixel\",\n compact({ account_id: input.account_id }),\n );\n return { pixel };\n }),\n );\n\n server.registerTool(\n \"tg_list_pixel_events\",\n {\n title: \"List pixel events\",\n description:\n \"List conversion events for the account's pixel, or fetch specific events by ID.\",\n inputSchema: z.object({\n event_ids: z.array(z.string().min(1)).max(100).optional(),\n account_id: z.string().optional(),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_pixel_events\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n if (input.event_ids && input.event_ids.length > 0) {\n const events = await ctx.client.call<PixelEvent[]>(\n \"getPixelEventsById\",\n compact({ account_id: input.account_id, event_ids: input.event_ids }),\n );\n return { events };\n }\n\n const result = await ctx.client.call<PixelEventsList>(\n \"getPixelEventsList\",\n compact({ account_id: input.account_id, offset: input.offset, limit: input.limit }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_manage_pixel\",\n {\n title: \"Manage pixel and conversion events\",\n description:\n \"action=create_pixel creates the account's Pixel Tag (only one per account); \" +\n \"action=create_event needs title and type; action=update_event renames an event; \" +\n \"action=delete_event removes an event that is not used by any ad. \" +\n \"Requires confirm: true and TG_ADS_MODE=write.\",\n inputSchema: z.object({\n action: z.enum([\"create_pixel\", \"create_event\", \"update_event\", \"delete_event\"]),\n event_id: z.string().min(1).optional(),\n title: z.string().min(1).max(64).optional(),\n type: eventType.optional().describe(\"Event type, for example purchase or lead.\"),\n account_id: z.string().optional(),\n confirm: z.boolean().optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_manage_pixel\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n ctx.policy.assertWrite(input.confirm);\n\n if (input.action === \"create_pixel\") {\n const result = await ctx.client.write<Pixel>(\n \"createPixel\",\n compact({ account_id: input.account_id }),\n );\n return { pixel: result.data, idempotency_key: result.idempotencyKey };\n }\n\n if (input.action === \"create_event\") {\n if (!input.title) throw new Error(\"title is required when action=create_event.\");\n if (!input.type) throw new Error(\"type is required when action=create_event.\");\n const result = await ctx.client.write<PixelEvent>(\n \"createPixelEvent\",\n compact({\n account_id: input.account_id,\n title: input.title,\n type: input.type,\n }),\n );\n return { event: result.data, idempotency_key: result.idempotencyKey };\n }\n\n if (!input.event_id) throw new Error(\"event_id is required for event actions.\");\n\n if (input.action === \"update_event\") {\n if (!input.title) throw new Error(\"title is required when action=update_event.\");\n const result = await ctx.client.write<PixelEvent>(\n \"editPixelEvent\",\n compact({\n account_id: input.account_id,\n event_id: input.event_id,\n title: input.title,\n }),\n );\n return { event: result.data, idempotency_key: result.idempotencyKey };\n }\n\n await ctx.client.write(\n \"deletePixelEvent\",\n compact({\n account_id: input.account_id,\n event_id: input.event_id,\n }),\n );\n return { deleted: true, event_id: input.event_id };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { getMethod, isWriteMethod } from \"../api/catalog.js\";\nimport type { Params } from \"../api/client.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\ninterface MoneyRule {\n field: string;\n kind: \"cpm\" | \"ad\" | \"daily\" | \"amount\";\n}\n\nconst MONEY_RULES: Record<string, MoneyRule[]> = {\n createAd: [\n { field: \"cpm\", kind: \"cpm\" },\n { field: \"initial_budget\", kind: \"ad\" },\n { field: \"daily_budget_limit\", kind: \"daily\" },\n ],\n editAd: [\n { field: \"cpm\", kind: \"cpm\" },\n { field: \"daily_budget_limit\", kind: \"daily\" },\n ],\n increaseAdBudget: [{ field: \"amount\", kind: \"amount\" }],\n decreaseAdBudget: [{ field: \"amount\", kind: \"amount\" }],\n increaseAccountBudget: [{ field: \"amount\", kind: \"amount\" }],\n decreaseAccountBudget: [{ field: \"amount\", kind: \"amount\" }],\n};\n\nexport function registerRawTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_api_call\",\n {\n title: \"Call any Telegram Ads API method\",\n description:\n \"Escape hatch for methods that do not have a dedicated tool. Pass the exact method name from \" +\n \"tg_search and its parameters. Read methods run immediately; write methods require \" +\n \"TG_ADS_MODE=write and confirm: true, and receive an idempotency key automatically.\",\n inputSchema: z.object({\n method: z\n .string()\n .min(1)\n .describe(\"Exact method name, for example getTargetLocationsList.\"),\n params: z.record(z.string(), z.unknown()).optional(),\n confirm: z.boolean().optional(),\n idempotency_key: z.string().min(1).max(128).optional(),\n }),\n annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_api_call\", async (input) => {\n const method = getMethod(input.method);\n if (!method) {\n throw new Error(\n `Unknown method ${input.method}. Use tg_search to find the exact name. Names are case-sensitive.`,\n );\n }\n if (method.deprecated) {\n throw new Error(`${method.name} is deprecated: ${method.description}`);\n }\n\n const params: Params = input.params ?? {};\n const accountId = typeof params.account_id === \"string\" ? params.account_id : undefined;\n ctx.policy.assertAccount(accountId);\n\n const rules = MONEY_RULES[method.name];\n if (rules && rules.length > 0) {\n const currency = await ctx.client.resolveCurrency(accountId);\n for (const rule of rules) {\n const value = params[rule.field];\n if (typeof value !== \"number\") continue;\n if (rule.kind === \"cpm\") ctx.policy.assertCpm(value, currency);\n else if (rule.kind === \"ad\") ctx.policy.assertAdBudget(value, currency, rule.field);\n else if (rule.kind === \"daily\") ctx.policy.assertDailyBudget(value, currency);\n else ctx.policy.assertAmount(value, currency);\n }\n }\n\n if (isWriteMethod(method.name)) {\n ctx.policy.assertWrite(input.confirm);\n const result = await ctx.client.write(method.name, params, {\n ...(input.idempotency_key ? { idempotencyKey: input.idempotency_key } : {}),\n });\n return { method: method.name, result: result.data, idempotency_key: result.idempotencyKey };\n }\n\n const result = await ctx.client.call(method.name, compact(params));\n return { method: method.name, result };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { AccountReportItem, AdStatItem } from \"../api/types.js\";\nimport {\n compact,\n parseRange,\n planWindows,\n summarizeStats,\n toolHandler,\n type ToolContext,\n} from \"./helpers.js\";\n\nconst time = z.union([z.string().min(1), z.number().int().positive()]);\n\nexport function registerStatsTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_get_stats\",\n {\n title: \"Get advertising stats\",\n description:\n \"Get account or per-ad statistics for a time range. from/to accept Unix seconds, milliseconds, or \" +\n \"ISO 8601. interval is 86400 (daily, default) or 300 (5 minutes). Ranges above 1000 intervals are \" +\n \"split automatically. Always returns totals and derived CTR/CPM/CPC; set include_series for the \" +\n \"raw time series. Timestamps are inclusive for from and exclusive for to.\",\n inputSchema: z.object({\n scope: z.enum([\"account\", \"ad\"]),\n ad_ids: z.array(z.number().int().positive()).max(100).optional(),\n account_id: z.string().optional(),\n from: time,\n to: time,\n interval: z.union([z.literal(300), z.literal(86400)]).optional(),\n include_series: z\n .boolean()\n .optional()\n .describe(\"Include raw per-interval rows (default false).\"),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_stats\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const interval = input.interval ?? 86400;\n const range = parseRange(input.from, input.to);\n const windows = planWindows(range, interval);\n\n if (input.scope === \"account\") {\n const items: AdStatItem[] = [];\n for (const window of windows) {\n const chunk = await ctx.client.call<AdStatItem[]>(\n \"getAccountStats\",\n compact({\n account_id: input.account_id,\n from_time: window.from,\n to_time: window.to,\n interval,\n }),\n );\n items.push(...chunk);\n }\n\n return {\n scope: \"account\",\n interval,\n from: range.from,\n to: range.to,\n requests: windows.length,\n totals: summarizeStats(items),\n ...(input.include_series ? { series: items } : {}),\n };\n }\n\n const adIds = input.ad_ids ?? [];\n if (adIds.length === 0) {\n throw new Error(\"ad_ids is required when scope is ad.\");\n }\n\n const byAd: Array<{\n ad_id: number;\n totals: ReturnType<typeof summarizeStats>;\n series?: AdStatItem[];\n }> = [];\n const allItems: AdStatItem[] = [];\n\n for (const adId of adIds) {\n const items: AdStatItem[] = [];\n for (const window of windows) {\n const chunk = await ctx.client.call<AdStatItem[]>(\n \"getAdStats\",\n compact({\n account_id: input.account_id,\n ad_id: adId,\n from_time: window.from,\n to_time: window.to,\n interval,\n }),\n );\n items.push(...chunk);\n }\n allItems.push(...items);\n byAd.push({\n ad_id: adId,\n totals: summarizeStats(items),\n ...(input.include_series ? { series: items } : {}),\n });\n }\n\n return {\n scope: \"ad\",\n interval,\n from: range.from,\n to: range.to,\n requests: windows.length * adIds.length,\n totals: summarizeStats(allItems),\n by_ad: byAd,\n };\n }),\n );\n\n server.registerTool(\n \"tg_get_report\",\n {\n title: \"Get monthly account report\",\n description:\n \"Get Telegram's monthly report for all active ads in an account, including views, opens, clicks, \" +\n \"actions and spend per ad.\",\n inputSchema: z.object({\n year: z.number().int().min(2024).max(2100),\n month: z.number().int().min(1).max(12),\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_report\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n const report = await ctx.client.call<AccountReportItem[]>(\n \"getAccountReport\",\n compact({ account_id: input.account_id, year: input.year, month: input.month }),\n );\n return { year: input.year, month: input.month, items: report };\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type {\n TargetBot,\n TargetChannel,\n TargetCountry,\n TargetLanguage,\n TargetLocation,\n TargetLocationList,\n TargetTopic,\n} from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\nimport { idOrUsername } from \"./schemas.js\";\n\nexport function registerTargetingTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_targeting\",\n {\n title: \"List targeting options\",\n description:\n \"Look up targeting catalogs. kind=languages, topics or countries takes no extra arguments. \" +\n \"kind=locations searches by country_code and/or query, or resolves location_ids. \" +\n \"kind=channel resolves a channel by @username or numeric ID; kind=bot does the same for bots. \" +\n \"Prefer @username for channels and bots: numeric IDs only work after this account has resolved them.\",\n inputSchema: z.object({\n kind: z.enum([\"languages\", \"topics\", \"countries\", \"locations\", \"channel\", \"bot\"]),\n country_code: z.string().length(2).optional().describe(\"Required for location search.\"),\n query: z.string().optional().describe(\"Location search text.\"),\n location_ids: z.array(z.number().int().positive()).max(100).optional(),\n offset: z.string().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n channel: idOrUsername.optional(),\n bot: idOrUsername.optional(),\n for_excluding: z.boolean().optional(),\n account_id: z.string().optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_targeting\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n switch (input.kind) {\n case \"languages\": {\n const languages = await ctx.client.call<TargetLanguage[]>(\"getTargetLanguagesList\");\n return { languages };\n }\n case \"topics\": {\n const topics = await ctx.client.call<TargetTopic[]>(\"getTargetTopicsList\");\n return { topics };\n }\n case \"countries\": {\n const countries = await ctx.client.call<TargetCountry[]>(\"getTargetCountriesList\");\n return { countries };\n }\n case \"locations\": {\n if (input.location_ids && input.location_ids.length > 0) {\n const locations = await ctx.client.call<TargetLocation[]>(\"getTargetLocationsById\", {\n location_ids: input.location_ids,\n });\n return { locations };\n }\n if (!input.country_code) {\n throw new Error(\"country_code is required when searching locations by text.\");\n }\n const result = await ctx.client.call<TargetLocationList>(\n \"getTargetLocationsList\",\n compact({\n country_code: input.country_code,\n query: input.query,\n offset: input.offset,\n limit: input.limit,\n }),\n );\n return result;\n }\n case \"channel\": {\n if (input.channel === undefined) throw new Error(\"channel is required for kind=channel.\");\n const channel = await ctx.client.call<TargetChannel>(\n \"getTargetChannel\",\n compact({ channel_id: input.channel, for_excluding: input.for_excluding }),\n );\n return { channel };\n }\n case \"bot\": {\n if (input.bot === undefined) throw new Error(\"bot is required for kind=bot.\");\n const bot = await ctx.client.call<TargetBot>(\"getTargetBot\", { bot_id: input.bot });\n return { bot };\n }\n }\n }),\n );\n}\n","import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type {\n AccountTransactionsList,\n AdTransactionsList,\n TransactionStatus,\n} from \"../api/types.js\";\nimport { compact, toolHandler, type ToolContext } from \"./helpers.js\";\n\nexport function registerTransactionTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"tg_list_transactions\",\n {\n title: \"List transactions\",\n description:\n \"List account-level or ad-level transactions. Use next_offset to page. \" +\n \"Transactions explain where budget was added or spent.\",\n inputSchema: z.object({\n scope: z.enum([\"account\", \"ad\"]),\n ad_id: z.number().int().positive().optional(),\n account_id: z.string().optional(),\n offset: z.number().int().nonnegative().optional(),\n limit: z.number().int().min(1).max(100).optional(),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_list_transactions\", async (input) => {\n ctx.policy.assertAccount(input.account_id);\n\n if (input.scope === \"ad\") {\n if (input.ad_id === undefined) throw new Error(\"ad_id is required when scope=ad.\");\n const result = await ctx.client.call<AdTransactionsList>(\n \"getAdTransactionsList\",\n compact({\n account_id: input.account_id,\n ad_id: input.ad_id,\n offset: input.offset,\n limit: input.limit,\n }),\n );\n return result;\n }\n\n const result = await ctx.client.call<AccountTransactionsList>(\n \"getAccountTransactionsList\",\n compact({ account_id: input.account_id, offset: input.offset, limit: input.limit }),\n );\n return result;\n }),\n );\n\n server.registerTool(\n \"tg_get_transaction\",\n {\n title: \"Get transaction status\",\n description: \"Check the status of a budget transaction by its transaction ID.\",\n inputSchema: z.object({\n transaction_id: z.string().min(1),\n }),\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n toolHandler(ctx, \"tg_get_transaction\", async (input) => {\n const status = await ctx.client.call<TransactionStatus>(\"getTransactionStatus\", {\n transaction_id: input.transaction_id,\n });\n return { transaction: status };\n }),\n );\n}\n","import { registerAccountTools } from \"./account.js\";\nimport { registerAdTools } from \"./ads.js\";\nimport { registerAudienceTools } from \"./audiences.js\";\nimport { registerCodeTools } from \"./code.js\";\nimport { registerPixelTools } from \"./pixels.js\";\nimport { registerRawTools } from \"./raw.js\";\nimport { registerStatsTools } from \"./stats.js\";\nimport { registerTargetingTools } from \"./targeting.js\";\nimport { registerTransactionTools } from \"./transactions.js\";\nimport type { ToolContext } from \"./helpers.js\";\nimport type { McpServer } from \"@modelcontextprotocol/server\";\n\nexport function registerTools(server: McpServer, ctx: ToolContext): void {\n registerAccountTools(server, ctx);\n registerAdTools(server, ctx);\n registerStatsTools(server, ctx);\n registerTargetingTools(server, ctx);\n registerAudienceTools(server, ctx);\n registerPixelTools(server, ctx);\n registerTransactionTools(server, ctx);\n registerCodeTools(server, ctx);\n registerRawTools(server, ctx);\n}\n\nexport type { ToolContext };\n"],"mappings":";;;A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z","result","z","handle","value","serialized","z","z","z","z","z","result","z","z","z","z","languages","z","z","result","resolve","readFile","mkdir","dirname"]}
|