Skip to main content
Glama

tg-mcp

MCP server for a personal Telegram account. Read, search, download media, and send messages or files, from any MCP client.

Credentials stay on the machine in ~/.tg/ and are never returned by any tool.

Setup on a new machine

Needs uv and nothing else. Python, dependencies and the package are all fetched on demand.

1. Sign in (once per machine, interactive because Telegram sends a code):

uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcp-login

It prompts for api_id / api_hash from https://my.telegram.org (API development tools), then your phone number, then the code Telegram sends to the app. It writes ~/.tg/credentials.json and ~/.tg/session.session, both mode 600, and prints your recent chats with their ids.

2. Register the server:

claude mcp add telegram -- uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcp

That is the whole setup. claude mcp list should show telegram ✔ Connected.

Related MCP server: telegram-mcp

Setting it up for other agents

The sign-in is per machine, not per agent. Run tg-mcp-login once and every agent on that machine shares ~/.tg/. Adding a second or third client is config only.

There is no single config format across MCP clients, so this package ships an installer that writes each one in its own shape:

uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcp-install

It configures every supported client it finds and leaves the rest alone. --list shows what it detected, --dry-run prints the changes without making them, --name sets the server name, and naming clients (tg-mcp-install opencode cursor) limits it to those. Existing config is merged rather than replaced, a .bak is kept, and a config file it cannot parse is skipped with a warning rather than overwritten.

Client

How it is registered

Claude Code

claude mcp add

Codex

codex mcp add

opencode

~/.config/opencode/opencode.json

Claude Desktop

claude_desktop_config.json

Cursor

~/.cursor/mcp.json

Windsurf

~/.codeium/windsurf/mcp_config.json

The rest of this section is the same thing by hand. Under every format it is one command and three arguments:

command

uvx

args

--from, git+https://github.com/Abdk4Moura/tg-mcp, tg-mcp

Claude Code

claude mcp add telegram -- uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcp

Add --scope user to make it available in every project rather than just the current one.

Claude Desktop, Cursor, Windsurf, Continue, and most others

These share the same mcpServers block. Add:

{
  "mcpServers": {
    "telegram": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Abdk4Moura/tg-mcp", "tg-mcp"]
    }
  }
}

to the client's config file:

Client

File

Claude Desktop (macOS)

~/Library/Application Support/Claude/claude_desktop_config.json

Claude Desktop (Windows)

%APPDATA%\Claude\claude_desktop_config.json

Cursor

~/.cursor/mcp.json, or .cursor/mcp.json for one project

Windsurf

~/.codeium/windsurf/mcp_config.json

Continue

~/.continue/config.json

Restart the client afterwards. Most only read MCP config at startup.

opencode

opencode does not use mcpServers. Its key is mcp, the command is a single array rather than a command plus args, and each server declares its type. Add to ~/.config/opencode/opencode.json (or opencode.json / .opencode/opencode.json in a project, for that project only):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "telegram": {
      "type": "local",
      "command": ["uvx", "--from", "git+https://github.com/Abdk4Moura/tg-mcp", "tg-mcp"],
      "enabled": true
    }
  }
}

Environment variables go in an environment object, not env. opencode mcp list shows the server and whether it connected.

opencode reads opencode.json and opencode.jsonc and merges them, so if your config is a commented .jsonc you can drop the block above into a plain opencode.json beside it and leave the commented file alone. That is what tg-mcp-install does.

opencode mcp add telegram also works, but it prompts for the command interactively, so it is not scriptable for a local server the way claude mcp add is. The --url flag on that command is for remote servers only.

Codex

codex mcp add telegram -- uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcp

Codex stores this in ~/.codex/config.toml. codex mcp list shows it.

Anything else

Give the client the same command and args from the table at the top of this section, in whatever shape its own MCP documentation specifies.

If uvx is not on PATH

Some clients launch with a minimal environment and will not find uvx. Use its absolute path as the command (which uvx to find it, commonly ~/.local/bin/uvx).

Tools

Tool

What it does

tg_whoami

Which account is signed in

tg_list_chats

Recent chats with their numeric ids

tg_read_chat

Read messages; peer takes an id, @username, or me for Saved Messages; optional since / until as YYYY-MM-DD

tg_search

Search message text across all chats or within one peer

tg_download_media

Fetch a message's attachment to disk

tg_send_message

Sends text. Real, immediate, not recallable by this server

tg_send_file

Sends a file with an optional caption

Sessions

Each machine that runs tg-mcp-login creates its own Telegram session, listed separately under Settings → Devices and revocable on its own.

Copying session.session between machines also works, but both then share one session identity: revoking it logs out both, and a login from a very different IP can trip Telegram's security checks. Prefer a fresh login per machine.

That file is full account access. Anyone holding it can read and send as you.

Configuration

Variable

Default

Purpose

TG_DIR

~/.tg

Where credentials.json and session.session live

TG_DOWNLOAD_DIR

$TG_DIR/downloads

Where tg_download_media writes

Local development

uv run --directory /path/to/tg-mcp tg-mcp

Available Tools

7 tools
tg_download_mediaA

Download the media attached to one message. Returns the local path. message_id comes from tg_read_chat or tg_search.

ParametersJSON Schema
NameRequiredDescriptionDefault
peerYes
message_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the burden of disclosing behavior. It mentions that it returns a local path, which is a key behavior, and provides a dependency on other tools. However, it does not disclose edge cases like messages without media or potential errors, so it is only minimally adequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long, with no filler. It front-loads the action and result, then provides a useful dependency hint. Every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (2 parameters, output schema available), the description is mostly complete. It covers the main purpose, expected input source, and return type. The only gaps are edge cases (e.g., no media attached) and peer semantics, but the output schema likely fills in return structure details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning to message_id (where it comes from) but provides no explanation for the 'peer' parameter, which is still ambiguous. For a two-parameter tool, half the parameters lack semantic context, making this below average.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Download' and the resource 'media attached to one message', which is specific and distinct from sibling tools like tg_read_chat (reading messages) and tg_send_file (uploading). It also differentiates by noting the message_id source, making the tool's scope unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use the tool by stating that message_id comes from tg_read_chat or tg_search, implying this tool is used after those operations. However, it does not explicitly name alternative tools or state when not to use it, but the context is sufficient for a simple download tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tg_list_chatsA

List recent Telegram chats with their numeric ids, newest first.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It reveals the ordering ('newest first') and id type ('numeric ids'), but leaves 'recent' undefined and does not state whether the operation has side effects. Adequate for a simple read-only list but not rich in detail.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, front-loaded with the action, and contains no redundant words. Every phrase contributes meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple and an output schema exists, so return values need not be described. The description covers purpose, ordering, and id format. Missing details like limit parameter explanation and usage guidance leave minor gaps, but overall it is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has one parameter (limit) with 0% description coverage. The description does not mention the limit parameter at all, leaving its meaning to be inferred from the name and default. The parameter semantics are not enhanced.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb (List), names the resource (Telegram chats), and adds scope constraints (recent, numeric ids, newest first). This clearly distinguishes it from sibling tools like tg_read_chat or tg_send_message.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for obtaining chat IDs and recency order, but it does not explicitly state when to choose this tool over alternatives or mention exclusions. No sibling tools are referenced.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tg_read_chatA

Read messages from a chat, oldest first. peer is a numeric id, an @username, or 'me' for Saved Messages. Optional since/until are YYYY-MM-DD.

ParametersJSON Schema
NameRequiredDescriptionDefault
peerYes
limitNo
sinceNo
untilNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden of behavioral disclosure. It discloses ordering and date-range types, but does not mention limit behavior, error cases, or permission requirements. This is a read tool, so safety is less critical, yet gaps remain.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the primary action, and every sentence adds value. No redundant filler or repetition of schema information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read tool with an output schema, the description covers the essential behavioral aspects: ordering, peer formats, and date range. It lacks mention of limit and explicit guidance on when to use this vs tg_search, but these are minor gaps given the tool's low complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate. It explains peer (numeric id, @username, 'me') and since/until (YYYY-MM-DD), but omits limit entirely. Three of four parameters receive partial or full semantic context, but limit's meaning is left to inference from its name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function with a specific verb ('Read') and resource ('messages from a chat'), and adds ordering detail ('oldest first'). This distinguishes it from sibling tools like tg_send_message and tg_search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides useful context for usage: what 'peer' can be, and the date format for since/until. However, it does not explicitly contrast this with tg_search or state when to choose one over the other, so it lacks explicit exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tg_send_fileA

SEND a file to a Telegram chat, with an optional caption. Delivers immediately and cannot be unsent by this server. Use 'me' for Saved Messages.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
peerYes
captionNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It clearly states that delivery is immediate and irreversible by this server, which is critical for a send operation. Other traits like file size limits or path requirements are not mentioned, but the irreversibility is a strong and relevant disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with the key action, followed by essential behavioral and usage notes. Every sentence earns its place without redundancy, making it highly scannable for an AI agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has no annotations and no schema descriptions, so the description must cover a lot. It covers the core purpose, a key behavior (irreversible), and a usage tip, but omits details like file path semantics, authentication requirements, or potential errors. The output schema exists, so return values are not needed, but the input context could be richer.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It clarifies 'peer' with 'Use me for Saved Messages' and implies 'path' refers to the file to send, while 'caption' is optional. However, it does not explain the format or source of the path (e.g., local filesystem, URL), leaving some ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'SEND a file to a Telegram chat' with a clear verb and resource, and highlights optional caption support. This distinguishes it from siblings like tg_send_message (text) and tg_download_media (download), making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides useful context on when to use the tool: it sends files with immediate delivery and cannot be unsent, plus a specific tip for Saved Messages. However, it does not explicitly compare to alternatives like tg_send_message or mention when not to use it, but the context is sufficient for basic usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tg_send_messageA

SEND a text message to a Telegram chat. This delivers immediately to a real person and cannot be unsent by this server. Use 'me' to write to Saved Messages.

ParametersJSON Schema
NameRequiredDescriptionDefault
peerYes
textYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses key behavioral traits: immediate delivery, irreversibility, and the 'me' alias for Saved Messages. This is significant for a send operation and helps the agent understand consequences, though it does not address potential errors or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three concise sentences, each serving a distinct purpose: stating the action, noting the consequence, and giving a special usage tip. It is front-loaded with the main action and contains no superfluous words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple text-send tool, the description covers the core purpose, immediate delivery, irreversibility, and the 'me' special value. An output schema exists, so return values need not be described. The only notable gap is the lack of detailed peer format guidance, but overall it is adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has zero coverage (no descriptions for peer or text). The description compensates partially by explaining the special 'me' value for peer, but it does not clarify acceptable formats for peer or any constraints on text. This leaves ambiguity in parameter usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool sends a text message to a Telegram chat, using the explicit verb 'SEND' and identifying the resource. This distinguishes it from sibling tools like tg_send_file (file) and tg_read_chat (read), and the mention of 'real person' and 'Saved Messages' adds essential context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context that this tool delivers immediately to a real person and cannot be unsent, implying suitable use cases. It also provides a usage tip for the 'me' peer value. However, it does not explicitly mention alternatives or when not to use this tool versus tg_send_file, so it falls short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tg_whoamiA

Which Telegram account this server is signed in as.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the purpose without mentioning whether the operation has side effects, requires authentication, or handles errors (e.g., no signed-in account). This minimal disclosure falls short of what is needed for a tool with zero annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that front-loads the core function. It avoids extraneous words or redundant phrasing, earning a perfect score for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema details needed since it exists), the description is largely complete. However, it could benefit from a hint about the return value (e.g., account info) even though the output schema exists, but for a whoami tool the purpose is clear enough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the baseline for parameter semantics is 4. The description correctly omits parameter details, as there are none to explain, and the schema already confirms the empty parameter set.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: identifying which Telegram account the server is signed in as. This specific verb+resource (identify current account) distinguishes it from sibling tools like tg_send_message or tg_list_chats, making its function unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit when-to-use guidance is provided, but the tool's purpose is self-evident for checking the current account identity. There are no alternative tools that serve a similar purpose, so the usage context is implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.1/5.0
Disambiguation5/5

Each tool targets a distinct action: listing chats, reading messages, searching, downloading media, sending text, sending files, and identifying the account. There is no overlap, and the boundaries between tools are clear.

Naming Consistency4/5

All tools share the 'tg_' prefix and most follow a verb_noun pattern (list_chats, read_chat, download_media, send_message, send_file). Two exceptions are 'search' (verb only) and 'whoami' (question format), which are minor deviations from the otherwise consistent pattern.

Tool Count5/5

Seven tools is well-scoped for a Telegram server, covering core operations without being either too sparse or overly heavy. Each tool has a clear purpose and earns its place in the set.

Completeness4/5

The set covers the primary Telegram workflows: discovering chats, reading and searching messages, downloading media, sending text and files, and checking account identity. Minor gaps like message editing/deletion or chat management exist, but they are not critical for the server's apparent purpose.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    B
    quality
    D
    maintenance
    An MCP server that enables interaction with Telegram messaging platform, allowing users to retrieve unread messages, fetch entity information, and send messages through natural language interfaces.
    6
    10
  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that enables interaction with Telegram to send, read, and search messages across chats and dialogs. It supports waiting for incoming messages and retrieving conversation history through natural language commands.
    14
    4
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    MCP server that exposes a Telegram bot, enabling sending messages and retrieving updates through natural language.
    3
    1
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    An MCP server that connects to Telegram as your real user account and exposes read-only tools to read and search messages, list chats and folders, inspect group info, and download media.
    13
    MIT

Latest Blog Posts

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/Abdk4Moura/tg-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server