OpenAI & Codex Integration

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:

agent.tsTypeScript
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.

reddit_search

Full-text search across Reddit posts with sorting and time filters.

reddit_get_post

Retrieve post content, score, and paginated recursive comments.

reddit_get_community_posts

Fetch hot, top, new, and rising feeds from any public subreddit.

reddit_get_community_details

Inspect subreddit rules, subscriber counts, and description.

reddit_get_user_profile

Access user karma metrics, account age, and bio data.

reddit_get_user_posts

Pull a Reddit user's submission history.

reddit_get_user_comments

Pull public comments made by a specific user.

reddit_search_communities

Discover subreddits relevant to specific queries.

reddit_search_users

Locate Reddit users by name.

reddit_get_comment_permalink

Get single comment with immediate conversational context.

reddit_get_popular

Fetch current viral trends on r/popular.

reddit_get_leaderboard

Inspect trending communities leaderboard.

reddit_resolve_url_type

Determine what Reddit entity a URL points to.

reddit_explore

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