set_chat_title
Update the title of a Telegram group or channel by providing its chat ID and new title.
Instructions
Change the title of a group or channel.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes | ||
| title | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| error | No | ||
| new_title | No |
Implementation Reference
- aiogram_mcp/tools/chats.py:197-225 (handler)The actual handler function for the 'set_chat_title' tool. It checks if the chat is allowed, calls ctx.bot.set_chat_title(), and returns a SetChatTitleResult.
async def set_chat_title(chat_id: int, title: str) -> SetChatTitleResult: """Change the title of a group or channel.""" if not ctx.is_chat_allowed(chat_id): result = SetChatTitleResult(ok=False, error=f"Chat {chat_id} is not allowed.") if ctx.audit_logger: ctx.audit_logger.log( "set_chat_title", {"chat_id": chat_id, "title": title}, result.ok, result.error, ) return result try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() await ctx.bot.set_chat_title(chat_id=chat_id, title=title) result = SetChatTitleResult(ok=True, new_title=title) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = SetChatTitleResult(ok=False, error=str(exc)) if ctx.audit_logger: ctx.audit_logger.log( "set_chat_title", {"chat_id": chat_id, "title": title}, result.ok, result.error, ) return result - aiogram_mcp/tools/chats.py:38-39 (schema)Pydantic model defining the output schema for the set_chat_title tool, with a 'new_title' field.
class SetChatTitleResult(ToolResponse): new_title: str | None = None - aiogram_mcp/tools/chats.py:194-195 (registration)Registration of the tool via @mcp.tool decorator, gated by allowed_tools check inside register_chat_tools().
if allowed_tools is None or "set_chat_title" in allowed_tools: - aiogram_mcp/server.py:90-90 (registration)Call from AiogramMCP._register_tools() that wires register_chat_tools to the MCP server.
register_chat_tools(self._mcp, self._ctx, allowed_tools=at) - aiogram_mcp/permissions.py:46-52 (helper)Permission mapping: set_chat_title requires MODERATION level.
"set_chat_title": PermissionLevel.MODERATION, "set_chat_description": PermissionLevel.MODERATION, # admin (3 tools) "broadcast": PermissionLevel.ADMIN, "subscribe_events": PermissionLevel.ADMIN, "unsubscribe_events": PermissionLevel.ADMIN, }