Skip to main content
Glama
Andrei-Blagov

currency-bot-db

Currency MCP Bot (학습 프로젝트)

Telegram Bot + 공개 API + Docker/PostgreSQL + MCP + Cursor 연동의 간단한 예제입니다.

구성도

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

Python Bot
   ↓
PostgreSQL
   ↑
   MCP
   ↑
Cursor

Related MCP server: postgres-mcp

여기서 Telegram Bot이 하는 일

/start, /usd, /eur, /cny 명령을 받아 루블 대비 환율로 응답합니다.

여기서 API가 하는 일

봇은 무료 공개 API(open.er-api.com)에서 최신 환율을 요청합니다. 키나 등록이 필요 없습니다.

여기서 Docker가 하는 일

docker compose가 컨테이너에 PostgreSQL을 띄웁니다. 봇 자체는 Python으로 로컬에서 실행됩니다.

여기서 MCP가 하는 일

MCP 서버는 Cursor에 동일한 데이터베이스에 대한 두 가지 도구를 제공합니다:

  1. get_recent_requests — 사용자들의 최근 요청

  2. get_currency_stats — USD / EUR / CNY를 물어본 횟수

파일

파일

용도

bot.py

Telegram 봇 (aiogram)

db.py

ORM 없는 PostgreSQL

mcp_server.py

Cursor용 MCP 서버

docker-compose.yml

Docker의 PostgreSQL

.cursor/mcp.json

이 프로젝트의 MCP 연결

.env

시크릿 및 설정 (Git 미포함)

빠른 시작

1. Python 의존성

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

2. 환경 변수

예시를 복사해 봇 토큰을 붙여넣으세요:

copy .env.example .env

.env에 다음을 입력하세요:

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

3. Docker로 PostgreSQL 실행

docker compose up -d

확인:

docker compose ps

4. 봇 실행

python bot.py

Telegram에서 봇에게 /start를 보낸 다음 /usd, /eur, /cny를 보내세요.

5. Cursor에서 MCP

프로젝트에 .cursor/mcp.json이 있습니다. Windows에서는 서버가 사용자 ~/.cursor/mcp.json에도 추가되어, Connected 목록에 반드시 표시됩니다.

  1. 먼저 venv를 만들고 의존성을 설치하세요(위 1단계).

  2. Ctrl+Shift+P → Developer: Reload Window

  3. Settings → MCP를 여세요.

  4. currency-bot-db를 찾으세요 — 상태가 초록색이어야 하며, 도구: get_recent_requests, get_currency_stats입니다.

서버가 없거나 상태가 빨간색이면 PostgreSQL(docker compose ps) 및 .venv 설치 여부를 확인하세요.

Telegram Bot Token 얻는 방법

  1. Telegram을 열고 @BotFather를 찾으세요.

  2. /newbot을 보내세요.

  3. 봇의 이름과 username을 정하세요.

  4. BotFather가 123456:ABC... 형식의 토큰을 보내줍니다.

  5. .env에 TELEGRAM_BOT_TOKEN=...으로 붙여넣으세요.

토큰을 Git에 커밋하지 마세요 — .env 파일은 이미 .gitignore에 있습니다.

Cursor에서 MCP 테스트 요청

봇에게 여러 명령을 보낸 후 Cursor 채팅에 다음과 같이 입력하세요:

  • «사용자들의 최근 요청을 보여줘»

  • «사용자들이 가장 자주 요청한 통화는 뭐예요?»

  • «get_recent_requests를 limit=5로 호출해줘»

  • «get_currency_stats를 호출해줘»

Cursor는 MCP 도구 get_recent_requests와 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.
    1,195 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
    -
  • A
    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
    MIT