Skip to main content
Glama
CampusLoop MCPs

CampusLoop MCPs

README.md
# CampusLoop MCPs

Hosted [MCP](https://modelcontextprotocol.io) servers for the social networks the big tool hubs skip or charge for: **Bluesky, Reddit, Threads, X, LinkedIn, Instagram, Mastodon, Telegram bots and Discord webhooks**.

Live at **https://mcps.campusloop.space**. Sign in with your email, paste credentials for the networks you use, and connect any MCP client by URL.

- One endpoint for everything: `https://mcps.campusloop.space/mcp`. Tool names are prefixed (`bluesky_create_post`, `reddit_search`, ...), plus a `hub_status` tool.
- One endpoint per network: `https://mcps.campusloop.space/<provider>/mcp`, with unprefixed names.
- Auth: OAuth 2.1 (dynamic client registration, Client ID Metadata Documents, PKCE) or an API key sent as `Authorization: Bearer mcps_...`.
- Transport: Streamable HTTP (stateless, JSON responses).

## Providers

| Provider | Endpoint | Tools | Credentials you bring |
| --- | --- | --- | --- |
| Bluesky | `/bluesky/mcp` | 41 | Handle + app password |
| Reddit | `/reddit/mcp` | 15 | Your own "script" app client id/secret + username/password, or a refresh token |
| Threads | `/threads/mcp` | 18 | Long-lived Threads user access token |
| X (Twitter) | `/x/mcp` | 15 | Your developer app's consumer key/secret + access token/secret (OAuth 1.0a) |
| LinkedIn | `/linkedin/mcp` | 4 | Access token with `openid profile w_member_social` |
| Instagram | `/instagram/mcp` | 14 | Instagram Graph API token (business or creator account) |
| Mastodon | `/mastodon/mcp` | 10 | Server + access token |
| Telegram bot | `/telegram/mcp` | 8 | Bot token from @BotFather |
| Discord webhook | `/discord/mcp` | 3 | Webhook URL |

The dashboard shows step-by-step instructions for getting each credential. The full tool list is at [/docs](https://mcps.campusloop.space/docs).

Why bring your own credentials? Meta, LinkedIn and X review every app that posts for other people. Your own keys skip that wait, keep your own rate limits, and can be revoked at the source any time.

Platform limits worth knowing:

- **X**: the Free tier allows about 500 posts a month and almost no reads. Search, timelines and mentions need Basic or pay-per-use credits.
- **Reddit**: new API apps need approval under Reddit's Responsible Builder Policy. About 100 requests per minute.
- **Threads**: 250 posts and 1000 replies per 24 hours. Keyword search only finds your own posts until your app passes review for `threads_keyword_search`.
- **Instagram**: 100 API posts per 24 hours. Media must be at a public URL.
- **LinkedIn, Threads and Instagram tokens** expire after 60 days. Threads has a `refresh_token` tool.

## Connect a client

Replace `mcps_YOUR_API_KEY` with a key from the dashboard, or leave the header out to sign in with OAuth.

**Claude Code**

```sh
claude mcp add --transport http campusloop https://mcps.campusloop.space/mcp
# or with a key
claude mcp add --transport http campusloop https://mcps.campusloop.space/mcp \
  --header "Authorization: Bearer mcps_YOUR_API_KEY"
```

**Claude.ai and Claude Desktop**: Settings, Connectors, Add custom connector, paste `https://mcps.campusloop.space/mcp`, Connect, approve.

**Codex** (`~/.codex/config.toml`):

```toml
[mcp_servers.campusloop]
url = "https://mcps.campusloop.space/mcp"
bearer_token_env_var = "CAMPUSLOOP_MCPS_KEY"
```

**Cursor** (`~/.cursor/mcp.json`):

```json
{ "mcpServers": { "campusloop": { "url": "https://mcps.campusloop.space/mcp", "headers": { "Authorization": "Bearer mcps_YOUR_API_KEY" } } } }
```

**VS Code** (`.vscode/mcp.json`):

```json
{ "servers": { "campusloop": { "type": "http", "url": "https://mcps.campusloop.space/mcp", "headers": { "Authorization": "Bearer mcps_YOUR_API_KEY" } } } }
```

**Composio, agent frameworks and stdio-only clients**: use the URL with the `Authorization` header wherever a remote (Streamable HTTP) MCP server is accepted. For clients that only run local servers:

```sh
npx -y mcp-remote https://mcps.campusloop.space/mcp --header "Authorization:Bearer mcps_YOUR_API_KEY"
```

**curl**

```sh
curl -s https://mcps.campusloop.space/bluesky/mcp \
  -H "Authorization: Bearer mcps_YOUR_API_KEY" \
  -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

## How it is built

- One Cloudflare Worker (`src/index.ts`), TypeScript, no web framework.
- MCP: `@modelcontextprotocol/sdk` `McpServer` with `WebStandardStreamableHTTPServerTransport`, built per request (stateless) with only the requesting user's tools.
- OAuth: `@cloudflare/workers-oauth-provider` 1.4 in split roles inside one Worker. An `OAuthAuthorizationServer` (issuer `https://mcps.campusloop.space`, grants in the `OAUTH_KV` namespace) and one `OAuthResourceServer` per MCP endpoint, each publishing RFC 9728 metadata at `/.well-known/oauth-protected-resource/<path>`. The resource validator also accepts `mcps_` API keys.
- Data: Postgres (Neon), schema `mcps` with `users`, `login_tokens`, `sessions`, `api_keys`, `connections`. See `migrations/`.
- Sign-in: one-time email links through the Cloudflare Email Sending API.
- Providers: `src/providers/<name>.ts`, each with a credential form, a `test()` call and its tools. `src/mcp.ts` registers them.

```
src/
  index.ts          router: MCP resources, OAuth endpoints, web app
  oauth.ts          authorization server, per-endpoint resource servers, API key validation
  mcp.ts            builds the MCP server for a user and endpoint
  app.ts            web UI: sign in, dashboard, API keys, provider connections, OAuth consent
  db.ts             Postgres queries (schema mcps)
  email.ts          magic-link email
  lib/crypto.ts     AES-GCM, SHA-256, tokens
  lib/oauth1.ts     OAuth 1.0a HMAC-SHA1 signing for X
  providers/        bluesky, reddit, threads, x, linkedin, instagram, extras (mastodon, telegram, discord)
  ui/               HTML layout and client snippets
test/               vitest: signing vectors, mocked provider flows, MCP round trips
```

## Security

- Provider credentials are encrypted with AES-256-GCM using the `ENCRYPTION_KEY` Worker secret. The ciphertext is bound to its user and provider, so a copied row cannot be decrypted for someone else.
- API keys, session tokens and sign-in tokens are stored only as SHA-256 hashes. A new API key is shown once.
- OAuth tokens and codes are stored hashed by the provider library. Each grant is bound to one MCP endpoint (audience).
- Credentials are tested before they are saved. Disconnecting deletes them.
- Session cookies are `__Host-`, `HttpOnly`, `Secure`, `SameSite=Lax`. Form posts must be same-origin. Pages send `X-Frame-Options: DENY` and a strict CSP.
- Tools can post, reply and delete on your accounts. Destructive tools carry the MCP `destructiveHint` and read-only ones `readOnlyHint`, so clients can ask before running them.
- Prefer narrow credentials: Bluesky app passwords, Reddit script apps you own, tokens with only the scopes listed above.

## Self-hosting

1. `bun install`
2. Create a Postgres database (Neon works) and run `DATABASE_URL=... node scripts/migrate.mjs`.
3. Create a KV namespace with `bunx wrangler kv namespace create oauth` and put its id in `wrangler.jsonc`.
4. Change `PUBLIC_URL`, `EMAIL_FROM` and `routes` in `wrangler.jsonc`.
5. Set secrets:
   ```sh
   bunx wrangler secret put DATABASE_URL
   openssl rand -base64 32 | bunx wrangler secret put ENCRYPTION_KEY
   bunx wrangler secret put CLOUDFLARE_ACCOUNT_ID   # for Email Sending
   bunx wrangler secret put EMAIL_API_TOKEN         # token with Email Sending permission
   ```
6. `bunx wrangler deploy`

Local development: put the same values in `.dev.vars` with `PUBLIC_URL=http://localhost:8787` and run `bun run dev`.

Tests: `bun run test`. Type check: `bun run typecheck`.

## Deploys

Pushes to `main` run the type check, tests, the idempotent migration and `wrangler deploy` (`.github/workflows/deploy.yml`). Repository secrets: `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`, and optionally `DATABASE_URL` for the migration step. Worker secrets live in Cloudflare and CI does not touch them.

## License

MIT