MCP Bridgelement
Cloudflare Worker fetch handler for MCP, providing identity, enforcement, persistent storage (D1), and telemetry collection.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP BridgelementEvaluate this action against our policy and store the telemetry event"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Bridgelement
Bridgelement is a standalone, provider-agnostic MCP (Model Context Protocol) bridge that delivers policy enforcement, identity resolution, persistent storage, and telemetry collection for any LLM provider, agent framework, or local daemon. It is a complete, independently deployable product.
The bridge works with any MCP-compatible client.
Endpoints
Production: https://bridgelement.drdeeks.xyz/mcp
Endpoint | Method | Auth | Purpose |
| GET | Public | Tools discovery (MCP |
| POST | Required | MCP JSON-RPC ( |
| GET | Public | Health check + version |
| GET | Public | OAuth 2.0 Authorization Server Metadata (RFC 8414) |
| GET | Public | MCP Server Metadata |
| GET | Public | JSON Web Key Set |
| POST | Public | Dynamic Client Registration (RFC 7591) |
| GET | User | Authorization Endpoint (PKCE) |
| POST | Client | Token Endpoint |
| POST | Client | Token Introspection (RFC 7662) |
| POST | Required | Batch telemetry ingestion |
Related MCP server: universal-memory
Quick Start
Local Development
# From the plugin directory
cd plugins/bridgelement
npm install
npm testDeploy to Cloudflare Workers
Create D1 database and note its ID
Configure
wrangler.jsoncwith the D1 database IDRun migrations:
npx wrangler d1 migrations apply ack-universalSet Worker secrets (via
wrangler secret putor dashboard):ACK_BOOTSTRAP_TOKEN— Admin bootstrap token (NOT a user identity)ACK_PROVIDER— Provider identity (default:agnostic)ACK_DEFAULT_AGENT— Default agent ID (default:default-agent)
Deploy:
npx wrangler deployPoint any MCP client at
https://bridgelement.drdeeks.xyz/mcp
MCP Client Configuration
{
"mcpServers": {
"bridgelement": {
"command": "npx",
"args": ["mcp-remote", "https://bridgelement.drdeeks.xyz/mcp"]
}
}
}Or via HTTP transport directly.
What This Is
Cloudflare Worker
fetchhandler atPOST /mcp(andGET /mcpfor tools discovery)D1 schema in
migrations/(MemoryStore for local testing)Identity derived from the authenticated connection, never from
user_idarguments supplied by the modelEnforcement via vendored
evaluatePolicyengine — same logic as local daemonsFail-closed storage/worker failures return
decision: unavailable, neverallowNo
@modelcontextprotocol/sdk, no Apps SDK widget, no nested MCP server
Why It Exists
LLM providers and agent frameworks need a neutral, auditable enforcement layer that:
Resolves identity from the actual authenticated connection (OAuth, JWT, Access, etc.)
Evaluates policy against versioned profiles stored in durable storage
Emits canonical telemetry for RL, evaluation, analytics, replay, and dataset generation
Runs anywhere — Cloudflare Workers, Node.js, Deno, Bun — with the same logic
Depends on nothing — zero external npm dependencies for core enforcement
Contracts, Schemas & Protocols
MCP Contract (vendor/mcp-contract)
Defines the complete MCP tool surface exposed by the bridge:
Tool | Purpose |
| Current mode, profile, provider, installation |
| Full active profile |
| All profiles for the tenant |
| Resolved policy for a profile |
| Decision history |
| Profile management |
| Habit configuration |
| Switch enforcement mode |
| Core enforcement — evaluates tool/command against policy |
| Acknowledge a held action |
| Record an external decision |
| Telemetry ingestion & query |
| Component registry |
| Attribute registry |
| Event schema registry |
| Intervention log |
| Watchdog lease reporting |
| GDPR/export |
| Revoke installation |
Each tool has a complete JSON Schema (inputSchema / outputSchema) for MCP introspection.
Config Schema (vendor/config-schema)
Validates and normalizes profile structures:
defaultProfile(input)— Returns a complete profile with defaultsvalidateProfile(input)— Returns{ ok, profile?, errors[] }profileToPolicy(profile)— Compiles profile → policy forevaluatePolicy
Protocol (vendor/protocol)
Core protocol constants and effects:
EFFECTS = { ALLOW, DENY, HOLD }EVENT_TYPE— Canonical event type enumPolicy evaluation result shape
Events (vendor/events)
Telemetry event infrastructure:
EVENT_TYPE— All canonical event types (session, episode, task, run, policy, tool, habit, ack, protocol, component, attribute, schema, intervention, watchdog)createEventSink(service, env, store, identity)— Creates a sink for appending eventsredact(payload)— PII redaction for event payloads
Core (vendor/core)
Policy engine:
evaluatePolicy({ tool, command }, policy)— Returns{ effect, decisionId, reasonCodes }profileToPolicy(profile)— Compiles profile → policy object
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ Bridgelement │
│ ┌──────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Identity │ │ Enforcement │ │ Storage │ │
│ │ Resolution │──▶│ (evaluatePolicy)│◀──│ (D1 / Memory) │ │
│ │ (agnostic) │ │ (vendored) │ │ (pluggable) │ │
│ └──────────────┘ └──────────────────┘ └──────────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Telemetry Collection │ │
│ │ enforcement_events (D1) / JSONL (local) / custom sink │ │
│ └──────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘Data Flow
Request arrives at
POST /mcpwith MCP JSON-RPCIdentity resolved from headers (OAuth, CF Access, test header, etc.)
Tool dispatched to handler in
tools.jsProfile loaded from storage (D1 or Memory)
Policy evaluated via vendored
evaluatePolicyDecision recorded in
tool_decisionstableRL event emitted to
enforcement_eventswith hierarchical IDsResponse returned to client with decision + telemetry metadata
Hierarchical Event IDs
Every event carries full hierarchy for RL traceability:
sessionId → episodeId → taskId → runIdCounterfactual proposedAction is always recorded alongside the actual decision.
Configuration
Environment Variable | Description | Default |
| Service identity for telemetry |
|
| Event sink: |
|
| D1 Worker endpoint for local→hosted | — |
| Admin bootstrap token (NOT user identity) | — |
| Provider identity for identity resolution |
|
| Default agent ID when not provided |
|
| Default workspace for CF Access auth | — |
Project Structure
plugins/bridgelement/
├── src/
│ ├── index.js # Worker entry point (fetch handler)
│ ├── mcp.js # MCP protocol handler (JSON-RPC)
│ ├── auth.js # Identity extraction from request
│ ├── oauth.js # OAuth 2.0 / OIDC endpoints
│ ├── enforcement.js # Policy evaluation (vendored engine)
│ ├── ids.js # ID generation utilities
│ ├── rl-events.js # Telemetry event building & emission
│ ├── tools.js # MCP tool definitions & handlers
│ └── storage/
│ ├── d1.js # D1 storage adapter (production)
│ └── memory.js # In-memory storage (tests/local)
├── migrations/
│ ├── 0001_init.sql # Core schema (workspaces, users, profiles, decisions)
│ ├── 0001_init_down.sql # Rollback for 0001
│ ├── 0002_rl_events.sql # RL events table (enforcement_events)
│ ├── 0002_rl_events_down.sql # Rollback for 0002
│ ├── 0003_universal_telemetry.sql # Telemetry registry
│ └── 0003_universal_telemetry_down.sql # Rollback for 0003
├── vendor/
│ ├── mcp-contract/ # MCP tool definitions & schemas
│ ├── config-schema/ # Profile validation & policy compilation
│ ├── protocol/ # Core protocol constants & effects
│ ├── events/ # Event types, sinks, redaction
│ └── core/ # Policy engine (evaluatePolicy)
├── wrangler.jsonc # Cloudflare Worker configuration
├── package.json
├── AGENTS.md # Agent-facing architecture & gotchas
└── README.md # This fileIntegration
As an MCP Server
Any MCP-compatible client can connect:
{
"mcpServers": {
"bridgelement": {
"command": "npx",
"args": ["mcp-remote", "https://bridgelement.drdeeks.xyz/mcp"]
}
}
}Or via HTTP transport directly.
As a Library
Import individual modules for custom integrations:
import { evaluatePolicy } from './vendor/core/src/index.js';
import { defaultProfile, validateProfile } from './vendor/config-schema/src/profile.js';
import { EVENT_TYPE, createEventSink } from './vendor/events/src/index.js';Identity Integration
The bridge extracts identity from:
OAuth 2.0 Bearer tokens (via
/.well-known/oauth-authorization-serverdiscovery)Cloudflare Access:
cf-access-authenticated-user-email+x-ack-workspace-idTest header:
x-ack-test-identity(whenACK_ALLOW_TEST_IDENTITY=1)Bootstrap token:
Authorization: Bearer <token>(admin only, NOT user identity)
Model-supplied user_id / workspace_id in tool arguments are always ignored.
Authentication & Discovery
The bridge implements OAuth 2.0 / OIDC discovery for MCP clients:
GET /.well-known/oauth-authorization-server— Authorization server metadataGET /.well-known/mcp— MCP server metadata and capabilitiesGET /.well-known/jwks.json— JSON Web Key SetPOST /oauth/register— Dynamic client registrationGET /oauth/authorize— Authorization endpointPOST /oauth/token— Token endpoint (authorization_code, refresh_token, client_credentials)POST /oauth/introspect— Token introspection
Supported scopes: mcp:read, mcp:write, mcp:tools
Telemetry
All enforcement decisions emit canonical events to enforcement_events (D1) with:
Full hierarchical IDs:
sessionId → episodeId → taskId → runIdCounterfactual
proposedActionfor RL trainingRedacted payloads (PII stripped via
redact())Versioned schemas via telemetry registry
Query via ack_list_events MCP tool or POST /events for batch ingestion.
License
MIT © @the-federation/bridgelement
This server cannot be deployed
Maintenance
Related MCP Connectors
Build, validate, and deploy multi-agent AI solutions from any AI environment.
Hosted runtime for persistent agent teams, durable workflows, memory, schedules, and goals.
Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.
Document hosting and encrypted agent memory with multi-tenant persistence.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA local capability layer for AI agents providing persistent memory, credential management, connectors, and activity tracking.MIT
- AlicenseCqualityAmaintenanceA vendor-agnostic cognitive persistence layer for AI agents. Eliminate the "repetition tax" by transporting your context, preferences, and history across sessions. Features an auto-adaptation engine that syncs global instructions to ensure operational cohesion and optimize token usage across any LLM or multi-agent workflow.386Apache 2.0
- AGPL 3.0
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to maintain persistent personal memory and portable skills across MCP-compliant clients, with hybrid semantic recall and deterministic SQL analytics.-