Note: This is the initial version of the project. We welcome contributions and feedback!
An extensible Telegram bot that uses LLMs (OpenAI or Ollama) and connects to MCP (Model Context Protocol) servers to perform tool‑augmented tasks. This project also includes a web application to easily configure and test MCP servers.
- Install Python dependencies:
pip install -r requirements.txt
- (Optional) For connecting to Smithery.ai servers, it is recommended to install Node.js and
npx.
Configuration is split into two files: .env for secrets and llm_config.json for LLM settings.
a) Create a .env file in the project root for secrets:
# Telegram Bot
TELEGRAM_BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN"
# OpenAI API Key (required if you use openai)
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
# Naver Search MCP server credentials
NAVER_CLIENT_ID="YOUR_NAVER_CLIENT_ID"
NAVER_CLIENT_SECRET="YOUR_NAVER_CLIENT_SECRET"b) Edit llm_config.json for LLM provider settings:
This file configures which LLM provider to use (openai or ollama) and which model to use.
{
"llm_provider": "openai",
"model_name": "gpt-4o-mini",
"ollama_base_url": "http://localhost:11434/v1"
}- When
llm_provideris"openai",OPENAI_API_KEYin.envis used. - When
llm_provideris"ollama", the bot connects to an OpenAI-compatible endpoint atollama_base_url.
mcp_config.json defines the MCP servers the bot will start and connect to. You can configure it in two ways:
- (Recommended) Use the Web Application: A simple way to add, manage, and test MCP servers.
- Manually edit
mcp_config.json: Directly modify the configuration file.
A detailed guide is available in the "Extending the Bot" section below.
We recommend starting the web application first to configure and test your MCP servers.
a) Run the Web Application:
python frontend/app.pyOpen your browser to the local address provided to manage your MCP servers.
b) Run the Telegram Bot:
python main.pyOnce running, open Telegram and send a message to your bot. The active agent will respond using the configured LLM and MCP tools.
The bot operates with a single, powerful agent. This agent connects to the LLM you've configured (either from OpenAI or Ollama) and is equipped with all the tools provided by the MCP servers listed in mcp_config.json. When you send a message, the agent interprets your request, selects the appropriate tool from its available MCP capabilities, and responds accordingly.
You can add any MCP-compatible server. This is particularly easy for servers listed on Smithery.ai.
Method A: Using the Web Application (Recommended)
Start the web app (python frontend/app.py) and use the UI to add or remove MCP server configurations. The changes will be automatically saved to mcp_config.json.
Method B: Manually Editing mcp_config.json
You can add different types of servers:
-
Smithery Servers: Find a server on Smithery and paste its configuration.
{ "mcpServers": [ { "command": "npx", "args": [ "-y", "@smithery/cli@latest", "run", "@upstash/context7-mcp", "--key", "YOUR_SMITHY_KEY" ], "name": "context7-mcp" } ] } -
Remote Servers: Add a server by its name and URL.
{ "name": "sample-mcp-server", "url": "https://sample-mcp-url.io" } -
Local Python Servers: Run a custom server from a local script.
{ "args": ["src/naver_mcp_server.py"], "command": "python", "name": "naver-search-server" }
You can create your own tools by implementing a local MCP server.
- Place your server script under the
src/directory. - Use
src/naver_mcp_server.pyas a reference for implementing the FastMCP interface.
- Application logs are written to stdout and to
logs/bot.log.
- Missing
TELEGRAM_BOT_TOKEN: Set it in your.envfile. LLM_PROVIDER="openai"fails: EnsureOPENAI_API_KEYis set correctly in.env.LLM_PROVIDER="ollama"fails: Make sure a running Ollama instance with an OpenAI-compatible API is available atOLLAMA_BASE_URLand a valid model is specified inllm_config.json.
We are continuously working to improve the Telegram MCP Bot. Here are some features and enhancements planned for future releases:
- Multi-Turn Conversations: Enhancing the agent's ability to remember context from previous interactions for more natural, ongoing conversations.
- Expanded LLM Support: Integrating with a wider variety of LLM providers and models beyond OpenAI and Ollama.
- Fine-Grained LLM Control: Introducing options to adjust detailed LLM parameters such as system prompts, temperature, and more.
- Multi-Agent Architecture: Evolving from a single agent to a multi-agent system, allowing for specialized agents to collaborate on complex tasks.


