Skip to main content
Glama

discord_search_messages

Search Discord channel messages by keyword to find specific conversations or information within recent message history.

Instructions

Search messages in a channel by keyword (scans up to last 100 messages).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYes
keywordYes
limitNoMax messages to scan (default 100).

Implementation Reference

  • The handler implementation for the `discord_search_messages` tool, which fetches recent messages from a channel and filters them by a provided keyword.
    case "discord_search_messages": {
      const channel = await getTextChannel(args.channel_id as string);
      const limit = Math.min(Math.max(Number(args.limit ?? 100), 1), 100);
      const messages = await channel.messages.fetch({ limit });
      const keyword = (args.keyword as string).toLowerCase();
      const matches = [...messages.values()]
        .filter((m) => m.content.toLowerCase().includes(keyword))
        .sort((a, b) => a.createdTimestamp - b.createdTimestamp)
        .map((m) => ({ id: m.id, author: m.author.tag, content: m.content, timestamp: m.createdAt.toISOString() }));
      return { content: [{ type: "text", text: matches.length > 0 ? JSON.stringify(matches, null, 2) : `No messages found containing "${args.keyword}" in the last ${limit} messages.` }] };
    }
  • The schema definition for the `discord_search_messages` tool.
    {
      name: "discord_search_messages",
      description: "Search messages in a channel by keyword (scans up to last 100 messages).",
      inputSchema: {
        type: "object",
        properties: {
          channel_id: { type: "string" },
          keyword: { type: "string" },
          limit: { type: "number", description: "Max messages to scan (default 100)." },
        },
        required: ["channel_id", "keyword"],
      },
    },

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

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