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.
60 lines • 2.03 kB
JavaScript
import { formatToolResponse } from "./types.js";
import { RedditError } from "../../types/reddit.js";
const notificationSchema = {
type: "object",
properties: {
id: { type: "string" },
type: { type: "string" },
author: { type: "string" },
subject: { type: "string" },
body: { type: "string" },
context: { type: "string" },
isNew: { type: "boolean" },
createdUtc: { type: "number" },
formattedTime: { type: "string", format: "date-time" },
},
required: ["id", "type", "author", "body", "isNew", "createdUtc", "formattedTime"],
};
const responseSchema = {
type: "object",
properties: {
status: { type: "string", enum: ["success", "error"] },
message: { type: "string" },
result: {
type: "object",
properties: {
notifications: {
type: "array",
items: notificationSchema,
},
},
required: ["notifications"],
},
},
required: ["status", "message", "result"],
};
export const handleGetNotifications = async (args, { redditService }) => {
try {
const notifications = await redditService.fetchNotifications(args);
return formatToolResponse({
message: `Found ${notifications.length} notifications`,
result: { notifications },
schema: responseSchema,
type: "server",
title: "Get Notifications",
});
}
catch (error) {
return formatToolResponse({
status: "error",
message: `Failed to fetch notifications: ${error instanceof Error ? error.message : "Unknown error"}`,
error: {
type: error instanceof RedditError ? error.type : "API_ERROR",
details: error,
},
type: "server",
title: "Error Fetching Notifications",
});
}
};
//# sourceMappingURL=get-notifications.js.map