reddit-mcp
reddit-mcp
Cursor / Grok Bot 向けconnect-card OAuth用の、読み取り専用の Reddit Data API MCP コネクタです。
Cloudflare Worker として動作し、MCP Streamable HTTP を実装します。呼び出し元の Authorization: Bearer トークンは、https://oauth.reddit.com に そのままパススルー されます。
リポジトリ: https://github.com/pmsorhaindo/reddit-mcp
アーキテクチャ
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)ルート | 目的 |
| Livenessチェックとエンドポイント一覧 |
| MCP Streamable HTTP(JSON-RPC: |
| OAuth AS メタデータ(Redditのauthorize/token) |
| このMCP URLに対する保護リソースのメタデータ |
| 開発用ランディングページのみ — コード交換は行いません |
なぜ最小限のJSON-RPCなのか(完全なMCP SDKではないのか)
@modelcontextprotocol/sdk は従来、Nodeのトランスポートを対象にしていました。このWorkerは、Durable Objectsやセッションストアを使わずに、Cursor/Grokがツール呼び出しのために必要とする Workersネイティブで依存が少ない Streamable HTTP JSON-RPC サーフェス(initialize / tools/list / tools/call)を実装します。これは Bearerパススルー に適合します。WorkerはRedditのリフレッシュトークンを一切保持しないためです。
ツール
ツール | Reddit API | スコープ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
すべてのツールは コンパクトなJSON(テキストフィールドは切り詰められます)を返します。limit のデフォルトは 25 で、上限は 100 です。
レート制限
Redditへの外部呼び出しは、Workerのisolateごとに直列化されます(promiseチェーン)。
レスポンスの
X-Ratelimit-Remaining/X-Ratelimit-Resetは、次の呼び出しの前に尊重されます。HTTP 429 / 503 では、
Retry-Afterまたは指数バックオフによる制限付きリトライが実行されます。
シークレットの取り扱い
本当のシークレットをコミットしないでください。
強力な
.gitignoreが、.env、.dev.vars、.wrangler/、node_modules/、dist/、credentials*.json、.mcp-auth/を対象にしています。コミットされるのはサンプルの環境変数ファイルのみです:
.dev.vars.example、.env.example。wrangler.tomlには、インラインのシークレットはありません。エラーや
consoleログに、Authorizationヘッダー、トークン、シークレット用環境変数の値が含まれることはありません。ツールのエラーペイロードはステータスとメッセージのみです — クレデンシャルを漏らす可能性のある上流のレスポンスボディは含まれません。
Related MCP server: reddit-mcp
Redditアプリのセットアップ
https://www.reddit.com/prefs/apps でRedditアプリを作成します(クライアントに応じて web app または installed app を選択してください)。
リダイレクトURIを追加します:
http://localhost:8787/callback— ローカルのwrangler / 手動テスト用https://www.cursor.com/agents/mcp/oauth/callback— Cursor connect-card用
スコープをリクエストします(Redditのauthorize URLではカンマ区切り):
identity,read,mysubreddits,history
client_id/client_secretは、OAuthクライアント(Cursor / お使いのシークレットマネージャー)側で控えてください。このリポジトリやwrangler.tomlには入れないでください。
OAuthディスカバリの前提
/.well-known/oauth-authorization-serverは以下を公開します:authorization_endpoint:https://www.reddit.com/api/v1/authorizetoken_endpoint:https://www.reddit.com/api/v1/access_token
このWorkerは、認可コードの交換を行わず、リフレッシュトークンも保存しません。
Cursor / Grok は、クライアントで設定したRedditアプリの認証情報を使ってRedditとのOAuthを完了し、MCPリクエストに
Authorization: Bearer <access_token>を付けて送信します。メタデータ内の
issuerはこのWorkerのオリジンです。MCPクライアントがMCPベースURLからドキュメントを発見できるようにするためです。authorize/tokenの実行は引き続きReddit側で行われます。Redditのスコープは、authorize URLでは従来どおりカンマ区切りです。クライアントはスコープをそれに合わせて連結する必要があります。
Cloudflareへのデプロイ
前提条件: Node 22+、Cloudflareアカウント、Wranglerへのログイン(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 deployUSER_AGENT の例の形状(プレースホルダのみ):
cloudflare-worker:reddit-mcp:0.1.0 (by /u/YOUR_REDDIT_USERNAME)デプロイ後、workers.devまたはカスタムドメインのURLを確認してください。例: https://reddit-mcp.<account>.workers.dev
MCPサーバーの追加(Cursor / Grok)
AddMcpServer(または同等のconnect-card)を設定する際は次のようにします:
フィールド | 値 |
URL |
|
認証 | OAuth(connect-card) |
スコープ |
|
クライアントは、お使いのRedditアプリのclient id / secret と上記のCursorリダイレクトURIを使用します。認証後、MCPツールの呼び出しには、RedditのアクセストークンをBearerヘッダーとして含める必要があります。このWorkerがそれをアップストリームに転送します。
スモークテスト
$BASE と $TOKEN はローカルで置き換えてください — トークンはコミットしないでください。
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":{}}}'期待される結果: JSON-RPCの結果が返ること。get_me はコンパクトなプロフィールフィールドを返します。Bearerがない場合は、JSON-RPCエラーとして Unauthorized が返り、ヘッダーは漏れません。
スクリプト
スクリプト | コマンド |
|
|
|
|
|
|
対象外
書き込み、投票、メッセージ、Moderation、Ads API
Worker上でのRedditリフレッシュトークンやクライアントシークレットの保存
/callbackでのOAuthコード交換の実行完全なMCPのresources/prompts/sampling/elicitationセッション
マルチテナントのトークン保管庫 / Durable ObjectSessionストア
クロスアイソレートのグローバルレート制限連携の保証(制限はisolateごととRedditヘッダーによる)
ライセンス
ライセンスファイルを追加しない限り、Private / 未公開となります。
This server cannot be deployed
Maintenance
Related MCP Connectors
Reddit MCP server: search posts, subreddit feeds, comments & user profiles as JSON. No API key.
Real-time Reddit posts, subreddit search, comments & brand mentions MCP. OAuth or API key.
Reddit API as MCP tools: search, subreddits, posts, comments, users, monitors, webhooks, feedback.
Search, organize, and chat with your saved Reddit posts from Claude, Cursor, and any MCP client.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn 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.83-
- AlicenseNot gradedqualityDmaintenanceA 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.93 npm2MIT
- AlicenseNot gradedqualityDmaintenanceRead-only MCP server for public Reddit content using TypeScript. Enables listing posts, fetching post details and comments, and searching Reddit.18 npm2MIT
- AlicenseNot gradedqualityBmaintenanceA local, read-only Reddit MCP server that provides tools for searching posts, retrieving posts/comments, subreddit information, and user content via the official Reddit Data API with caching and privacy-focused features.-