Connect Reddit to OpenAI Agents & Codex
Seamlessly equip GPT-4o, Codex, and custom autonomous agents with 14 native Reddit tools using the open Model Context Protocol standard.
Connect to OpenAI Agent Loop
Bind SubScraper MCP tools to an autonomous OpenAI agent in TypeScript:
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import OpenAI from "openai";
// 1. Connect to SubScraper MCP Server
const transport = new StdioClientTransport({
command: "npx",
args: ["-y", "@subscraper/mcp"],
env: { SUBSCRAPER_API_KEY: "sk-your-api-key" }
});
const mcp = new Client({ name: "openai-reddit-agent", version: "1.0.0" });
await mcp.connect(transport);
// 2. Fetch all 14 Reddit tools automatically
const { tools } = await mcp.listTools();
// 3. Pass to OpenAI Chat Completion
const openai = new OpenAI();
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Search Reddit for top discussions on LangChain alternatives." }],
tools: tools.map(t => ({ type: "function", function: t }))
});All 14 Native Tools
Zero manual function schema authoring required.
Full-text search across Reddit posts with sorting and time filters.
Retrieve post content, score, and paginated recursive comments.
Fetch hot, top, new, and rising feeds from any public subreddit.
Inspect subreddit rules, subscriber counts, and description.
Access user karma metrics, account age, and bio data.
Pull a Reddit user's submission history.
Pull public comments made by a specific user.
Discover subreddits relevant to specific queries.
Locate Reddit users by name.
Get single comment with immediate conversational context.
Fetch current viral trends on r/popular.
Inspect trending communities leaderboard.
Determine what Reddit entity a URL points to.
Discover communities grouped by vertical.
Frequently Asked Questions
Can I use this MCP server with OpenAI SDK in Python or TypeScript?
Yes. You can run the SubScraper MCP server via standard MCP client libraries like @modelcontextprotocol/sdk in Node.js or mcp in Python, binding the tools directly to your OpenAI chat completion or Assistant agent loop.
How does MCP compare to custom OpenAI function definitions?
With MCP, you don't have to manually write or maintain 14 JSON schema tool definitions for Reddit. The MCP server automatically broadcasts standard tool schemas, parameter types, and descriptions to the LLM.
Are token costs optimized for LLM context windows?
Yes. SubScraper strips all HTML boilerplate, tracking scripts, and non-essential Reddit metadata, returning clean, token-efficient JSON designed specifically for LLM context limits.
Build Reddit-powered OpenAI agents today.
Start with 30 free requests. Plug in our MCP server in minutes.
Get Free API Key