Skip to main content
Glama
pmsorhaindo

reddit-mcp

by pmsorhaindo

reddit-mcp

Nur-Lese-Reddit-Data-API-MCP-Connector für Cursor / Grok Bot Connect-Card-OAuth. Läuft als Cloudflare Worker, der MCP Streamable HTTP spricht und das Authorization: Bearer-Token des Aufrufers an https://oauth.reddit.com weiterreicht.

Repository: https://github.com/pmsorhaindo/reddit-mcp

Architektur

Cursor / Grok Bot
   │  OAuth (connect-card) against Reddit authorize/token
   │  then MCP JSON-RPC with Bearer access token
   ▼
Cloudflare Worker (this repo)
   │  POST /mcp  → tools/list, tools/call
   │  GET  /.well-known/oauth-*  → discovery pointing at Reddit
   ▼
https://oauth.reddit.com  (User-Agent from env, Bearer passthrough)

Route

Verwendungszweck

GET / oder /health

Liveness + Endpunktübersicht

POST /mcp

MCP Streamable HTTP (JSON-RPC: initialize, tools/list, tools/call)

GET /.well-known/oauth-authorization-server

OAuth-AS-Metadaten (Reddit authorize/token)

GET /.well-known/oauth-protected-resource

Metadaten der geschützten Ressource für diese MCP-URL

GET /callback

Nur Entwicklungs-Landingpage – tauscht keine Codes aus

Warum minimales JSON-RPC (nicht das vollwertige MCP SDK)?

@modelcontextprotocol/sdk zielte historisch auf Node-Transports. Dieser Worker implementiert eine Workers-native, schlanke Streamable-HTTP-JSON-RPC-Oberfläche (initialize / tools/list / tools/call), die genau das abdeckt, was Cursor/Grok für Tool-Aufrufe benötigen – ohne Durable Objects oder Session-Stores. Das passt zum Bearer-Passthrough: Der Worker hält niemals Reddit-Refresh-Tokens.

Tools

Tool

Reddit-API

Scopes

get_me

GET /api/v1/me

identity

list_subscriptions

GET /subreddits/mine/subscriber

mysubreddits

get_user_history

GET /user/{user}/{overview|submitted|comments}

history, read

get_subreddit_feed

GET /r/{sub}/{hot|new|top|rising|controversial}

read

search_reddit

GET /search oder /r/{sub}/search

read

Alle Tools geben kompaktes JSON zurück (gekürzte Textfelder). limit ist standardmäßig 25, das Maximum ist 100.

Ratenbegrenzung

  • Ausgehende Reddit-Aufrufe werden pro Worker-Isolate serialisiert (Promise-Kette).

  • Die Antwort-Header X-Ratelimit-Remaining / X-Ratelimit-Reset werden vor dem nächsten Aufruf berücksichtigt.

  • HTTP 429 / 503 lösen begrenzte Wiederholungsversuche mit Retry-After oder exponentiellem Backoff aus.

Geheimnis-Hygiene

Übertragen Sie niemals echte Geheimnisse.

  • Ein striktes .gitignore deckt ab: .env, .dev.vars, .wrangler/, node_modules/, dist/, credentials*.json, .mcp-auth/.

  • Es werden nur Beispiel-Env-Dateien übertragen: .dev.vars.example, .env.example.

  • wrangler.toml enthält keine Inline-Secrets.

  • Fehler und console-Logs enthalten niemals Authorization-Header, Tokens oder geheime Env-Werte.

  • Tool-Fehlerantworten enthalten nur Status/Meldung – keine Upstream-Response-Bodies, die Anmeldedaten widerspiegeln könnten.

Related MCP server: reddit-mcp

Reddit-App-Einrichtung

  1. Erstelle eine Reddit-App unter https://www.reddit.com/prefs/apps (Typ Web-App oder installierte App, passend zu deinem Client).

  2. Füge Redirect-URIs hinzu:

    • http://localhost:8787/callback – lokales Wrangler / manuelle Tests

    • https://www.cursor.com/agents/mcp/oauth/callback – Cursor Connect-Card

  3. Fordere Scopes an (durchgerechnet, mit Komma im in Reddit-Autorisierungs-URIs):

    • identity,read,mysubreddits,history

  4. Notiere dir client_id / client_secret für den OAuth-Client (Cursor / deinen Secrets-Manager). Lege sie nicht in diesem Repository oder in wrangler.toml ab.

Annahmen zur OAuth-Erkennung

  • /.well-known/oauth-authorization-server bewirbt:

    • authorization_endpoint: https://www.reddit.com/api/v1/authorize

    • token_endpoint: https://www.reddit.com/api/v1/access_token

  • Dieser Worker führt keinen Authorization-Code-Austausch durch und speichert keine Refresh-Tokens.

  • Cursor/Grok schließen OAuth-Authorisierung mit Reddit ab (mit den Reddit-App-Zugangsdaten, die du im Client konfigurierst) und senden dann Authorization: Bearer <access_token> bei MCP-Anfragen.

  • issuer in den Metadaten ist die Origin dieses Workers, damit MCP-Clients Doku aus der MCP-Basis-URL ableiten können; authorize/tokenBibliothek bleiben auf Reddit.

  • Reddit-Scopes werden auf der authorize URL traditionell kommagetrennt übergeben – Clients müssen die Scopes entsprechend zusammenfügen.

Cloudflare-Bereitstellung

Voraussetzungen: Node 22+, ein Cloudflare-Konto, Wrangler eingeloggt (npx wrangler login).

git clone https://github.com/pmsorhaindo/reddit-mcp.git
cd reddit-mcp
npm install

# Local secrets (gitignored)
cp .dev.vars.example .dev.vars
# edit USER_AGENT — must identify you per Reddit API rules

npm run typecheck
npm run dev          # http://127.0.0.1:8787

# Production secret (not committed)
npx wrangler secret put USER_AGENT
npm run deploy

USER_AGENT Beispielsh Form (nur Platzhalter):

cloudflare-worker:reddit-mcp:0.1.0 (by /u/YOUR_REDDIT_USERNAME)

Nach dem Deployment für die workers.dev- oder Custom-Domain-URL, z. B. https://reddit-mcp.<account>.workers.dev.

MCP-Server hinzufügen (Cursor / Grok)

Konfiguriere AddMcpServer (oder eine entsprechende Connect-Card) mit:

Feld

Wert

URL

https://<your-worker>/mcp

Auth

OAuth (Connect-Card)

Scopes

identity read mysubreddits history

Der Client sollte die Client-ID/Secret deiner Reddit-App und die oben genannte Cursor- Redirect URI verwenden. Nach Ende-Authentifizierungmüssen Anrufe für MCP-Tools den Reddit-Zugriffstoken als Bearer-Header enthalten; dieser Worker reicht ihn an Reddit weiter.

Smoke-Tests

Ersetze $BASE und $TOKEN lokal – committe keine Tokens.

BASE=http://127.0.0.1:8787
TOKEN=reddit_access_token_here

# Health
curl -sS "$BASE/health"

# OAuth metadata
curl -sS "$BASE/.well-known/oauth-authorization-server"
curl -sS "$BASE/.well-known/oauth-protected-resource"

# MCP initialize
curl -sS -X POST "$BASE/mcp" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}'

# tools/list
curl -sS -X POST "$BASE/mcp" \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

# tools/call get_me (requires valid Bearer)
curl -sS -X POST "$BASE/mcp" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_me","arguments":{}}}'

Erwartet: JSON-RPC-Ergebnisse; get_me liefert kompakte Profilfelder. Ohne Bearer-Token → JSON-RPC-Fehler Unauthorized ohne Preisgabe von Headern.

Skripte

Skript

Befehl

npm run dev

wrangler dev

npm run deploy

wranglerDeploy

npm run typecheck

tsc --noEmit

Außerhalb des Umfangs

  • Schreiben, Stimmen, Nachrichten, Moderation oder Ads-API

  • Speichern von Reddit-Refresh-Tokens oder Client-Stichdaten auf dem Worker

  • OAuth-Code-Austausch auf /callback

  • Vollständige MCP-Ressourcen/Pronomen/Sampler/Elicitation-Sessions

  • Multi-Tenant-Token-Vaults / Durable-Object-Session-Stores

  • Garantierte globale Ratenbegrenzung über Isolates hinweg (Limits gelten pro Isolate + Reddit-Header)**Eigenverantwortlich

Lizenz

Privat / unveröffentlicht, sofern Sie eine Lizenzdatei hinzufügen.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    An MCP server that provides both read-only and authenticated access to Reddit content and interactions without requiring a developer API key. It enables users to browse posts, search subreddits, and perform write actions like commenting and voting by leveraging browser session cookies.
    8
    1
    The Unlicense
  • F
    license
    Not graded
    quality
    D
    maintenance
    A read-only Model Context Protocol server that enables browsing subreddits, searching within subreddits, retrieving comment trees, and looking up user activity on Reddit via natural language.
  • A
    license
    Not graded
    quality
    D
    maintenance
    A read-only MCP server that connects to the Reddit Data API to search posts, browse subreddits, read comments, view user profiles, and check trending content through the Model Context Protocol.
    12
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Read-only MCP server for public Reddit content using TypeScript. Enables listing posts, fetching post details and comments, and searching Reddit.
    32
    2
    MIT

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/pmsorhaindo/reddit-mcp'

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