TelegramMCP
A small Model Context Protocol (MCP) server that lets MCP clients send Telegram messages to a configured user through a Telegram bot.
The server communicates over stdio and exposes a single send_message tool, so it works with any MCP-compatible client (Claude Desktop, Cursor, VS Code, etc.).
Features
send_message tool for sending a text message to a fixed Telegram user
- Zero-config startup: the config directory and
.env template are created automatically on first run
- Credentials are read from
~/.telegram-mcp/.env and never from the repository
- Statically compiled Go binary with no runtime dependencies
Requirements
- Go 1.27.1 or newer
- A Telegram bot token from @BotFather
- Your numeric Telegram user ID (you can get it from @userinfobot)
Installation
With go install (recommended)
go install github.com/coderianx/TelegramMCP@latest
The binary is installed to your Go bin directory:
# Linux / macOS
$(go env GOPATH)/bin/TelegramMCP
# Windows
%USERPROFILE%\go\bin\TelegramMCP.exe
Make sure that directory is on your PATH if you want to call the binary by name.
@latest builds from the latest commit on the default branch. Pin a version with @v1.0.0 once releases are tagged.
From source
git clone https://github.com/coderianx/TelegramMCP.git
cd TelegramMCP
go build -o telegram-mcp .
Configuration
On startup the server creates ~/.telegram-mcp/ and, if it does not exist yet, a .env file with this template:
TG_TOKEN=
USER_ID=
Fill in both values:
| Variable |
Description |
TG_TOKEN |
Bot token from @BotFather |
USER_ID |
Numeric Telegram user ID that will receive the messages |
The file is only created once; existing values are never overwritten. Because it contains a secret, consider restricting its permissions:
chmod 600 ~/.telegram-mcp/.env
Important: the target user must start a conversation with the bot first (send /start), otherwise Telegram will reject the message.
MCP client setup
Add the server to your MCP client configuration. Example for Claude Desktop:
{
"mcpServers": {
"telegram": {
"command": "/home/you/go/bin/TelegramMCP",
"args": []
}
}
}
- Use the absolute path to the binary.
- On Windows the path is something like
C:\\Users\\you\\go\\bin\\TelegramMCP.exe.
- Restart the client after changing the configuration.
The exact configuration file location depends on the client:
- Claude Desktop (macOS):
~/Library/Application Support/Claude/claude_desktop_config.json
- Claude Desktop (Windows):
%APPDATA%\Claude\claude_desktop_config.json
- Other clients: see their MCP server documentation — any stdio server entry works.
Usage
Once connected, ask the client to use the tool, for example:
Send a Telegram message saying "Deploy finished successfully."
Input:
{
"content": "Hello from MCP!"
}
Output:
{
"result": "success",
"message": "message sent successfully"
}
On failure, result is "error", message describes the problem, and the tool also returns an error to the MCP client.
Project structure
TelegramMCP/
├── main.go # MCP server entrypoint and tool registration
├── internal/
│ ├── config/
│ │ ├── config.go # Creates ~/.telegram-mcp/.env on first run
│ │ └── env.go # Reads TG_TOKEN and USER_ID from .env
│ └── tools/
│ └── sendmessage.go # send_message tool implementation
├── go.mod
└── go.sum
Development
go build ./...
go vet ./...
gofmt -l .
To try the server manually, run go run . — it waits for MCP messages on stdin/stdout, so it is meant to be launched by an MCP client rather than used directly from a terminal.
Troubleshooting
| Problem |
Likely cause |
config: Init has not been called |
The binary was started without running config initialization — use the compiled main package entrypoint. |
config: TG_TOKEN is empty or missing |
.env exists but the token was not filled in. |
config: USER_ID "..." is not a valid integer |
USER_ID must be a numeric ID, not a username. |
Forbidden: bot can't initiate conversation with a user |
Send /start to the bot from the target account first. |
| Tool does not appear in the client |
Check that the command path is absolute and the client was restarted. |
License
MIT