Private, local MCP server for Bale (bale.ai) bots: let AI agents read, search and answer messages, ask and wait for replies, and send or download files through the official Bot API.
Talk to your AI agents on Bale, privately. Let Claude, Cursor or Copilot read what people send your Bale bot, keep a searchable history, reply, send files, and ask you a question and wait for your tap, all from your own machine.
Quick start · What it can do · Privacy · Tools · FAQ · فارسی
Agents now run for minutes or hours: deploys, data jobs, research. You want them to tell you when they are done, ask before they do something risky, and take new instructions while you are away from the keyboard. For many people in Iran that phone is running Bale (بله). With bale-mcp the agent does it through your own Bale bot:
You: Run the migration on staging, but ask me on Bale before you touch the users table.
Agent: calls bot_send_message(chat_id=…, text="Migration step 3 alters users (2.1M rows). Go?", buttons=[["Go", "Stop"]]) → bot_wait_for_reply(chat_id=…, after_message_id=3)
{"messages": [{"kind": "button", "text": "Go", "from": "Sepehr", "message_id": 3}], "timed_out": false} Agent: Got your approval. Running step 3 now; I'll message you when it's done.
The tool calls are real; the reply shape is from a live test against tapi.bale.ai on 2026-10-03.
claude mcp add bale -e BALE_BOT_TOKEN=123456789:your-token -e BALE_ALLOWED_CHATS=your-chat-id -- uvx bale-mcp Claude Desktop Settings → Developer → Edit Config, then add:
{ "mcpServers": { "bale": { "command": "uvx", "args": ["bale-mcp"], "env": { "BALE_BOT_TOKEN": "123456789:your-token", "BALE_ALLOWED_CHATS": "your-chat-id" } } } } Cursor Click Install in Cursor above and fill in the two values, or add the Claude Desktop block to ~/.cursor/mcp.json.
Add to .vscode/mcp.json. VS Code asks for the token once and stores it securely:
{ "inputs": [ { "type": "promptString", "id": "bale-token", "description": "Bale bot token", "password": true } ], "servers": { "bale": { "type": "stdio", "command": "uvx", "args": ["bale-mcp"], "env": { "BALE_BOT_TOKEN": "${input:bale-token}", "BALE_ALLOWED_CHATS": "your-chat-id" } } } } Anything else It's a standard stdio MCP server: run uvx bale-mcp, or pip install bale-mcp and run bale-mcp, with BALE_BOT_TOKEN in the environment.
AI agent (Claude, Cursor, Copilot, ...) │ │ MCP over stdio ▼ bale-mcp (runs on your machine) ──▶ ~/.bale-mcp/messages.db local history (SQLite) │ │ HTTPS, official Bot API ▼ tapi.bale.ai ◀──▶ your Bale app Each reading tool first pulls pending updates from Bale (getUpdates) into the local store, then answers from it. Sent messages are stored too, so a chat's history shows both sides.
Chat ids are numbers (they can exceed 32 bits), or @username for public channels and groups when sending.
No. It uses the official Bot API, so it only sees what people send to your bot, and messages in groups and channels the bot is a member of. It cannot log in as you.
No: in testing tapi.bale.ai answered from a foreign (Turkish) exit. If every call fails with "Could not reach tapi.bale.ai", set BALE_MCP_PROXY to an HTTP proxy that can reach it. Normal system proxy variables are ignored on purpose.
The token is wrong or was revoked. Copy it again from @botfather. (Bale answers a bad token with HTTP 403 or 404.)
bot_wait_for_reply returns timed_out: true when nobody answered in time; the agent can call it again. Some MCP clients cancel tool calls after about a minute; use a shorter timeout_seconds there.
Use the full path to uvx (where uvx on Windows, which uvx on macOS/Linux) as command.
npx @modelcontextprotocol/inspector -e BALE_BOT_TOKEN=123456789:your-token uvx bale-mcp Configuration Variable Default Meaning BALE_BOT_TOKEN required Bot token from @botfather BALE_ALLOWED_CHATS unset (all chats) Comma-separated chat ids or @usernames; all other chats are ignored and never messaged BALE_MCP_DB ~/.bale-mcp/messages.db Local history file; :memory: keeps nothing on disk BALE_MCP_PROXY unset HTTP proxy for every request, e.g. http://user:pass@host:port فارسی bale-mcp به دستیار هوش مصنوعی شما (Claude، Cursor، Copilot و ...) اجازه میدهد از طریق بازوی (ربات) بله خودتان پیامها را بخواند، در آنها جستجو کند، پاسخ و فایل بفرستد، و از شما سؤال بپرسد و منتظر جوابتان بماند.
نصب در Claude Code: توکن را از @botfather بگیرید و:
git clone https://github.com/sepehr071/bale-mcp && cd bale-mcp uv sync uv run pytest # offline, against a mocked Bot API uv run pytest -m live # read-only calls with BALE_BOT_TOKEN uv run pytest -m live_send # sends, edits and deletes one message in BALE_TEST_CHAT_ID uv run ruff check . Tools live in src/bale_mcp/bot.py (sending, bot info) and inbox.py (reading, waiting, downloads); store.py is the local SQLite history. Each tool is a typed async function with a docstring that tells the agent when to use it. Issues and PRs are welcome.
Releases: bump the version in pyproject.toml and server.json, then push a v* tag. GitHub Actions tests, publishes to PyPI and the MCP Registry, and creates the GitHub Release.
Unofficial and not affiliated with or endorsed by Bale. It uses Bale's official, public Bot API. Follow Bale's terms, and don't use it to spam people.
ai-agent bale bot human-in-the-loop iran mcp messenger model-context-protocol privacy
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.




