tgtrack-mcp
tgtrack-mcp
Manage a tgtrack / «Откуда Подписки» account from an AI agent — channels, ad-system integrations, tracking-script settings, goals and links — with no official API.
English · Русский
Why
tgtrack ("Откуда Подписки") tracks where your Telegram subscribers come from and feeds offline "subscription" conversions back to Yandex Metrika / Direct. All of it — channels, "advertising systems" (integrations), the landing tracking-script, goals, links, daily reports — lives only in the settings.tgtrack.ru panel. There is no public API.
tgtrack-mcp exposes that control plane as MCP tools. It talks to the same internal endpoints the panel uses and signs every request exactly like the panel does (a short-lived JWT plus an md5-based request signature), so an AI agent (Claude, etc.) can list channels, read and create integrations, tweak the script settings, goals and links — in one turn.
🔑 Uses your panel token — a JWT read from the
settings.tgtrack.ruURL; nothing is scraped or hardcoded🧩 18 focused tools — read + safe writes; destructive actions gated behind
confirm: true🧮 Panel-accurate signing —
H = md5(md5(JSON + T) + T), verified against a live sample🪶 TypeScript, ESM, strict — thin, MIT, no account secrets in the repo
How it works
Every call is a POST to https://api.tgtrack.ru/API/settings/<endpoint>.php with a multipart/form-data body of two fields:
JSON = JSON.stringify({ ...params, T, tn }) // T = unix seconds, tn = your JWT
H = md5( md5(JSON + T) + T ) // request signature (T is the salt)The response is a { S, D, M } envelope: S === 0 means success and the payload is D.data; otherwise the tool returns a typed error (217/218 = bad/expired token → a clear "refresh your token" message).
Requirements
Node ≥ 18.
A tgtrack token (
TGTRACK_TOKEN): open settings.tgtrack.ru, and copy thet=value from the address bar (or thetgtrack_tokencookie). It is short-lived (~72 h); tgtrack has no working refresh endpoint, so re-paste it when it expires.
Setup
npm install
npm run buildRegister it with your MCP client (see .mcp.json.example):
{
"mcpServers": {
"tgtrack": {
"command": "node",
"args": ["dist/index.js"],
"env": { "TGTRACK_TOKEN": "<the ?t=... JWT from settings.tgtrack.ru>" }
}
}
}Tools
Read
Tool | Purpose |
| List all channels / groups / bots on the account. |
| Full channel: integrations (ad systems), links, script & report settings. |
| Build the ready |
Integrations ("advertising systems")
Tool | Purpose |
| Create an integration. For |
| Script settings of an integration (strict mode, conversion delay, auto-approve, goal flags…). |
| Update a goal (name/value in Metrika), optionally create it. |
| Poll Yandex auto-goal creation by |
| Link to re-grant Yandex access for an integration. |
Links & channel
Tool | Purpose |
| Landings attached to a channel / integration. |
| Change a link's target URL. |
| Rename a link / integration. |
| Params of an under-post button link (target, button text, subscription check). |
| Toggle auto-approval of join requests. |
| Daily-report toggles (morning report, send-if-no-subs, traffic report). |
Dangerous — require confirm: true
Tool | Purpose |
| ⚠️ Delete an invite link / integration (irreversible). |
| ⚠️ Delete an outbound link (irreversible). |
| ⚠️ Mint a new API key — invalidates the previous one. |
| ⚠️ Mint a new report key — invalidates the previous one. |
Without confirm: true the dangerous tools return a description of what they would do and never touch the API.
Usage
Run the MCP server over stdio, or call a tool directly for scripting:
node dist/index.js # MCP (stdio)
TGTRACK_TOKEN=... npx tsx src/run.ts tgtrack_list_channels
TGTRACK_TOKEN=... npx tsx src/run.ts tgtrack_get_channel '{"chatID":"600334c8b9b9e"}'
TGTRACK_TOKEN=... npx tsx src/run.ts tgtrack_get_integration_script \
'{"linkID":"5cd4255d831d9e","counterID":"110494105"}'Streamable HTTP transport:
TGTRACK_TOKEN=... node dist/index.js --http --port 3001 # /mcp, /healthScope
Included (v1): the full settings/management control plane — channels, integrations, script settings, goals, links, reports.
Not included yet:
Analytics data (subscribers over time, source breakdown, conversions) — this lives behind a separate reporting API keyed by a report key (
tgtrack_new_report_key). Planned for v2.Admin tools (
deleteChannel,changeUserAccess, …) — planned behind a flag (v1.1).MAX (
max.tgtrack.ru) parity — behind aserviceoption.
Security
The token lives only in your environment (TGTRACK_TOKEN) — never in the repo, never logged, never echoed in error messages. .mcp.json and .env are git-ignored; only .mcp.json.example (with a placeholder) is committed.
Contributing
Contributions welcome — open an issue or a PR.
Fork and branch:
git checkout -b feature/my-changenpm install;npm run buildandnpm testmust passNever commit secrets (the JWT /
.env/ a real.mcp.json) or real account dataOpen a PR describing what and why
License
MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/skiddgoddamn/tgtrack-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server