Skip to content

Commit 1873f4e

Browse files
committed
feat: initial Reddit adapter for browserkit
4 public tools using Reddit JSON API: - get_subreddit: posts from any subreddit with sort/time/count - get_thread: post + top-level comments - search: site-wide or subreddit-scoped search - get_user: public profile (overview/submitted/comments) Uses Reddit JSON API (no bot detection, works in CI without auth). 85 tests: 49 L1 unit, 14 L3 protocol, 7 L4 reliability, 15 L2 live. Made-with: Cursor
0 parents  commit 1873f4e

15 files changed

Lines changed: 3472 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Build & Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
path: adapter-reddit
18+
19+
- uses: actions/checkout@v4
20+
with:
21+
repository: browserkit-dev/browserkit
22+
path: browserkit
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
28+
- name: Install & build @browserkit/core
29+
working-directory: browserkit
30+
run: |
31+
npm install -g pnpm
32+
pnpm install --frozen-lockfile
33+
pnpm --filter @browserkit/core build
34+
35+
- name: Patch @browserkit/core dep path
36+
working-directory: adapter-reddit
37+
run: |
38+
npm pkg set 'devDependencies.@browserkit/core'='file:../browserkit/packages/core'
39+
npm pkg set 'peerDependencies.@browserkit/core'='>=0.1.0'
40+
41+
- name: Install adapter dependencies
42+
working-directory: adapter-reddit
43+
run: npm install
44+
45+
- name: Install Patchright Chromium
46+
working-directory: adapter-reddit
47+
run: npx patchright install chromium --with-deps
48+
49+
- name: Build
50+
working-directory: adapter-reddit
51+
run: npm run build
52+
53+
# L1 unit + L3 protocol + L4 reliability (Reddit is public — network OK in CI)
54+
# L2 integration tests also run (Reddit is public, no auth needed)
55+
- name: Test
56+
working-directory: adapter-reddit
57+
run: npm test
58+
timeout-minutes: 10
59+
60+
- name: Integration tests
61+
working-directory: adapter-reddit
62+
run: npm run test:integration
63+
timeout-minutes: 15

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
.DS_Store
4+
*.storage-state.json

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# @browserkit/adapter-reddit
2+
3+
[Reddit](https://old.reddit.com) adapter for [browserkit](https://github.com/browserkit-dev/browserkit) — browse subreddits, threads, search, and user profiles via your local browser session.
4+
5+
Targets `old.reddit.com` — Reddit's classic r2 HTML interface with stable class names unchanged since ~2015. No React DOM churn.
6+
7+
## Tools
8+
9+
| Tool | Key inputs | Description |
10+
|---|---|---|
11+
| `get_subreddit` | `subreddit`, `sort?` (hot/new/top/rising/controversial), `time?`, `count?` | Posts from a subreddit |
12+
| `get_thread` | `thread_id` (post ID or URL), `sort?`, `count?` | Post + top-level comments |
13+
| `search` | `query`, `subreddit?`, `sort?`, `time?`, `count?` | Search Reddit |
14+
| `get_user` | `username`, `section?` (overview/submitted/comments), `count?` | Public user profile |
15+
16+
Plus auto-registered management tools from the framework: `browser` (health check, screenshot, page state, mode switch, navigate), `close_session`.
17+
18+
## Setup
19+
20+
```bash
21+
pnpm add @browserkit/adapter-reddit
22+
```
23+
24+
```js
25+
// browserkit.config.js
26+
import { defineConfig } from "@browserkit/core";
27+
28+
export default defineConfig({
29+
adapters: {
30+
"@browserkit/adapter-reddit": { port: 3849 },
31+
},
32+
});
33+
```
34+
35+
No login required — all four Phase 1 tools work on public Reddit content without authentication.
36+
37+
```bash
38+
browserkit start --config browserkit.config.js
39+
```
40+
41+
Connect your MCP client to `http://127.0.0.1:3849/mcp`.
42+
43+
## Examples
44+
45+
```
46+
// Hot posts from r/programming
47+
get_subreddit({ subreddit: "programming", sort: "hot", count: 10 })
48+
49+
// Top posts of the past week
50+
get_subreddit({ subreddit: "worldnews", sort: "top", time: "week", count: 25 })
51+
52+
// Get a thread and its comments
53+
get_thread({ thread_id: "abc123", sort: "confidence", count: 20 })
54+
get_thread({ thread_id: "https://old.reddit.com/r/programming/comments/abc123/", count: 10 })
55+
56+
// Search
57+
search({ query: "TypeScript performance", subreddit: "programming", sort: "top", time: "month" })
58+
59+
// User profile
60+
get_user({ username: "GovSchwarzenegger", section: "submitted", count: 10 })
61+
```
62+
63+
## Tests
64+
65+
```bash
66+
pnpm test # L1 unit + L3 MCP protocol + L4 reliability
67+
pnpm test:integration # L2 live scraping against real old.reddit.com
68+
```
69+
70+
Reddit is a public site — both test suites run without authentication and are safe for CI.
71+
72+
## License
73+
74+
MIT

0 commit comments

Comments
 (0)