Skip to main content
Glama
wowjinxy
by wowjinxy

read_messages

Retrieve recent messages from a Discord channel to monitor conversations, review discussions, or gather information for analysis.

Instructions

Read recent messages from a channel.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'read_messages' tool. Fetches recent messages from the specified Discord channel, processes reactions, formats the output with author, timestamp, content, and reactions, and returns as TextContent.
    @staticmethod
    async def handle_read_messages(discord_client, arguments: Dict[str, Any]) -> List[TextContent]:
        """Read recent messages from a channel"""
        channel = await discord_client.fetch_channel(int(arguments["channel_id"]))
        limit = min(int(arguments.get("limit", 10)), 100)
        
        messages = []
        async for message in channel.history(limit=limit):
            reaction_data = []
            for reaction in message.reactions:
                emoji_str = str(reaction.emoji.name) if hasattr(reaction.emoji, 'name') and reaction.emoji.name else str(reaction.emoji.id) if hasattr(reaction.emoji, 'id') else str(reaction.emoji)
                reaction_info = {
                    "emoji": emoji_str,
                    "count": reaction.count
                }
                reaction_data.append(reaction_info)
            
            messages.append({
                "id": str(message.id),
                "author": str(message.author),
                "content": message.content,
                "timestamp": message.created_at.strftime('%Y-%m-%d %H:%M:%S'),
                "reactions": reaction_data
            })
        
        def format_reaction(r):
            return f"{r['emoji']}({r['count']})"
        
        formatted_messages = []
        for m in messages:
            reactions_str = ', '.join([format_reaction(r) for r in m['reactions']]) if m['reactions'] else 'No reactions'
            formatted_messages.append(
                f"**{m['author']}** ({m['timestamp']}): {m['content']}\n"
                f"   Reactions: {reactions_str}"
            )
        
        return [TextContent(
            type="text",
            text=f"**Recent messages from #{channel.name}** ({len(messages)} messages):\n\n" + 
                 "\n\n".join(formatted_messages)
        )]
  • JSON schema defining the input parameters for the 'read_messages' tool: required 'channel_id' (string) and optional 'limit' (number, 1-100). This is part of the tool registration in list_tools().
    Tool(
        name="read_messages",
        description="Read recent messages from a channel with reactions",
        inputSchema={
            "type": "object",
            "properties": {
                "channel_id": {
                    "type": "string",
                    "description": "Discord channel ID"
                },
                "limit": {
                    "type": "number",
                    "description": "Number of messages to fetch (max 100)",
                    "minimum": 1,
                    "maximum": 100
                }
            },
            "required": ["channel_id"]
        }
    ),
  • Registration and routing logic for core tools including 'read_messages'. Checks if the tool name is in core_tool_names and dynamically calls the corresponding handler method on CoreToolHandlers.
    core_tool_names = [
        "get_server_info", "list_servers", "get_channels", "list_members",
        "get_user_info", "send_message", "read_messages", "add_reaction",
        "add_multiple_reactions", "remove_reaction", "moderate_message",
        "create_text_channel", "delete_channel", "add_role", "remove_role"
    ]
    
    if name in core_tool_names:
        handler_method = f"handle_{name}"
        if hasattr(CoreToolHandlers, handler_method):
            return await getattr(CoreToolHandlers, handler_method)(discord_client, arguments)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states this is a read operation, implying it's non-destructive, but doesn't cover critical aspects like authentication requirements, rate limits, pagination behavior (beyond the 'limit' parameter), error conditions, or whether it returns messages in chronological order. The mention of 'recent' is vague and unhelpful for an agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence with no wasted words. It's front-loaded with the core action ('Read recent messages'), making it easy to parse. Every part of the sentence contributes to understanding the tool's basic function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there's an output schema (which should define return values), the description doesn't need to explain outputs. However, for a read operation with 2 parameters and no annotations, the description is too minimal—it lacks context on permissions, behavior, or parameter details. It's barely adequate as a starting point but leaves significant gaps for an agent to infer usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning parameter titles ('Channel Id', 'Limit') provide no semantic context. The description adds no information about parameters—it doesn't explain what 'channel_id' represents (e.g., a Discord channel ID), what format it expects (string vs. integer), or how 'limit' interacts with 'recent' (e.g., whether it caps results or defines a timeframe). This fails to compensate for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Read') and resource ('recent messages from a channel'), making the tool's function immediately understandable. However, it doesn't distinguish this tool from potential siblings like 'get_channels' or 'list_members' that might also retrieve channel-related data, nor does it specify what 'recent' means in terms of timeframe or ordering.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_channels' (which might list channels) and 'send_message' (which writes to channels), there's no indication of whether this is for viewing message history, monitoring activity, or other use cases. No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/wowjinxy/mcp-discord'

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