UNPKG

systemprompt-mcp-reddit

Version:

A specialized Model Context Protocol (MCP) server that enables you to search, read, and interact with Reddit content, leveraging an AI Agent to help with each operation.

84 lines 2.77 kB
import { formatToolResponse } from "./types.js"; import { RedditError } from "../../types/reddit.js"; import { sendReplySuccessMessage } from "../../constants/tool/send-reply.js"; const replyResponseSchema = { type: "object", properties: { status: { type: "string", enum: ["success", "error"] }, message: { type: "string" }, result: { type: "object", properties: { response: { type: "object", properties: { id: { type: "string" }, parent_id: { type: "string" }, body: { type: "string" }, permalink: { type: "string" }, }, required: ["id", "parent_id", "body", "permalink"], }, }, required: ["response"], }, }, required: ["status", "message", "result"], }; const replyInputSchema = { type: "object", properties: { id: { type: "string", description: "The ID of the parent post or comment to reply to (must start with t1_ for comments or t3_ for posts)", pattern: "^t[1|3]_[a-z0-9]+$", }, text: { type: "string", description: "The markdown text of the reply (max 10000 characters)", maxLength: 10000, }, sendreplies: { type: "boolean", description: "Whether to send reply notifications", default: true, }, }, required: ["id", "text"], }; export const handleSendReply = async (args, { redditService }) => { try { const { id, text } = args; if (!id || !text) { throw new RedditError("id and text are required for sending replies", "VALIDATION_ERROR"); } const params = { id, text, sendreplies: true, }; const response = await redditService.sendReply(params); return formatToolResponse({ message: sendReplySuccessMessage, result: { response, }, schema: replyResponseSchema, type: "server", title: "Send Reddit Reply", }); } catch (error) { return formatToolResponse({ status: "error", message: `Failed to send reply: ${error instanceof Error ? error.message : "Unknown error"}`, error: { type: error instanceof RedditError ? error.type : "API_ERROR", details: error, }, type: "server", title: "Error Sending Reply", }); } }; //# sourceMappingURL=send-reply.js.map