Skip to content

feat: upgrade to v0.3.0 with PostgreSQL sessions, daemon mode and setup wizard#9

Open
imdeniil wants to merge 8 commits into
dryeab:mainfrom
imdeniil:main
Open

feat: upgrade to v0.3.0 with PostgreSQL sessions, daemon mode and setup wizard#9
imdeniil wants to merge 8 commits into
dryeab:mainfrom
imdeniil:main

Conversation

@imdeniil
Copy link
Copy Markdown

Description

This PR upgrades mcp-telegram to v0.3.0, introducing several major features and stability improvements:

  1. PostgreSQL Session Backend: Replaced SQLite with PostgreSQL to support multi-terminal access without session locks.
  2. Daemon Mode: A centralized Telegram connection that multiple MCP servers can share.
  3. Interactive Setup Wizard: New mcp-telegram setup command that automates database creation, migrations, and Docker integration.
  4. Reliability Fixes:
    • Fixed access_hash errors by syncing entity caches.
    • Fixed resource leaks and race conditions in session saving.
    • Added automatic schema migrations on startup.

Changes

  • New PostgresSession class in session.py.
  • Rewritten daemon.py with robust API and lifecycle management.
  • Integrated Docker Compose support.
  • Updated CLI with setup wizard and improved error handling.

- Add Telegram daemon for shared connection across multiple terminals
- Replace SQLite with PostgreSQL for session storage (PostgresSession)
- Add Docker Compose setup with PostgreSQL and daemon containers
- Add HTTP proxy client for MCP servers to communicate with daemon
- Add interactive setup wizard (mcp-telegram setup)
- Add new CLI commands: daemon, start --daemon, setup
- Add database migrations for schema initialization
- Update README with daemon mode documentation

Architecture:
  MCP Terminal 1 ─┐
  MCP Terminal 2 ─┼──▶ Telegram Daemon ──▶ PostgreSQL
  MCP Terminal N ─┘           │
                               ▼
                          Telegram

This allows multiple AI agents/terminals to share a single Telegram
connection without re-authentication or session conflicts.
- setup: auto-create database and run migrations
- setup: better error messages and instructions
- login: support PostgreSQL mode when DATABASE_URL is set
- login: create account in database if not exists
- login: update account with user info after auth
- Add test_chain.sh for verification
- setup creates database + runs migrations
- Authenticates with Telegram
- Optionally starts daemon
- Provides final instructions

This wizard will:
1. Configure PostgreSQL database (create + migrate)
2. Set Telegram API credentials
3. Authenticate with Telegram
4. Optionally start daemon
- Split setup into sync wrapper and async implementation
- Fix daemon startup outside of async context
- Update README with simplified setup instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant