ChatGPT to Telegram MCP
Allows ChatGPT to publish duplicate-free posts to a fixed Telegram channel, with 48-hour history and deduplication.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ChatGPT to Telegram MCPSend this announcement to the Telegram channel."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ChatGPT to Telegram MCP
Publish reliable, duplicate-free Telegram posts from ChatGPT — manually or as part of a scheduled workflow.
Features · Architecture · Quick start · Connect ChatGPT · Security
ChatGPT to Telegram MCP is a Streamable HTTP MCP server for Cloudflare Workers. It gives ChatGPT two focused tools: read the posts this server sent during the previous 48 hours, and publish one post to a fixed Telegram channel. Exact-text and source-URL deduplication prevents accidental reposts.
Use it in an ordinary ChatGPT conversation or make publishing part of a scheduled workflow when scheduled tasks and custom MCP apps are available for your account or workspace. The Worker itself does not run a cron job.
This is an unofficial open-source project and is not affiliated with OpenAI or Telegram.
Features
ChatGPT-ready MCP endpoint using Streamable HTTP.
One fixed Telegram destination controlled by server configuration, not model input.
48-hour history backed by Cloudflare D1.
Duplicate protection for normalized text and canonical source URLs.
OAuth 2.1 authentication with GitHub sign-in, PKCE
S256, DCR, and CIMD.GitHub allowlist for explicit access control.
Safe retries through pending D1 reservations and idempotent tool behavior.
Cloudflare-native deployment with Workers, KV, D1, logs, and traces.
Related MCP server: Telegram Channel MCP Server
Architecture
flowchart LR
C["ChatGPT<br/>chat or scheduled workflow"]
W["Cloudflare Worker<br/>OAuth + MCP server"]
G["GitHub OAuth<br/>identity check"]
K["Cloudflare KV<br/>OAuth state and tokens"]
D["Cloudflare D1<br/>48-hour send history"]
T["Telegram Bot API<br/>fixed channel"]
C -->|"OAuth 2.1 + MCP"| W
W <-->|"sign in"| G
W <-->|"OAuth records"| K
W <-->|"history and dedupe"| D
W -->|"sendMessage"| TPublish flow
sequenceDiagram
participant C as ChatGPT
participant M as MCP Worker
participant D as D1
participant T as Telegram
C->>M: get_previous_messages
M->>D: Read the previous 48 hours
D-->>M: Posts and source URLs
M-->>C: History
C->>C: Prepare a non-duplicate digest
C->>M: send_message(text, source_urls)
M->>D: Reserve fingerprint and URLs
alt Duplicate found
D-->>M: Existing matches
M-->>C: sent=false, duplicate=true
else New post
D-->>M: Reservation created
M->>T: sendMessage
T-->>M: Telegram message
M->>D: Mark reservation as sent
M-->>C: sent=true
endMCP tools
Tool | Purpose | Important behavior |
| Returns up to 100 posts sent by this server during the previous 48 hours. | Reads the Worker's D1 history; it cannot see manual posts or posts from other bots. |
| Publishes one post to the configured Telegram channel. | Rejects matching text or source URLs found in the 48-hour window. Include every represented article URL in |
The public tool names and response formats are stable across the project rebrand.
Prerequisites
Node.js 20 or newer.
A Cloudflare account with Wrangler authenticated.
A Telegram bot that can post to the target channel.
A GitHub OAuth App.
A ChatGPT account or workspace with custom MCP app support for the way you intend to use it.
Quick start
1. Install
git clone https://github.com/d8rt8v/chatgpt-to-telegram-mcp.git
cd chatgpt-to-telegram-mcp
npm install2. Create local configuration
macOS/Linux:
cp wrangler.example.jsonc wrangler.jsonc
cp .env.example .envPowerShell:
Copy-Item wrangler.example.jsonc wrangler.jsonc
Copy-Item .env.example .envBoth files are ignored by Git. Keep real account IDs and credentials there only.
3. Create Cloudflare resources
npx wrangler d1 create chatgpt-telegram-history
npx wrangler kv namespace create OAUTH_KVCopy the returned D1 and KV IDs into wrangler.jsonc without changing the DB and OAUTH_KV binding names.
4. Configure the GitHub OAuth App
For a Worker deployed at https://chatgpt-tg-mcp.<subdomain>.workers.dev, set:
Homepage URL:
https://chatgpt-tg-mcp.<subdomain>.workers.devAuthorization callback URL:
https://chatgpt-tg-mcp.<subdomain>.workers.dev/callback
Put the OAuth Client ID and Client Secret in .env.
5. Configure environment values
Variable | Description |
| Token issued by BotFather. |
| Fixed destination, such as |
| GitHub OAuth App Client ID. |
| GitHub OAuth App Client Secret. |
| One GitHub login or a comma-separated allowlist, for example |
All five values are uploaded as encrypted Worker secrets. Wrangler also loads .env for local development when no .dev.vars file exists.
6. Migrate and deploy
npm run db:migrate:remote
npm run deploy
npm run secrets:pushnpm run secrets:push runs wrangler secret bulk .env. A production deployment does not receive values from the local .env file automatically.
Keep the existing D1 database ID, KV namespace ID, binding names, and migration state in your local wrangler.jsonc. The rebrand changes only the Worker name and public URL; it does not recreate or erase D1/KV data.
Before deploying:
Fill the two blank secret values in the local
.env.Change the GitHub OAuth App homepage and callback to the new
chatgpt-tg-mcpURL.Deploy the renamed Worker and push
.envwithnpm run secrets:push.Reconnect the MCP app in ChatGPT.
The old Worker is not deleted automatically. After the new endpoint is verified, retire the old Worker or remove its OAuth and Telegram secrets; otherwise it remains a second write-capable endpoint and existing MCP tokens may continue to publish through it. Deleting the old Worker does not delete the separately managed D1 database or KV namespace reused by the new deployment.
If the existing D1 migration is already applied, do not apply it again just for the rebrand.
Connect ChatGPT
Add the public MCP endpoint as a custom app/server:
https://chatgpt-tg-mcp.<subdomain>.workers.dev/mcpChoose OAuth authentication. ChatGPT should discover the OAuth endpoints automatically; do not paste GitHub credentials into ChatGPT. Sign in with a GitHub account listed in ALLOWED_GITHUB_LOGINS.
Interactive use works anywhere your ChatGPT account or workspace supports the custom MCP app. Scheduled publishing is an additional use case where scheduled workflows can access the app. Availability depends on the ChatGPT plan and workspace configuration; see OpenAI's documentation for Scheduled Tasks and Workspace Agents.
Authentication
ChatGPT discovers the protected-resource and authorization-server metadata.
It registers with DCR or uses CIMD and starts an authorization-code flow with PKCE
S256.The Worker displays a consent page and redirects to GitHub.
Only users in
ALLOWED_GITHUB_LOGINSare accepted.The Worker issues its own access and refresh tokens to ChatGPT.
The GitHub token is used only for the identity check and is not stored in MCP token properties.
Verify a deployment
curl https://chatgpt-tg-mcp.<subdomain>.workers.dev/health
curl -i https://chatgpt-tg-mcp.<subdomain>.workers.dev/mcp
curl https://chatgpt-tg-mcp.<subdomain>.workers.dev/.well-known/oauth-protected-resource/mcp
curl https://chatgpt-tg-mcp.<subdomain>.workers.dev/.well-known/oauth-authorization-serverExpected results:
/healthreturns{"ok":true,"service":"chatgpt-to-telegram-mcp","authentication":"oauth"}./mcpreturns401without a token and includes aWWW-Authenticatechallenge.Both
/.well-known/endpoints return OAuth metadata as JSON.
Local development
Create a separate GitHub OAuth App for local work with:
Homepage:
http://localhost:8787Callback:
http://localhost:8787/callback
Then run:
npm run db:migrate:local
npm run devOAuth cookies are Secure, so the production workers.dev URL remains the most reliable way to test the complete browser flow.
Commands
Command | Description |
| Start the local Worker. |
| Run the Node.js test suite. |
| Check JavaScript syntax. |
| Apply D1 migrations locally through the |
| Apply D1 migrations to the configured remote database. |
| Deploy the Worker. |
| Upload all |
Security
Telegram destination selection remains server-side; the model cannot choose a different channel.
GitHub login matching is case-insensitive and denies every account outside the allowlist.
Access tokens expire after one hour, refresh tokens after 30 days, and dynamic client registrations after 90 days.
Plain PKCE and the OAuth implicit flow are disabled.
OAuth state and CSRF values are one-time and expire after ten minutes.
The Telegram bot token, GitHub secret, account IDs, and live Wrangler configuration are excluded from Git.
Telegram is called only after D1 successfully reserves the content fingerprint and source URLs.
Limitations
Telegram bots cannot read arbitrary historical channel messages.
get_previous_messagesreturns only posts recorded by this Worker.Deduplication covers the previous 48 hours, not the entire lifetime of the channel.
Semantic duplicate detection is performed by ChatGPT using the returned history; the server enforces exact normalized-text and canonical-URL matches.
Scheduled execution is provided by the ChatGPT workflow using this MCP server, not by a Cloudflare cron trigger.
License
Released under the MIT License.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- 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/d8rt8v/ChatGPT-to-Telegram-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server