The Telegram MCP Server connects AI assistants like Claude to your Telegram account using the user client API instead of the bot API. This allows AI assistants to access and interact with your Telegram chats and messages through a standardized interface.
api_id
and api_hash
by creating a new application at https://core.telegram.org/api/obtaining_api_idClone the repository:
git clone https://github.com/your-username/telegram-mcp-server.git
cd telegram-mcp-server
Install dependencies:
npm install
Configure using environment variables in a .env
file:
TELEGRAM_API_ID=YOUR_API_ID
TELEGRAM_API_HASH=YOUR_API_HASH
TELEGRAM_PHONE_NUMBER=YOUR_PHONE_NUMBER_WITH_COUNTRY_CODE # e.g., +15551234567
Configure client software (Claude Desktop, Cursor, etc.) to connect to the MCP server:
{
"mcpServers": {
"telegram": {
"url": "http://localhost:8080/sse",
"disabled": false,
"timeout": 30
}
}
}
For Claude Desktop, the config file is located at:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
Important: Restart your MCP client after making changes.
For first-time setup or when your session expires:
npm start
./data/session.json
) will be created./data/dialog_cache.json
)Start the server manually:
npm start
Once running, your MCP client will connect to it via the configured URL.
Lists available Telegram channels/chats accessible by the account.
Parameters:
limit
(number, optional): Maximum number of channels to return (default: 50)Output: List of channels/chats with their ID, title, type, and access hash (if applicable).
Searches the cached channels/chats by keywords in their names.
Parameters:
keywords
(string): Keywords to search for in channel nameslimit
(number, optional): Maximum results to return (default: 100)Output: List of matching channels/chats.
Retrieves recent messages from a specific channel/chat.
Parameters:
channelId
(number): The numeric ID of the channel/chatlimit
(number, optional): Maximum messages to return (default: 100)filterPattern
(string, optional): JavaScript-compatible regex to filter messages by contentOutput: List of messages containing ID, date, text, and sender ID.
npm start
manually once to refresh the session./data/dialog_cache.json
and restart the server to force a full refreshnpm install
in the project directorydata
directoryThere are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.