Skip to main content
Glama
scarecr0w12

discord-mcp

get_pinned_messages

Retrieve all pinned messages from a Discord channel by providing server and channel IDs. This tool helps users access important announcements and saved content in Discord servers.

Instructions

Get all pinned messages in a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel

Implementation Reference

  • The main handler function for the 'get_pinned_messages' tool. It fetches the Discord guild and channel, validates the channel type, retrieves pinned messages using Discord.js fetchPinned(), maps them to a simplified object, wraps in error handling, and returns JSON-formatted response.
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const channel = await guild.channels.fetch(channelId);
    
        if (!isMessageableChannel(channel)) {
          throw new Error('Channel does not support messages');
        }
    
        const pinned = await channel.messages.fetchPinned();
        return pinned.map((msg) => ({
          id: msg.id,
          content: msg.content,
          authorId: msg.author.id,
          authorUsername: msg.author.username,
          createdAt: msg.createdAt.toISOString(),
        }));
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Zod input schema defining required parameters: guildId (string) and channelId (string).
      guildId: z.string().describe('The ID of the server (guild)'),
      channelId: z.string().describe('The ID of the channel'),
    },
    async ({ guildId, channelId }) => {
  • Direct registration of the 'get_pinned_messages' tool on the McpServer using server.tool(), specifying name, description, input schema, and inline handler function.
      'get_pinned_messages',
      'Get all pinned messages in a channel',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        channelId: z.string().describe('The ID of the channel'),
      },
      async ({ guildId, channelId }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const channel = await guild.channels.fetch(channelId);
    
          if (!isMessageableChannel(channel)) {
            throw new Error('Channel does not support messages');
          }
    
          const pinned = await channel.messages.fetchPinned();
          return pinned.map((msg) => ({
            id: msg.id,
            content: msg.content,
            authorId: msg.author.id,
            authorUsername: msg.author.username,
            createdAt: msg.createdAt.toISOString(),
          }));
        });
    
        if (!result.success) {
          return { content: [{ type: 'text', text: result.error }], isError: true };
        }
    
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • src/index.ts:59-59 (registration)
    Top-level call to registerMessageTools(server) within createMcpServer(), which triggers the registration of get_pinned_messages and other message tools.
    registerMessageTools(server);
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 the tool retrieves data ('Get'), implying a read-only operation, but doesn't clarify aspects like whether it requires authentication, returns paginated results, includes metadata, or has rate limits. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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, direct sentence that efficiently conveys the core functionality without unnecessary words. It's front-loaded with the main action and resource, making it easy to parse quickly. Every part of the sentence earns its place by specifying what is being retrieved and where.

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 the tool's low complexity (2 required parameters, no output schema, no annotations), the description is minimally adequate but incomplete. It covers the basic purpose but lacks usage guidelines, behavioral details, and output information. For a read operation in this context, it should ideally mention return format or permissions, but it's not entirely inadequate for such a simple tool.

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 input schema has 100% description coverage, with clear documentation for 'guildId' and 'channelId'. The description adds no additional parameter information beyond what the schema provides, such as format examples or contextual usage. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, but the description doesn't compensate with extra insights.

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 action ('Get') and resource ('all pinned messages in a channel'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this from sibling tools like 'get_messages' or 'unpin_message', which would require mentioning it specifically retrieves only pinned messages rather than all messages or performing an unpin operation.

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. It doesn't mention prerequisites (e.g., needing specific permissions), compare it to similar tools like 'get_messages' for retrieving all messages, or indicate scenarios where pinned messages are relevant (e.g., for finding important announcements).

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

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