Skip to main content
Glama

agent_read_inbox

Reads incoming messages and room events from the agentlink server, with options to limit results, mark as read, or clear after reading.

Instructions

Baca pesan masuk dan event room (join/leave).

Args: params: limit (default 10), clear (hapus setelah dibaca) Returns: str: JSON daftar pesan dan event

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The main handler function for 'agent_read_inbox' tool. Reads incoming messages and room events, supports filtering unread messages, marking messages as read, and optionally clearing the inbox. Returns JSON with messages, counts, and read status metadata.
    @mcp.tool(name="agent_read_inbox")
    async def agent_read_inbox(params: ReadInboxInput) -> str:
        """
        Baca pesan masuk dan event room (join/leave).
    
        Args:
            params: limit (default 10), clear (hapus setelah dibaca)
        Returns:
            str: JSON daftar pesan dan event
        """
        room_last_read = _safe_int(current_room.get("last_read_sequence")) if current_room else 0
        visible_messages = inbox
        if params.only_unread:
            visible_messages = [
                message
                for message in inbox
                if not isinstance(message, dict)
                or not isinstance(message.get("sequence"), int)
                or message.get("sequence", 0) > room_last_read
            ]
        messages = visible_messages[-params.limit:]
        max_sequence = _max_message_sequence(messages)
        if params.mark_read and current_room is not None and max_sequence > room_last_read:
            current_room["last_read_sequence"] = max_sequence
            room_last_read = max_sequence
        if params.clear:
            inbox.clear()
        if current_room is not None:
            current_room["local_cached_message_count"] = len(inbox)
        _persist_local_room_state()
        unread_count = len([
            message for message in inbox
            if isinstance(message, dict)
            and isinstance(message.get("sequence"), int)
            and message.get("sequence", 0) > room_last_read
        ])
        return json.dumps({"messages": messages, "count": len(messages),
            "total_in_inbox": len(inbox), "cleared": params.clear,
            "only_unread": params.only_unread, "mark_read": params.mark_read,
            "last_read_sequence": room_last_read,
            "unread_count": unread_count,
            "cache_path": current_room.get("local_cache_path") if current_room else None}, indent=2)
  • Input schema for agent_read_inbox tool using Pydantic BaseModel. Defines parameters: limit (1-100 messages), only_unread (filter by read status), mark_read (update read cursor), and clear (delete after reading).
    class ReadInboxInput(BaseModel):
        model_config = ConfigDict(extra="forbid")
        limit: int  = Field(default=10, ge=1, le=100, description="Jumlah pesan")
        only_unread: bool = Field(default=False, description="True = hanya tampilkan pesan di atas cursor baca lokal")
        mark_read: bool = Field(default=True, description="True = simpan cursor baca lokal dari hasil yang dibaca")
        clear: bool = Field(default=False, description="Hapus setelah dibaca")
  • Tool registration using @mcp.tool decorator with name='agent_read_inbox', registering the handler function with the FastMCP server instance.
    @mcp.tool(name="agent_read_inbox")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/syuaibsyuaib/ssyubix-agentlink'

If you have feedback or need assistance with the MCP directory API, please join our Discord server