Weather Bot with OpenAI Agents SDK

by esakrissa

166 downloads
Not rated
GitHub

About

Telegram bot using OpenAI Agents SDK and MCP Server.

Details

Author
esakrissa
Downloads
166
Categories
Developer Tools

- Real-time weather via Open-Meteo API (no key required)
- Natural language processing with GPT-4o-mini
- Simple MCP server for weather data retrieval
- Telegram-native message formatting
- Easy-to-use interface with plain text queries

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Weather Bot with OpenAI Agents SDK
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Clone the repository, set up a Python 3.11+ virtual environment, install dependencies, and create a .env file with your Telegram bot token and OpenAI API key. Run python main.py then send a message like "what's the weather in Ubud?" to the bot on Telegram. The bot replies with temperature, conditions, and wind speed.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "weather bot with openai agents sdk": {
            "agents-sdk-telegram": {
                "command": "python",
                "args": [
                    "-m",
                    "venv",
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "agents-sdk-telegram": {
        "command": "python",
        "args": [
            "-m",
            "venv",
            "venv"
        ]
    }
}

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

2. Create and activate a virtual environment:

python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

3. Install dependencies:

pip install -r requirements.txt

4. Create a .env file in the project root:

TELEGRAM_BOT_TOKEN=your_bot_token_here
OPENAI_API_KEY=your_openai_api_key_here

5. 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

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.