+ Integration Guide

· Updated August 29, 2026

Search Reddit from Claude Code Using MCP

Add FetchLayer's Reddit MCP tool to Claude Code (Anthropic's terminal agent) so you can search Reddit and scrape data without leaving the command line.

Written by Alex P.

  • MCP
  • Claude Code
  • reddit scraping
  • AI agent
  • terminal
  • Anthropic

Claude Code is Anthropic’s agentic coding tool that runs in the terminal. It supports MCP servers, which means you can give it access to Reddit data through FetchLayer — right from your command line, with no browser, no editor UI, and no separate scraping script to maintain.


Prerequisites

  • Claude Code installed (npm install -g @anthropic-ai/claude-code)
  • A FetchLayer API key — get one free (no credit card)

Option 1: Add via CLI

The fastest way to add the FetchLayer MCP server:

claude mcp add fetchlayer \
  --transport streamable-http \
  https://mcp.fetchlayer.dev \
  -- --header "Authorization: Bearer ss-your-api-key"

This saves the config to ~/.claude/settings.json (global) so it’s available in all projects.

To add it for the current project only:

claude mcp add fetchlayer \
  --transport streamable-http \
  --scope project \
  https://mcp.fetchlayer.dev \
  -- --header "Authorization: Bearer ss-your-api-key"

This saves to .mcp.json in your project root — useful if you want the config to travel with the repo (and be visible in code review) rather than living in your personal global settings.

There’s a third scope worth knowing about: --scope local, which saves the server to your personal, non-shared config for that one project — the right choice if you want FetchLayer available on a specific repo but don’t want it committed to .mcp.json for the whole team (for example, if your API key shouldn’t be shared as-is).


Option 2: Edit config manually

If you prefer editing the config file directly, add this to ~/.claude/settings.json:

{
  "mcpServers": {
    "fetchlayer": {
      "url": "https://mcp.fetchlayer.dev",
      "headers": {
        "Authorization": "Bearer ss-your-api-key"
      }
    }
  }
}

Or for project-level config, create .mcp.json in your project root with the same content. If .mcp.json is going into version control, keep the raw key out of it and reference an environment variable instead, since anyone who can read the repo can read a hardcoded header.


Verify it works

Run Claude Code and check that the MCP server is connected:

claude

Then type:

/mcp

You should see “fetchlayer” listed with its available tools and a connected status. If it shows as failed or pending, that’s almost always a malformed header or a typo in the URL rather than anything on FetchLayer’s side — /mcp in Claude Code will usually show the specific error rather than a bare “disconnected.”


Try it out

Once connected, just ask Claude Code to use Reddit data in your prompts:

> Search Reddit for "best API testing tools" and show me the top 5 results
> Get the latest posts from r/ExperiencedDevs about salary negotiation
> Scrape the comments from https://reddit.com/r/programming/comments/... and summarize the key opinions

Claude Code will call the FetchLayer tools automatically and incorporate the results into its responses.


Real workflow example

Here’s a practical use case — competitive research while coding:

> I'm building a URL shortener. Search Reddit for "self-hosted URL shortener"
> discussions from the past year. What are people recommending and what
> features do they care about most?

Claude Code will:

  1. Call scrape_search with the query
  2. Potentially call scrape_post on the most relevant threads to read comments
  3. Synthesize the findings into an actionable summary

All without leaving your terminal.

Using it in headless / scripted runs

Because Claude Code also supports non-interactive, headless invocation (claude -p "..." piped into a script or CI step), the same fetchlayer MCP server works identically in an automated pipeline — for example, a nightly job that pulls trending posts from a handful of subreddits and writes a summary to a file, with no human clicking “approve” on each tool call. If you’re running Claude Code headless, set the MCP server up at --scope project (or local) so the config is present without depending on your interactive global settings.


Available Tools

All 13 FetchLayer Reddit tools are available:

  • scrape_search — Search posts by keyword
  • scrape_post — Get a full post with comments
  • scrape_community_posts — Browse subreddit posts
  • scrape_community_details — Get subreddit metadata
  • scrape_user_profile — User karma, bio, account age
  • scrape_user_posts / scrape_user_comments — User history
  • scrape_search_communities / scrape_search_users — Discovery
  • scrape_comment_permalink — Specific comment with context
  • scrape_popular — What’s trending on Reddit
  • scrape_leaderboard — Trending communities
  • scrape_explore — Discover communities by topic

What a tool call actually returns

Reddit tools return structured JSON, not a page you have to parse. A scrape_search call for something like “self-hosted url shortener” returns an array of post objects shaped roughly like this:

{
  "results": [
    {
      "id": "1abc23",
      "subreddit": "selfhosted",
      "title": "What is your favorite self-hosted URL shortener?",
      "author": "u/example_user",
      "score": 214,
      "num_comments": 87,
      "created_utc": 1735689600,
      "url": "https://reddit.com/r/selfhosted/comments/1abc23/...",
      "selftext": "Looking for something lightweight that supports custom domains..."
    }
  ]
}

That structure is why an agent can reliably sort by score, filter by subreddit, or pull num_comments to decide whether a thread is worth a follow-up scrape_post call — none of which is reliable when an agent is scraping rendered HTML itself, where class names and layout change without warning.


Choosing a config scope

The claude mcp add command takes a --scope flag, and which one you pick determines who can call Reddit tools:

  • local (default) — this project, your machine only. Config stays out of the repo.
  • project — written to a file that’s committed, so everyone on the team gets the server. Convenient, but never put a literal API key in it.
  • user — every project you open. Convenient and the easiest way to spend requests by accident, since an agent in an unrelated repo can still reach for the tool.

For a shared repo, project scope plus an environment variable reference is the combination that works — the team gets the server definition, and each person supplies their own key:

claude mcp add --scope project --transport http fetchlayer \
  https://mcp.fetchlayer.dev \
  --header "Authorization: Bearer ${FETCHLAYER_API_KEY}"

Everyone then sets FETCHLAYER_API_KEY in their own shell. Nobody’s key lands in git, and a key that never reaches the repo never needs rotating for that reason.


Request cost in an agentic session

Claude Code runs multi-step tasks, so it’s worth knowing what actually increments the counter:

  • Each scrape_search is one request, however many results return
  • Each scrape_post is one request per page of comments — pages: 3 costs three
  • Anything answered from earlier context costs nothing

The practical version: search wide, open narrow. A prompt like “search r/devops for Terraform complaints, then open only the two most-discussed threads” is three requests. The same task phrased as “read what people say about Terraform in r/devops” can easily become ten, because the agent opens results to find out whether they’re relevant.

Naming a thread limit in the prompt is the single most effective cost control, and it usually improves the output too — two carefully-read threads beat eight skimmed ones.


Combining Reddit data with the codebase

The reason to have this in Claude Code rather than a browser is that the agent can act on what it finds, in the repo, in one pass:

“Search Reddit for complaints about our CLI’s error messages, then find the corresponding error strings in src/ and draft clearer replacements.”

That’s one search request, then ordinary file operations. The agent grounds the rewrite in language real users used to describe the confusion, rather than in its own guess at what’s unclear.

The same shape works for triage — pull recurring complaints, grep for the responsible code path, and open the loop on a fix — all without leaving the terminal.


Troubleshooting

MCP server not connecting?

  • Run claude mcp list to see configured servers and their scope
  • Check that the URL is correct: https://mcp.fetchlayer.dev
  • Verify your API key is valid and starts with ss-
  • If you added it at --scope project but aren’t in that project’s directory, Claude Code won’t see it — global (user) scope is the one that follows you everywhere

Permission denied?

  • Claude Code may ask you to approve MCP tool usage the first time in a session — accept when prompted
  • Check the Claude Code permission settings with /permissions if you want to pre-approve fetchlayer calls so you’re not confirming every request

Works interactively but fails in a headless script?

  • Headless runs can’t respond to an interactive approval prompt — make sure the server’s permission is already granted (or configured to auto-approve) before running with -p

Using more than one platform in the same session

The fetchlayer MCP server you just connected is Reddit-specific, but the same account and API key work across FetchLayer’s other platform servers too — Twitter/X, App Store reviews, YouTube comments, Google Maps, and Google Play Store. If your workflow needs more than Reddit (comparing what people say on Reddit vs. X about the same topic, for example), you can add the Twitter MCP server alongside this one with the same API key and a different server URL. Nothing about the setup above changes — it’s the same config shape, just a second entry in your mcpServers block.


What’s Next