Skip to main content
Glama
jeebus87

reddirect

by jeebus87

Get Saved Items

get_saved_items

Retrieve your saved Reddit posts and comments. Specify the number of items to return.

Instructions

Get your saved Reddit posts and comments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of saved items to return

Implementation Reference

  • The handler function for the 'get_saved_items' tool. It fetches saved Reddit posts/comments from the Reddit API by calling /user/{username}/saved.json, maps the response into a structured list (id, type, title, author, subreddit, score, permalink, body), and returns the result as JSON text.
    server.registerTool(
      "get_saved_items",
      {
        title: "Get Saved Items",
        description: "Get your saved Reddit posts and comments.",
        inputSchema: z.object({
          limit: z.number().int().min(1).max(100).default(25).describe("Number of saved items to return"),
        }),
      },
      async ({ limit }) => {
        try {
          const username = client.getUsername();
          const data = await client.getJson(
            `/user/${username}/saved.json?limit=${limit}`
          );
          const items = (data?.data?.children || []).map((c: any) => {
            const d = c.data;
            return {
              id: d.name,
              type: c.kind === "t1" ? "comment" : "post",
              title: d.title || d.link_title || null,
              author: d.author,
              subreddit: d.subreddit,
              score: d.score,
              permalink: `${BASE_URL}${d.permalink}`,
              body: d.body || d.selftext || null,
            };
          });
          return {
            content: [
              { type: "text" as const, text: JSON.stringify({ saved_items: items }, null, 2) },
            ],
          };
        } catch (error) {
          return {
            content: [
              { type: "text" as const, text: `Error getting saved items: ${error instanceof Error ? error.message : String(error)}` },
            ],
            isError: true,
          };
        }
      }
    );
  • The input schema for 'get_saved_items' defines a single optional 'limit' parameter (integer 1-100, default 25).
    inputSchema: z.object({
      limit: z.number().int().min(1).max(100).default(25).describe("Number of saved items to return"),
    }),
  • The 'register' function in src/tools/save.ts registers 'get_saved_items' (along with 'save_item' and 'unsave_item') on the MCP server. It is called from src/index.ts line 31.
    export function register(server: McpServer, client: RedditClient): void {
      server.registerTool(
        "save_item",
        {
          title: "Save Post or Comment",
          description: "Save a Reddit post or comment to your saved items list.",
          inputSchema: z.object({
            url: z.string().describe("Full Reddit URL of the post or comment to save"),
          }),
        },
        async ({ url }) => {
          try {
            const thingId = extractThingId(url);
            if (!thingId) {
              return {
                content: [{ type: "text" as const, text: "Could not extract ID from URL." }],
                isError: true,
              };
            }
            await client.post("/api/save", { id: thingId });
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ success: true, id: thingId, saved: true }, null, 2),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                { type: "text" as const, text: `Error saving: ${error instanceof Error ? error.message : String(error)}` },
              ],
              isError: true,
            };
          }
        }
      );
    
      server.registerTool(
        "unsave_item",
        {
          title: "Unsave Post or Comment",
          description: "Remove a Reddit post or comment from your saved items list.",
          inputSchema: z.object({
            url: z.string().describe("Full Reddit URL of the post or comment to unsave"),
          }),
        },
        async ({ url }) => {
          try {
            const thingId = extractThingId(url);
            if (!thingId) {
              return {
                content: [{ type: "text" as const, text: "Could not extract ID from URL." }],
                isError: true,
              };
            }
            await client.post("/api/unsave", { id: thingId });
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ success: true, id: thingId, unsaved: true }, null, 2),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                { type: "text" as const, text: `Error unsaving: ${error instanceof Error ? error.message : String(error)}` },
              ],
              isError: true,
            };
          }
        }
      );
    
      server.registerTool(
        "get_saved_items",
        {
          title: "Get Saved Items",
          description: "Get your saved Reddit posts and comments.",
          inputSchema: z.object({
            limit: z.number().int().min(1).max(100).default(25).describe("Number of saved items to return"),
          }),
        },
        async ({ limit }) => {
          try {
            const username = client.getUsername();
            const data = await client.getJson(
              `/user/${username}/saved.json?limit=${limit}`
            );
            const items = (data?.data?.children || []).map((c: any) => {
              const d = c.data;
              return {
                id: d.name,
                type: c.kind === "t1" ? "comment" : "post",
                title: d.title || d.link_title || null,
                author: d.author,
                subreddit: d.subreddit,
                score: d.score,
                permalink: `${BASE_URL}${d.permalink}`,
                body: d.body || d.selftext || null,
              };
            });
            return {
              content: [
                { type: "text" as const, text: JSON.stringify({ saved_items: items }, null, 2) },
              ],
            };
          } catch (error) {
            return {
              content: [
                { type: "text" as const, text: `Error getting saved items: ${error instanceof Error ? error.message : String(error)}` },
              ],
              isError: true,
            };
          }
        }
      );
    }
  • Helper utility in the same file used by 'save_item' and 'unsave_item' to extract Reddit thing IDs from URLs. Not directly used by 'get_saved_items' but part of the same save.ts module.
    function extractThingId(url: string): string | null {
      const commentMatch = url.match(
        /\/comments\/[a-z0-9]+\/[^/]*\/([a-z0-9]+)/i
      );
      if (commentMatch) return `t1_${commentMatch[1]}`;
      const postMatch = url.match(/\/comments\/([a-z0-9]+)/i);
      if (postMatch) return `t3_${postMatch[1]}`;
      return null;
    }
Behavior2/5

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

With no annotations present, the description carries the full burden of behavioral disclosure. It only states the basic action without revealing side effects (e.g., read-only, no destructive behavior), authentication requirements, rate limits, or pagination behavior. The description adds minimal value beyond the name.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single short sentence that conveys the purpose without unnecessary words. While it is succinct, it could benefit from slightly more detail (e.g., scoping to the authenticated user) without becoming verbose.

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 low complexity (one optional parameter, no output schema, no annotations), the description is minimally adequate but lacks context such as authentication assumption, return format, or pagination details. It meets the basic requirement but has clear gaps.

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 covers 100% of parameters with a description for 'limit'. The tool description does not provide any additional meaning or context for the parameter beyond what the schema already offers, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'saved Reddit posts and comments', making the tool's purpose explicit. It distinguishes itself from sibling tools like 'save_item' and 'unsave_item' by focusing on retrieval rather than modification.

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?

No guidance is provided on when to use this tool versus alternatives such as 'save_item' or 'unsave_item'. There is no mention of prerequisites, authentication, or usage context, leaving the agent to infer from the tool name alone.

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/jeebus87/reddirect'

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