agentleFS
arlanrakharlanrakh/talk-to-girlfriend-ai/CLAUDE.md

talk-to-girlfriend-ai

CLAUDE.md546 starsChanged 20 months agoApache-2.0View on GitHub

Telegram MCP Server - a full-featured Telegram integration for Claude, Cursor, and MCP-compatible clients. Uses Telethon for Telegram API access and exposes 60+ tools via the Model Context Protocol. Required in .env: - TELEGRAM_API_ID - from my.telegram.org/apps - TELEGRAM_API_HASH - from my.telegram.org/apps - TELEGRAM_SESSION_STRING (preferred) or TELEGRAM_SESSION_NAME (file-based) For TypeScript agent: - AI_GATEWAY_API_KEY - Vercel AI Gateway key - NIA_API_KEY - Nia API key - TELEGRAM_API_URL - HTTP bridge URL (default: http://localhost:8765)

  • Reads credentials

The file

We split this CLAUDE.md into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All functions accept flexible ID formats:

    line 65
  2. Very specific:

    Use Union[int, str] for ID parameters

    line 74

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

Telegram MCP Server - a full-featured Telegram integration for Claude, Cursor, and MCP-compatible clients. Uses Telethon for Telegram API access and exposes 60+ tools via the Model Context Protocol.

Commands

MCP Server (Python)

# Install dependencies
uv sync

# Run the MCP server
uv run main.py

# Generate Telegram session string
uv run session_string_generator.py

# Format code
black .

# Lint code
flake8 .

Run Tests

# Run validation tests
pytest test_validation.py -v

TypeScript Agent (in agent/)

cd agent
bun install
bun run dev

Docker

docker build -t telegram-mcp:latest .
docker compose up --build

Architecture

MCP Server (main.py)

Single-file MCP server exposing Telegram functionality as tools. Key components:

  • FastMCP("telegram") - MCP server instance
  • TelegramClient - Telethon client (supports both string and file-based sessions)
  • @mcp.tool() decorated functions - 60+ tools for chat, messaging, contacts, admin, media operations
  • @validate_id() decorator - validates chat_id/user_id parameters (accepts int, string int, or @username)
  • log_and_format_error() - centralized error handling with error codes logged to mcp_errors.log

TypeScript Agent (agent/)

CLI agent using Claude Sonnet via Vercel AI Gateway. Communicates with Telegram through an HTTP bridge:

  • telegram_api.py - FastAPI HTTP bridge exposing Telethon via REST (runs on port 8765)
  • agent/src/agent.ts - AI agent using @ai-sdk/gateway
  • agent/src/tools/ - Tool definitions (telegram.ts, nia.ts, aiify.ts)

ID Validation

All functions accept flexible ID formats:

  • Integer ID: 123456789 or -1001234567890
  • String ID: "123456789"
  • Username: "@username" or "username"

Code Style

  • Python: Black formatter (line-length 99), Flake8 linter
  • Target Python version: 3.10+
  • Use Union[int, str] for ID parameters
  • Error codes follow pattern: {CATEGORY}-ERR-{hash}

Environment Variables

Required in .env:

  • TELEGRAM_API_ID - from my.telegram.org/apps
  • TELEGRAM_API_HASH - from my.telegram.org/apps
  • TELEGRAM_SESSION_STRING (preferred) or TELEGRAM_SESSION_NAME (file-based)

For TypeScript agent:

  • AI_GATEWAY_API_KEY - Vercel AI Gateway key
  • NIA_API_KEY - Nia API key
  • TELEGRAM_API_URL - HTTP bridge URL (default: http://localhost:8765)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.