Skip to main content
Glama
jeebus87

reddirect

by jeebus87

Authorize Reddit Account

authorize

Authorize your Reddit account once via browser to grant permanent access. No API keys or passwords needed.

Instructions

One-time authorization: opens Reddit in your browser to connect your account. You click 'Allow', and reddirect gets permanent access. No API keys or passwords stored. Only needs to be done once.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'authorize' tool. It calls client.authorize() and returns the authenticated username.
      async () => {
        try {
          const username = await client.authorize();
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(
                  {
                    success: true,
                    username,
                    message: `Connected as u/${username}. You now have full read/write access. This authorization persists — you won't need to do this again.`,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({
                  success: false,
                  error: error instanceof Error ? error.message : String(error),
                }, null, 2),
              },
            ],
            isError: true,
          };
        }
      }
    );
  • The registration call for 'authorize' with title, description, and inputSchema (empty object — no inputs).
    "authorize",
    {
      title: "Authorize Reddit Account",
      description:
        "One-time authorization: opens Reddit in your browser to connect your account. You click 'Allow', and reddirect gets permanent access. No API keys or passwords stored. Only needs to be done once.",
      inputSchema: z.object({}),
    },
  • Registration of the 'authorize' tool via server.registerTool() inside the register() function exported from src/tools/auth.ts.
      server.registerTool(
        "authorize",
        {
          title: "Authorize Reddit Account",
          description:
            "One-time authorization: opens Reddit in your browser to connect your account. You click 'Allow', and reddirect gets permanent access. No API keys or passwords stored. Only needs to be done once.",
          inputSchema: z.object({}),
        },
        async () => {
          try {
            const username = await client.authorize();
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      success: true,
                      username,
                      message: `Connected as u/${username}. You now have full read/write access. This authorization persists — you won't need to do this again.`,
                    },
                    null,
                    2
                  ),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({
                    success: false,
                    error: error instanceof Error ? error.message : String(error),
                  }, null, 2),
                },
              ],
              isError: true,
            };
          }
        }
      );
    }
  • src/index.ts:26-33 (registration)
    The root registration: registerAuthTools(server, client) is called, which registers the 'authorize' tool.
    registerAuthTools(server, client);
    registerBrowseTools(server, client);
    registerSearchTools(server, client);
    registerPostTools(server, client);
    registerVoteTools(server, client);
    registerSaveTools(server, client);
    registerInboxTools(server, client);
    registerSubscriptionTools(server, client);
  • The RedditClient.authorize() method that is called by the handler. It delegates to runOneTimeAuth() from auth-flow.ts.
    async authorize(): Promise<string> {
      console.error("[reddirect] Starting one-time authorization...");
      const result = await runOneTimeAuth();
    
      this.session = {
        accessToken: result.accessToken,
        refreshToken: null,
        expiresAt: Date.now() + 23 * 60 * 60 * 1000, // token_v2 lasts ~24hrs
        username: result.username,
        scope: "*",
      };
    
      await this.saveSession();
      console.error(`[reddirect] Authorized as ${result.username}`);
      return result.username;
    }
  • The runOneTimeAuth() function that opens Chrome, waits for Reddit login, extracts the token_v2 cookie, and returns the access token + username.
    export async function runOneTimeAuth(): Promise<AuthResult> {
      const chromePath = await findChrome();
      const tempProfile = path.join(os.tmpdir(), "reddirect-auth-profile");
      await fs.mkdir(tempProfile, { recursive: true });
    
      console.error("[reddirect] Opening Chrome for Reddit login...");
      console.error(
        "[reddirect] Log into your Reddit account in the browser window.\n"
      );
    
      // Launch Chrome with a temp profile and debug port
      // Use 'start' on Windows to ensure the window is visible
      const args = [
        `--remote-debugging-port=${CDP_PORT}`,
        `--user-data-dir=${tempProfile}`,
        "--no-first-run",
        "--no-default-browser-check",
        "--window-size=800,700",
        "https://www.reddit.com/login/",
      ];
    
      let chromeProcess: ReturnType<typeof spawn>;
      if (process.platform === "win32") {
        chromeProcess = spawn("cmd", ["/c", "start", "", chromePath, ...args], {
          stdio: "ignore",
          shell: false,
        });
      } else {
        chromeProcess = spawn(chromePath, args, {
          stdio: "ignore",
          detached: true,
        });
      }
    
      try {
        await waitForCDP();
        const token = await pollForLogin();
    
        console.error("[reddirect] Login detected! Extracting session...");
        const username = await fetchUsername(token);
    
        return { accessToken: token, username };
      } finally {
        // Kill Chrome and the debug port
        if (process.platform === "win32") {
          // Find and kill Chrome on our debug port
          spawn("cmd", ["/c", "taskkill", "/F", "/IM", "chrome.exe", "/FI", `WINDOWTITLE eq *reddirect*`], {
            stdio: "ignore",
          });
          // More reliable: kill by the temp profile directory
          try {
            const { execSync } = await import("node:child_process");
            execSync(
              `wmic process where "CommandLine like '%reddirect-auth-profile%'" call terminate`,
              { stdio: "ignore" }
            );
          } catch {
            // Best effort
          }
        } else {
          chromeProcess.kill();
        }
        // Clean up temp profile
        await fs.rm(tempProfile, { recursive: true, force: true }).catch(() => {});
      }
    }
Behavior5/5

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

Despite no annotations, description details that it opens Reddit in browser, requires user click 'Allow', grants permanent access, and stores no API keys or passwords. This fully discloses the interactive nature and security posture.

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?

Three efficient sentences with front-loaded key information. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no parameters and no output schema, description covers the process, security, and one-time nature. Could mention that other tools become usable after authorization, but not essential.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters (schema coverage 100%), so baseline 4. Description adds value by explaining the authorization process and that no credentials are stored, which is helpful context beyond the empty schema.

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?

Clearly states it's a one-time authorization tool to connect Reddit account, opens browser, permanent access. Distinguishes from all sibling tools which are Reddit actions, not authorization.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'One-time authorization' and 'Only needs to be done once', implying it's a prerequisite. However, does not explicitly state when to use versus alternatives, though context makes it clear.

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