Skip to main content
Glama
Local Reddit Research MCP

Local Reddit Research MCP

by ahmedamad111
README.md
# Local Reddit Research MCP

A read-only MCP server that lets an AI assistant (Claude Desktop, Claude Code, or any MCP client) search and read public Reddit posts. It needs no Reddit account, no API keys and no OAuth. It runs on your own computer over stdio, keeps what it reads in a local SQLite database, ranks results locally, and returns a bounded evidence pack with a source link for every item.

It reads Reddit's public RSS feeds first. Every live request goes through one shared request gate that waits at least 65 seconds between requests and backs off after HTTP 429 (using `Retry-After` when Reddit sends it). It never posts, votes, comments, messages or signs in.

## Tools

All seven tools are annotated read-only and non-destructive.

| Tool | What it does |
|---|---|
| `reddit_search_debug(query, limit)` | One Reddit search. Returns posts with title, body and permalink. |
| `reddit_thread_debug(url, comments_limit)` | Reads one post and up to `comments_limit` comments. Takes a full `https://www.reddit.com/r/<sub>/comments/<id>/...` URL. |
| `reddit_browse(subreddit, query?, sort?, time_range?, limit?, cursor?)` | One page (up to 25 posts) of a subreddit's Best, Hot, New, Top or Rising feed, or a keyword search inside one subreddit, with load-more cursors. |
| `reddit_research(topic, mode, max_threads, comments_per_thread, max_chars)` | Builds a ranked, deduplicated evidence pack from the local cache plus at most one live request per call. |
| `reddit_image(post_url, image_index)` | Returns the pixels of an image recorded from a post you already read. Only `i.redd.it`, `preview.redd.it` and `external-preview.redd.it`; PNG, JPEG, GIF or WebP; at most 3 MiB; no redirects. |
| `reddit_cache_status()` | Cache and corpus counts, request gate state (`nextAllowedAt`, `backoffUntil`) and recent failures. |
| `reddit_chrome_test(url, kind)` | Diagnostic for the optional Chrome mode. Does nothing unless Chrome mode is turned on. |

## Requirements

- Node.js 22 or newer.
- Developed and tested on macOS. The server itself is plain Node.js and should run on Linux and Windows, but that is not tested. `better-sqlite3` downloads a prebuilt binary for common platforms; otherwise it needs a C++ build toolchain.

## Install

```bash
git clone https://github.com/ahmedamad111/reddit-research-mcp.git
cd reddit-research-mcp
npm ci
npm run build
npm test
```

## Configure your MCP client

Claude Desktop (`claude_desktop_config.json`) or any client that takes the same shape:

```json
{
  "mcpServers": {
    "reddit-research": {
      "command": "node",
      "args": ["/absolute/path/to/reddit-research-mcp/dist/src/mcp/server.js"],
      "env": {
        "REDDIT_RESEARCH_DB_PATH": "/absolute/path/to/reddit.sqlite3"
      }
    }
  }
}
```

Claude Code:

```bash
claude mcp add reddit-research -e REDDIT_RESEARCH_DB_PATH="$HOME/.local/share/reddit-research/reddit.sqlite3" -- node "$PWD/dist/src/mcp/server.js"
```



You can also build a Claude Desktop extension bundle (`dist/package/local-reddit-research-0.2.0.mcpb`) with `npm run package:extension`. The bundle's `manifest.json` targets macOS and stores the database under the Claude Desktop folder; edit `REDDIT_RESEARCH_DB_PATH` and `compatibility.platforms` there for other systems.

### Environment variables

| Name | Default | Meaning |
|---|---|---|
| `REDDIT_RESEARCH_DB_PATH` | `./.local-reddit-research/reddit.sqlite3` (relative to the working directory) | Where the SQLite cache lives. Set an absolute path. |
| `REDDIT_RESEARCH_CHROME_ENABLED` | off | Set to exactly `1` to turn on Chrome mode (below). Any other value leaves it off. |
| `REDDIT_RESEARCH_CHROME_MECHANISM` | `extension` | `cdp` connects to Chrome's remote-debugging endpoint instead of the Playwright extension. |
| `REDDIT_CHROME_PROFILE_DIR_NAME` | unset | Picks a Chrome profile when the Playwright extension is installed in more than one. |

## Example prompts

- "Search Reddit for quiet mechanical keyboards. Read three relevant posts and five comments each, and summarize the recommendations with links."
- "Search r/Sourdough for starter problems in a cold kitchen. Read two posts and their comments."
- "Show the top r/investing posts from the past month."
- "Read these Reddit post links with five comments each and tell me which ones could not be read: ..."

Searches can be limited to one community with Reddit's own syntax, for example `subreddit:Sourdough cold kitchen`.

## How it gets data

Each tool call makes at most one live request. If a method fails in a way that can be retried, the call returns `ACQUISITION_PENDING` with `next_action` and `retry_at`; repeat the same call after that time and the server tries the next method. The order is:

1. The local cache, if fresh.
2. Reddit's public RSS feeds.
3. Your own Chrome session, only if Chrome mode is on.
4. Reddit's public HTML pages.
5. Older cached results, clearly marked stale, only when nothing live is available.

HTTP 401, 403 and 429, and any active backoff, stop the chain: the server reports the denial and does not try another method.

### Chrome mode (off by default)

When `REDDIT_RESEARCH_CHROME_ENABLED=1` is set, the server can read a page through your existing Chrome window using [Playwright MCP](https://github.com/microsoft/playwright-mcp) (installed as a dependency), limited to `reddit.com` origins. A fixed script reads a small set of post and comment fields. The server never signs in, never copies cookies or storage, and never returns page HTML, screenshots or cookies. If you are signed in to Reddit in that browser, Reddit sees the request as coming from your account and the reader can see whatever your account can see, so leave this off unless you want that.

Setup:

1. Extension mechanism (default): install the Playwright MCP Bridge extension in Chrome, following the Playwright MCP README's "Browser extension" section. If it is installed in more than one Chrome profile, set `REDDIT_CHROME_PROFILE_DIR_NAME` to the profile folder name (for example `Default` or `Profile 1`).
2. CDP mechanism: set `REDDIT_RESEARCH_CHROME_MECHANISM=cdp` and turn on **Allow remote debugging for this browser instance** at `chrome://inspect/#remote-debugging` yourself. The server never changes that setting.
3. Restart your MCP client, then ask it to run `reddit_chrome_test` with a thread URL. The result names the mechanism, the status and a short, sanitized error if the connection failed.

Chrome mode does not see HTTP status codes or `Retry-After` headers, so it relies on the shared 65-second gate and on recognising login, block and error pages, not on Reddit's rate-limit headers. `reddit_chrome_test` with `kind: "search"` only accepts `https://www.reddit.com/search/` and `https://www.reddit.com/r/<subreddit>/search/` URLs.

## Limits

- Comments come from RSS, so they are flat (no nesting) and have no vote scores. A thread read is not the full discussion.
- Share links (`/s/...`) are refused; paste the full `/comments/` permalink.
- Without Chrome mode, private, quarantined, deleted or removed content is not available. Some subreddits and threads deny access.
- Best feeds are personalized on Reddit; this reader only returns a Best feed when Reddit's public RSS identifies it as one, and never substitutes Hot.
- Live requests are at least 65 seconds apart, so reading ten threads takes more than ten minutes. MCP clients with a 60-second tool timeout should wait outside the call until `retry_at` or `reddit_cache_status`'s `nextAllowedAt`.
- JavaScript-only pages, videos, galleries missing from RSS and attachments may not be readable.

## Reddit's rules and rate limits

Without Chrome mode, this tool reads only public pages. It identifies itself with a fixed user agent (`local-reddit-research-mcp/0.2`), spaces requests at least 65 seconds apart, and after HTTP 429 waits for `Retry-After` or an exponential backoff (1 to 15 minutes), whichever is longer. Redirects are followed only to HTTPS Reddit hosts (at most three), and response bodies over 5 MiB are rejected. Do not shorten the gate, run many copies in parallel, or use it to bulk-download Reddit. You are responsible for using it in line with Reddit's [User Agreement](https://redditinc.com/policies/user-agreement) and [Data API Terms](https://redditinc.com/policies/data-api-terms). It is not affiliated with or endorsed by Reddit.

## Privacy

- There is no server of ours in the loop. Your search terms and URLs go to Reddit, and the results go to your MCP client (and from there to whatever model provider it uses).
- The SQLite file on your computer keeps the posts, comments, search terms and request history you fetched. Delete the file to clear it.
- Failure diagnostics stored in the database keep a short plain-text excerpt and a few allow-listed headers. Cookies, credentials, emails, IP addresses, scripts and form fields are removed before storage.
- Reddit content is untrusted text. Treat it as data, never as instructions for your assistant.

## Development

```bash
npm run typecheck
npm run lint
npm test          # offline: fixtures and injected HTTP/browser doubles, no network
npm run smoke:mcp # builds, starts the server over stdio with a temporary database, lists tools
```

## License

MIT. See [LICENSE](LICENSE).