Cloudflare OS Gatekeepers: Complete Guide to Third-Party Service Integrations
Cloudflare OS Gatekeepers integrate with ten distinct third-party services—including Slack, GitHub, Google Workspace, Linear, Home Assistant, and the Model Context Protocol (MCP)—exposing them to Gadgets through a uniform typed RPC API that auto-discovers capabilities from GATEKEEPER_* environment bindings.
The cloudflare/cloudflare-os repository implements Gatekeepers as isolated Cloudflare Workers that act as secure bridges between external APIs and internal Gadgets. Each Gatekeeper handles its own OAuth 2.0 flow and exposes service-specific RPC methods, allowing Gadgets to query Slack workspaces, GitHub repositories, or Linear projects without managing separate authentication logic.
Available Gatekeeper Service Integrations
Cloudflare OS ships with ten production-ready Gatekeepers, each residing in the packages/gatekeeper-* directory structure. The backend auto-registers these workers by scanning for GATEKEEPER_* service bindings at deployment time.
Slack Workspace Integration
The Slack Gatekeeper (packages/gatekeeper-slack/src/slack.ts) connects to Slack workspaces using user-level OAuth tokens (xoxp-…). It exposes read-only access to channels, direct messages, threads, members, and search functionality via the Slack Web API.
Session objects implement the SlackWorkspaceSession interface defined in packages/gatekeeper-slack/src/types.d.ts, providing typed methods like listChannels() and searchMessages().
GitHub Repository Management
Located in packages/gatekeeper-github/src/github.ts, the GitHub Gatekeeper authenticates via OAuth App scopes including repo, read:user, and user:email. It exposes repository data, issues, and pull requests through the GitHub REST API.
The GitHubRepoSession type provides methods such as getIssue() and listPullRequests(), wrapping the underlying REST endpoints with typed RPC signatures.
Google Workspace Services
The Google Gatekeeper (packages/gatekeeper-google/src/google.ts) supports Gmail, Drive, Calendar, and other Google services based on configurable OAuth 2.0 scopes defined in deploy-inputs.json. RPC session methods wrap the official Google client libraries, exposing interfaces like GoogleGmailSession with listMessages() and sendMessage() capabilities.
Model Context Protocol (MCP) Servers
MCP Gatekeepers (packages/gatekeeper-mcp/src/mcp.ts and packages/gatekeeper-mcp/src/server-id.ts) dynamically integrate any Model Context Protocol server. They auto-generate session methods from the MCP server's inputSchema, supporting both full-server grants (access to all tools) and named-tool grants (restricted to specific tools).
The Mcp<Name>Session interface is generated at runtime based on the remote server's capabilities.
Linear Project Management
Found in packages/gatekeeper-linear/src/linear.ts, the Linear Gatekeeper uses the Linear GraphQL API to expose read-only session methods such as listIssues(), listProjects(), and searchIssues(). The LinearSession type provides typed access to issue-tracking data without exposing write operations directly.
Home Assistant Smart Home Integration
The Home Assistant Gatekeeper (packages/gatekeeper-homeassistant/src/homeassistant.ts) binds to Home Assistant servers via REST API. It exposes entity read/write methods and event streaming capabilities, allowing Gadgets to query sensor states or trigger automations through the HomeAssistantSession interface.
Email (SMTP/IMAP)
Located in packages/gatekeeper-email/src/email.ts, the Email Gatekeeper provides a generic email interface built on Cloudflare Workers Email or external SMTP relays. Session methods include send(), list(), and search(), abstracting protocol details behind a unified RPC API.
Cloudflare Observability
The Cloudflare Gatekeeper (packages/gatekeeper-cloudflare/src/observability-api.ts and src/observability-session.ts) reads account-wide or worker-scoped telemetry data. It exposes read-only access to billing and performance metrics through the internal observability APIs.
MCP Portal (Admin-Configured)
MCP Portal (packages/gatekeeper-mcp-portal/src/portal.ts) functions identically to the standard MCP Gatekeeper but connects to a pre-configured, admin-provided MCP server endpoint. Only administrators can add the GATEKEEPER_MCP_PORTAL binding, enforcing centralized control over sensitive tool access.
Scheduler and Persistent Callbacks
The Scheduler Gatekeeper (packages/gatekeeper-scheduler/src/driver.ts) integrates with Cloudflare Workers Observability Scheduler. It provides a singleton ScheduleDriver Durable Object for registering periodic workspace callbacks, enabling Gadgets to schedule recurring tasks without external cron services.
Gatekeeper Architecture and Session Lifecycle
Understanding how Cloudflare OS Gatekeepers manage service integrations requires examining four architectural phases defined in the source code:
-
Binding Discovery – The backend scans environment bindings matching
GATEKEEPER_*and registers each as a capability that Gadgets can request during the grant flow. -
OAuth Flow – Each Gatekeeper initializes its own OAuth 2.0 handler (or dynamic client registration for MCP) using
CLIENT_IDandCLIENT_SECRETvariables. The Slack Gatekeeper, for example, redirects to Slack's OAuth endpoint and exchanges codes forxoxptokens. -
Session Creation – Upon successful authentication, Gatekeepers instantiate typed session objects (e.g.,
SlackWorkspaceSession,GitHubRepoSession) that implement the RPC contracts defined insrc/types.d.tsfiles. -
Capability Enforcement – Sessions respect granularity constraints: Slack differentiates between workspace, conversation, and thread grants, while MCP supports full-server versus named-tool restrictions. The system logs all calls via
@gadgets/backend-utils/loggerand disposes stubs to prevent resource leaks.
Implementing Gatekeeper Integrations in Code
Gadgets access Gatekeeper sessions through environment bindings. Below are minimal implementations for the most common service integrations.
Querying Slack Channels
// Access the Slack workspace session
const slack = await env.GATEKEEPER_SLACK as SlackWorkspaceSession;
const channels = await slack.listChannels({ cursor: undefined });
for (const ch of channels.items) {
console.log(`Channel: ${ch.name}`);
}
Source: packages/gatekeeper-slack/src/types.d.ts
Fetching GitHub Issues
const gh = await env.GATEKEEPER_GITHUB as GitHubRepoSession;
const issue = await gh.getIssue({
owner: "cloudflare",
repo: "cloudflare-os",
number: 123
});
console.log(issue.title, issue.body);
Source: packages/gatekeeper-github/src/types.d.ts
Calling MCP Tools
// Access a Linear MCP server session
const linear = await env.MCP_LINEAR as McpLinearSession;
const resp = await linear.searchIssues({ query: "status:open" });
if (resp.status === "ok") {
console.log(resp.text);
}
Source: packages/gatekeeper-mcp/src/types.d.ts
Listing Gmail Messages
const google = await env.GATEKEEPER_GOOGLE as GoogleGmailSession;
const msgs = await google.listMessages({ maxResults: 10 });
console.log(`Retrieved ${msgs.items.length} recent emails`);
Source: packages/gatekeeper-google/src/types.d.ts
Accessing Linear Projects
const linear = await env.GATEKEEPER_LINEAR as LinearSession;
const projects = await linear.listProjects({});
for (const p of projects.items) {
console.log(p.name);
}
Source: packages/gatekeeper-linear/src/types.d.ts
Security Model and Write Operations
All Cloudflare OS Gatekeepers operate read-only by default. When a service requires write operations—such as creating a GitHub issue or posting to Slack—the Gatekeeper enqueues the mutation for explicit user approval rather than executing immediately. Approved writes are recorded as actions in the backend audit log.
This security model applies uniformly across integrations, from the GitHubRepoSession creating pull request comments to the EmailSession sending messages via SMTP.
Summary
- Cloudflare OS Gatekeepers integrate with ten services: Slack, GitHub, Google Workspace, Linear, Home Assistant, Email, MCP servers, MCP Portal, Scheduler, and Cloudflare Observability.
- Each Gatekeeper resides in
packages/gatekeeper-<service>/and implements service-specific OAuth in files likesrc/slack.ts,src/github.ts, orsrc/google.ts. - RPC sessions (e.g.,
SlackWorkspaceSession,GitHubRepoSession) provide typed methods that abstract underlying REST, GraphQL, or SMTP protocols. - Auto-discovery occurs via
GATEKEEPER_*environment bindings scanned at deployment. - Read-only by default: Write operations require explicit user approval and audit logging.
Frequently Asked Questions
What services do Cloudflare OS Gatekeepers integrate with?
Cloudflare OS Gatekeepers integrate with Slack, GitHub, Google Workspace (Gmail, Drive, Calendar), Linear, Home Assistant, generic email (SMTP/IMAP), Model Context Protocol (MCP) servers, MCP Portal, Cloudflare Observability, and the internal Scheduler service. Each integration exposes service-specific APIs through typed RPC sessions.
How do Gatekeepers handle authentication with third-party services?
Each Gatekeeper implements its own OAuth 2.0 flow using CLIENT_ID and CLIENT_SECRET environment variables. The Slack Gatekeeper uses user-level xoxp tokens, GitHub uses OAuth App scopes (repo, read:user), and Google uses configurable OAuth 2.0 scopes. MCP Gatekeepers support dynamic client registration for server-to-server authentication.
Are Gatekeeper operations read-only or can they write data?
Gatekeepers operate read-only by default. Write operations—such as creating GitHub issues, sending emails, or posting Slack messages—are intercepted and queued for explicit user approval. Once approved, these mutations execute and are recorded as actions in the backend audit log.
How do I access a Gatekeeper session in my Gadget code?
Access Gatekeeper sessions through the environment object using the binding name (e.g., env.GATEKEEPER_SLACK). Cast the binding to the appropriate session type (such as SlackWorkspaceSession or GitHubRepoSession) to gain autocomplete and type safety for RPC methods. All session types are defined in their respective src/types.d.ts files.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →