Skip to main content
Glama
Andrei-Blagov

currency-bot-db

Currency MCP Bot (educational project)

A simple example of combining Telegram Bot + public API + Docker/PostgreSQL + MCP + Cursor.

Diagram

Telegram
   ↓
Python Bot
   ↓
API курса валют

Python Bot
   ↓
PostgreSQL
   ↑
   MCP
   ↑
Cursor

Related MCP server: postgres-mcp

What the Telegram Bot does here

It accepts the /start, /usd, /eur, /cny commands and replies with the currency exchange rate to the ruble.

What the API does here

The bot fetches the current rate from a free public API (open.er-api.com) — no key and no registration required.

What Docker does here

docker compose starts PostgreSQL in a container. The bot itself runs locally on Python.

What MCP does here

The MCP server gives Cursor two tools for the same database:

  1. get_recent_requests — recent user requests

  2. get_currency_stats — how many times USD / EUR / CNY were requested

Files

File

Purpose

bot.py

Telegram bot (aiogram)

db.py

PostgreSQL without ORM

mcp_server.py

MCP server for Cursor

docker-compose.yml

PostgreSQL in Docker

.cursor/mcp.json

MCP connection in this project

.env

Secrets and settings (not in Git)

Quick Start

1. Python dependencies

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt

2. Environment variables

Copy the example and paste the bot token:

copy .env.example .env

In .env, fill in:

TELEGRAM_BOT_TOKEN=ваш_токен_от_BotFather

3. PostgreSQL via Docker

docker compose up -d

Check:

docker compose ps

4. Starting the bot

python bot.py

In Telegram, send the bot /start, then /usd, /eur, /cny.

5. MCP in Cursor

The project includes .cursor/mcp.json. On Windows, the server is also added to the user-level ~/.cursor/mcp.json so that it definitely appears in the Connected list.

  1. First create a venv and install the dependencies (step 1 above)

  2. Ctrl+Shift+PDeveloper: Reload Window

  3. Open Settings → MCP

  4. Find currency-bot-db — the status should be green, tools: get_recent_requests, get_currency_stats

If the server is missing or the status is red: check PostgreSQL (docker compose ps) and that .venv is installed.

Where to get a Telegram Bot Token

  1. Open Telegram and find @BotFather

  2. Send /newbot

  3. Come up with a name and username for the bot

  4. BotFather will send a token like 123456:ABC...

  5. Paste it into .env as TELEGRAM_BOT_TOKEN=...

Don't commit the token to Git — the .env file is already in .gitignore.

Test requests to MCP in Cursor

After sending the bot a few commands, type in the Cursor chat:

  • “Show the recent user requests”

  • “Which currencies did users request most often?”

  • “Call get_recent_requests with limit=5”

  • “Call get_currency_stats”

Cursor should use the MCP tools get_recent_requests and get_currency_stats.

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    D
    maintenance
    Enables querying PostgreSQL database metadata including table lists and schema information through the MCP protocol. Supports stdio transport for Cursor/IDE integration as well as HTTP transport with health check endpoints.
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for PostgreSQL that enables Cursor and other MCP clients to execute SQL queries, list tables, and explore database schemas via HTTP.
    2,120 npm
    MIT
  • F
    license
    Not graded
    quality
    F
    maintenance
    Provides read-only SQL query access to Postgres and DuckDB databases via MCP tools, with extensive security hardening for public endpoints.
    1
    -
  • F
    license
    A
    quality
    D
    maintenance
    Enables querying and interacting with PostgreSQL databases using natural language through MCP. Supports configuration via environment variables and Cursor IDE integration.
    3
    -