MCP ExplorerExplorer

Agents Sdk Telegram

@esakrissaon a year ago
3 MIT
FreeCommunity
AI Systems
Telegram bot using OpenAI Agents SDK and MCP Server.

Overview

What is Agents Sdk Telegram

agents-sdk-telegram is a Telegram bot that utilizes OpenAI’s Agents SDK and Model Context Protocol (MCP) to provide real-time weather information through natural language queries.

Use cases

Use cases include providing current weather updates for specific cities, assisting users in planning travel based on weather conditions, and serving as an educational resource for understanding meteorological data.

How to use

To use agents-sdk-telegram, clone the repository, set up a virtual environment, install dependencies, configure the .env file with your Telegram bot token and OpenAI API key, and run the bot. Users can interact with the bot by sending messages asking about the weather in any city.

Key features

Key features include real-time weather data retrieval using the Open-Meteo API, natural language processing capabilities powered by the GPT-4o-mini model, a simple MCP server implementation for weather data, Telegram-native message formatting, and an easy-to-use interface for weather queries.

Where to use

agents-sdk-telegram can be used in various fields such as weather forecasting, customer service for travel-related inquiries, and educational tools for learning about weather patterns.

Content

Weather Bot with OpenAI Agents SDK

A Telegram bot that provides real-time weather information using OpenAI’s Agents SDK and Model Context Protocol (MCP). The bot can fetch current weather conditions for cities worldwide using natural language queries, powered by GPT-4o-mini model.

Features

  • Real-time weather data using Open-Meteo API
  • Natural language processing with OpenAI Agents SDK (GPT-4o-mini)
  • Simple MCP server implementation for weather data retrieval
  • Telegram-native message formatting
  • Easy-to-use interface with simple weather queries

Technology Stack

  • Python 3.11+
  • OpenAI Agents SDK
  • Model Context Protocol (MCP)
  • python-telegram-bot
  • Open-Meteo API (no API key required)

Quick Start

  1. Clone the repository:
git clone https://github.com/esakrissa/agents-sdk-telegram.git
cd agents-sdk-telegram
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file in the project root:
TELEGRAM_BOT_TOKEN=your_bot_token_here
OPENAI_API_KEY=your_openai_api_key_here
  1. Run the bot:
python main.py

Usage

Simply send a message to the bot asking about weather in any city:

what's the weather in Ubud?

The bot will respond with current weather conditions including:

  • Temperature
  • Weather conditions
  • Wind speed

Architecture

OpenAI Agents SDK Integration

The bot uses OpenAI’s Agents SDK with GPT-4o-mini model to process natural language queries and generate human-like responses. The Agent is configured with specific instructions for handling weather-related queries and maintaining conversation context.

Model Context Protocol (MCP)

The project implements a simple MCP server (weather_mcp.py) that provides the get_weather tool. This demonstrates how to:

  • Create custom MCP tools
  • Handle tool requests and responses
  • Integrate external APIs (Open-Meteo) with MCP

License

MIT © Esa Krissa

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers