Skip to main content
Glama
jar285

MCP-Discord

by jar285

discord_read_messages

Retrieve messages from Discord text channels to monitor conversations, analyze discussions, or gather information with configurable limits.

Instructions

Retrieves messages from a Discord text channel with a configurable limit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
limitNo

Implementation Reference

  • Handler function that fetches messages from a specified Discord channel using the discord.js client, validates input with ReadMessagesSchema, formats message details including author, timestamp, attachments, embeds, and replies, sorts them chronologically, and returns formatted JSON response.
    case "discord_read_messages": {
      const { channelId, limit } = ReadMessagesSchema.parse(args);
      try {
        if (!client.isReady()) {
          return {
            content: [{ type: "text", text: "Discord client not logged in. Please use discord_login tool first." }],
            isError: true
          };
        }
    
        const channel = await client.channels.fetch(channelId);
        if (!channel) {
          return {
            content: [{ type: "text", text: `Cannot find channel with ID: ${channelId}` }],
            isError: true
          };
        }
    
        // Check if channel has messages (text channel, thread, etc.)
        if (!channel.isTextBased() || !('messages' in channel)) {
          return {
            content: [{ type: "text", text: `Channel type does not support reading messages` }],
            isError: true
          };
        }
    
        // Fetch messages
        const messages = await channel.messages.fetch({ limit });
        
        if (messages.size === 0) {
          return {
            content: [{ type: "text", text: `No messages found in channel` }]
          };
        }
    
        // Format messages 
        const formattedMessages = messages.map(msg => ({
          id: msg.id,
          content: msg.content,
          author: {
            id: msg.author.id,
            username: msg.author.username,
            bot: msg.author.bot
          },
          timestamp: msg.createdAt,
          attachments: msg.attachments.size,
          embeds: msg.embeds.length,
          replyTo: msg.reference ? msg.reference.messageId : null
        })).sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
    
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({
              channelId,
              messageCount: formattedMessages.length,
              messages: formattedMessages
            }, null, 2) 
          }]
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Failed to read messages: ${error}` }],
          isError: true
        };
      }
    }
  • Zod schema used for input validation in the discord_read_messages handler, defining channelId as required string and limit as optional number between 1-100 defaulting to 50.
    const ReadMessagesSchema = z.object({
        channelId: z.string(),
        limit: z.number().min(1).max(100).optional().default(50)
    });
  • JSON schema for input validation exposed via the MCP ListTools endpoint for the discord_read_messages tool.
    inputSchema: {
      type: "object",
      properties: {
        channelId: { type: "string" },
        limit: {
          type: "number",
          minimum: 1,
          maximum: 100,
          default: 50
        }
      },
      required: ["channelId"]
    }
  • src/index.ts:303-319 (registration)
    Tool registration in the ListTools response array, defining name, description, and input schema for discord_read_messages.
    {
      name: "discord_read_messages",
      description: "Retrieves messages from a Discord text channel with a configurable limit",
      inputSchema: {
        type: "object",
        properties: {
          channelId: { type: "string" },
          limit: {
            type: "number",
            minimum: 1,
            maximum: 100,
            default: 50
          }
        },
        required: ["channelId"]
      }
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions a 'configurable limit' but fails to detail critical aspects like rate limits, authentication requirements, pagination behavior, or error handling. This leaves significant gaps for a read operation in a messaging platform.

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, efficient sentence that front-loads the core action ('retrieves messages') without unnecessary details. It is appropriately sized for a simple retrieval tool, with zero wasted words.

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

Completeness2/5

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

Given the complexity of a Discord API tool with no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks information on return values (e.g., message format), error cases, or integration context, making it insufficient for reliable agent use.

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

Parameters3/5

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

The description adds minimal value beyond the input schema, which has 0% description coverage. It implies 'limit' controls the number of messages retrieved but does not explain 'channelId' semantics (e.g., format or source). With low schema coverage, the description partially compensates but remains inadequate for full parameter understanding.

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 ('retrieves') and resource ('messages from a Discord text channel'), making the purpose evident. However, it does not explicitly differentiate from sibling tools like 'discord_get_forum_post' or 'discord_get_server_info', which also retrieve data but target different resources.

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, such as 'discord_get_forum_post' for forum messages or 'discord_send' for sending messages. It lacks context about prerequisites (e.g., needing channel access) or exclusions, leaving usage unclear.

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

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