Skip to main content
Glama

reply_to_post

Post a reply to an existing Reddit post by providing the post ID and content, enabling direct engagement in discussions.

Instructions

Post a reply to an existing Reddit post

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYesThe ID of the post to reply to
contentYesThe content of the reply
subredditNoThe subreddit name if known (for validation)

Implementation Reference

  • The main tool handler function for 'reply_to_post'. It extracts parameters, gets the Reddit client, calls client.replyToPost, formats the comment info, and returns a success response with details.
    export async function replyToPost(params: {
      post_id: string;
      content: string;
      subreddit?: string;
    }) {
      const { post_id, content, subreddit } = params;
      const client = getRedditClient();
    
      if (!client) {
        throw new McpError(
          ErrorCode.InternalError,
          "Reddit client not initialized"
        );
      }
    
      try {
        console.log(`[Tool] Replying to post ${post_id}`);
        const comment = await client.replyToPost(post_id, content);
        const formattedComment = formatCommentInfo(comment);
    
        return {
          content: [
            {
              type: "text",
              text: `
    # Reply Posted Successfully
    
    ## Comment Details
    - Author: u/${formattedComment.author}
    - Subreddit: r/${formattedComment.context.subreddit}
    - Thread: ${formattedComment.context.thread}
    - Link: ${formattedComment.link}
    
    Your reply has been successfully posted.
              `,
            },
          ],
        };
      } catch (error) {
        console.error(`[Error] Error replying to post: ${error}`);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to reply to post: ${error}`
        );
      }
    }
  • The input schema and metadata for the 'reply_to_post' tool as registered in the listTools response.
      name: "reply_to_post",
      description: "Post a reply to an existing Reddit post",
      inputSchema: {
        type: "object",
        properties: {
          post_id: {
            type: "string",
            description: "The ID of the post to reply to",
          },
          content: {
            type: "string",
            description: "The content of the reply",
          },
          subreddit: {
            type: "string",
            description: "The subreddit name if known (for validation)",
          },
        },
        required: ["post_id", "content"],
      },
    },
  • src/index.ts:464-471 (registration)
    The switch case in the CallToolRequest handler that dispatches 'reply_to_post' calls to the tools.replyToPost function.
    case "reply_to_post":
      return await tools.replyToPost(
        toolParams as {
          post_id: string;
          content: string;
          subreddit?: string;
        }
      );
  • The core RedditClient.replyToPost method that authenticates, checks post existence, makes the API POST to /api/comment, and constructs the RedditComment response object.
    async replyToPost(postId: string, content: string): Promise<RedditComment> {
      await this.authenticate();
    
      if (!this.username || !this.password) {
        throw new Error("User authentication required for posting replies");
      }
    
      try {
        if (!(await this.checkPostExists(postId))) {
          throw new Error(
            `Post with ID ${postId} does not exist or is not accessible`
          );
        }
    
        const params = new URLSearchParams();
        params.append("thing_id", `t3_${postId}`);
        params.append("text", content);
    
        const response = await this.api.post("/api/comment", params, {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded",
          },
        });
    
        // Extract comment data from response
        const commentData = response.data;
        return {
          id: commentData.id,
          author: this.username,
          body: content,
          score: 1,
          controversiality: 0,
          subreddit: commentData.subreddit,
          submissionTitle: commentData.link_title,
          createdUtc: Date.now() / 1000,
          edited: false,
          isSubmitter: false,
          permalink: commentData.permalink,
        };
      } catch (error) {
        console.error(`[Error] Failed to reply to post ${postId}:`, error);
        throw new Error(`Failed to reply to post ${postId}`);
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Post a reply' implies a write/mutation operation, it doesn't disclose authentication requirements, rate limits, error conditions, or what happens upon success. For a mutation tool with zero annotation coverage, this minimal description leaves critical behavioral aspects unspecified.

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 communicates the core purpose without any wasted words. It's appropriately sized for a straightforward tool and gets directly to the point. Every word earns its place in this minimal but complete statement of function.

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 this is a mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't address authentication needs, rate limits, error handling, or what the tool returns. With 3 parameters and complex Reddit API interactions likely involved, more context about behavioral expectations would be helpful for an AI agent.

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?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema. It doesn't explain parameter relationships, format requirements, or usage patterns. The baseline of 3 is appropriate when the schema does all the parameter documentation work.

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 ('Post a reply') and target resource ('to an existing Reddit post'), making the purpose immediately understandable. It distinguishes from siblings like 'create_post' by specifying it's for replying rather than creating new posts. However, it doesn't explicitly differentiate from other comment/reply-related tools that might exist.

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 (like authentication), when not to use it, or how it differs from similar operations. With multiple sibling tools available, this lack of contextual guidance is a significant gap.

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