streamable-httpMITupdated 7d ago
Never hand an AI agent a full OAuth scope again.
What can you do with ScopeGate?
ScopeGate
Never hand an AI agent a full OAuth scope again.
ScopeGate sits between your agents and the accounts they reach ā yours or your clients'. You connect a service once, tick the exact actions an agent may call, and hand it an MCP endpoint that can do nothing else. Every call is logged; one click kills the key without touching the connection.
- Per-action permissions ā
gmail:read_emailsyes,gmail:send_emailno. Finer than any provider's OAuth scopes. - Audit trail ā who, which tool, what outcome, how long. Per project, exportable.
- One-click revocation ā regenerate an endpoint key; the service connection stays.
- Tokens never leave ā AES-256-GCM at rest, refreshed automatically, agents only ever see
sg_ā¦.
Run it yourself in one command:
docker compose --profile local up
Open http://localhost:3000 ā the admin login is printed in the container logs on first boot. Details in Quick Start.
Tech Stack
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Database: PostgreSQL + Prisma 7
- UI: Tailwind CSS v4, shadcn/ui
- Auth: Better Auth (database-backed sessions, Prisma adapter)
- MCP:
@modelcontextprotocol/sdk(Streamable HTTP) - Package Manager: pnpm
Quick Start (self-hosted)
Full feature parity with the hosted cloud version ā nothing is cut for self-host.
git clone https://github.com/alifanov/scopegate.git
cd scopegate
docker compose --profile local up
Open http://localhost:3000. No .env file needed: a local
Postgres and a fresh BETTER_AUTH_SECRET are provisioned automatically, and the
generated admin login is printed once in the app container logs on first boot
(look for Generated admin login) ā search it with docker compose logs app | grep -A4 "First run".
The password is also saved to the app_data volume so it survives restarts.
To connect real services (Gmail, LinkedIn, GitHub, ā¦), copy .env.example to .env
and fill in the OAuth client id/secret for the providers you want ā every block is
independent and optional, a provider without credentials simply doesn't show up.
Development Setup
Prerequisites
- Node.js 20.19+, 22.12+ or 24+ (required by Prisma 7)
- pnpm
- PostgreSQL
Setup
- Clone the repository and install dependencies:
pnpm install
- Copy the environment file and fill in your values:
cp .env.example .env
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |
BETTER_AUTH_SECRET |
Secret key for session signing |
BETTER_AUTH_URL |
App base URL (e.g. http://localhost:3000) |
ADMIN_EMAIL |
Bootstrap admin email |
ADMIN_PASSWORD |
Bootstrap admin password |
- Run database migrations:
pnpm prisma migrate dev
- Start the development server:
pnpm dev
Open http://localhost:3000.
Project Structure
src/
āāā app/
ā āāā (auth)/ # Login & register pages
ā āāā (dashboard)/ # Protected dashboard pages
ā ā āāā projects/ # Project management, endpoints, audit, settings
ā āāā api/
ā ā āāā auth/[...all]/ # Better Auth catch-all handler
ā ā āāā projects/ # Projects CRUD, endpoints, services, audit
ā ā āāā mcp/[apiKey]/ # MCP Streamable HTTP handler
ā āāā layout.tsx
ā āāā page.tsx # Landing page
āāā components/
ā āāā ui/ # shadcn/ui components
ā āāā layout/ # Sidebar, header
ā āāā shared/ # Reusable app components
āāā lib/
ā āāā db.ts # Prisma client singleton
ā āāā auth.ts # Better Auth server instance
ā āāā auth-client.ts # Better Auth client SDK
ā āāā auth-middleware.ts # getCurrentUser() helper
ā āāā bootstrap.ts # Admin user bootstrap on empty DB
ā āāā provider-registry.ts # Every supported provider ā the one file to edit
ā āāā mcp/
ā āāā permissions.ts # Permission groups (derived from the registry)
ā āāā tools/ # One file per service, aggregated in index.ts
ā āāā service-fetch.ts # Unified, SSRF-safe transport for all providers
ā āāā handler.ts # MCP server factory + audit logging
āāā generated/prisma/ # Generated Prisma client
āāā middleware.ts # Route protection
Available Scripts
pnpm dev # Start development server
pnpm build # Production build
pnpm start # Start production server
pnpm lint # Run ESLint
pnpm prisma generate # Regenerate Prisma client
pnpm prisma migrate dev # Create and apply migrations
pnpm prisma studio # Open Prisma Studio (DB browser)
How It Works
- Login ā sign in with admin credentials (bootstrapped from env vars on first run)
- Create a Project ā organize endpoints and services by project
- Connect a Service ā add a service connection to the project
- Create an MCP Endpoint ā select a service connection and pick specific permissions (e.g.
gmail:read_emails,calendar:create_event) - Use the MCP URL ā plug the endpoint URL into any MCP-compatible AI agent; only the allowed actions are exposed
- Monitor ā track every request in the audit log
Permissions
A permission is a single action, not a service ā gmail:read_emails can be granted
without gmail:send_email. Groups are derived from src/lib/provider-registry.ts
(27 providers: Google Workspace, Google Ads & Search Console, Meta, LinkedIn,
Twitter, Slack, Notion, Jira, HubSpot, Salesforce, Stripe, Airtable, ā¦) and listed
in src/lib/mcp/permissions.ts. Adding a provider means editing the registry ā
transport, token strategy and permission groups are all derived from it.
A few Google examples:
| Group | Actions |
|---|---|
| Gmail | gmail:read_emails, gmail:send_email, gmail:list_labels, gmail:search_emails |
| Google Calendar | calendar:list_events, calendar:create_event, calendar:update_event, calendar:delete_event |
| Google Drive | drive:list_files, drive:read_file, drive:create_file, drive:delete_file |
Database Schema
- User ā authentication, team membership
- Session ā database-backed auth sessions
- Account ā auth provider credentials (email/password)
- Project ā logical grouping for services and endpoints
- TeamMember ā user-project relationship with roles (owner/member)
- ServiceConnection ā OAuth tokens for connected services
- McpEndpoint ā MCP endpoint with API key, rate limit, active status
- EndpointPermission ā allowed actions per endpoint
- AuditLog ā request log with action, status, duration, errors
License
See LICENSE.
Install
Add ScopeGate to your client. Pick the one you use.
claude mcp add --transport http scopegate https://scopegate.dev/api/mcp/{api_key}codex mcp add scopegate --url https://scopegate.dev/api/mcp/{api_key}{
"mcpServers": {
"scopegate": {
"url": "https://scopegate.dev/api/mcp/{api_key}"
}
}
}Add to `~/.cursor/mcp.json`, or `.cursor/mcp.json` for a single project.
{
"servers": {
"scopegate": {
"type": "http",
"url": "https://scopegate.dev/api/mcp/{api_key}"
}
}
}Add to `.vscode/mcp.json` in your workspace.
{
"mcpServers": {
"scopegate": {
"url": "https://scopegate.dev/api/mcp/{api_key}"
}
}
}Add to `claude_desktop_config.json`, then restart Claude Desktop.
{
"mcpServers": {
"scopegate": {
"serverUrl": "https://scopegate.dev/api/mcp/{api_key}"
}
}
}Add to `~/.codeium/windsurf/mcp_config.json`.
Score
39 / 100
Incomplete
- Documentation25/25
- Maintenance19/25
- Trust13/20
- Capability0/15
- Install experience12/15
- Documents what it does and how to connect
- Has a resolvable package or endpoint
- Exposes at least one tool, prompt or resource
- README has substantive content
- Includes a code example
- Documents its configuration
- Mentions credentials or security posture
- Last commit 0 days ago
- Has a release history
- Repository is not archived
- Licensed MIT
- Namespace verified in the official MCP registry
- Claimed by its owner
- Published under an organisation
- 0 tool(s) documented
- Provides prompt templates
- Provides resources
- 6 documented install method(s)
- Published to a package registry
- Offers a hosted endpoint ā no local install
Version history
| Versions | Published |
|---|---|
| 1.0.1Latest | Aug 14, 2026 |