# Building The Plumber: The Journey **A late-night-to-next-morning build of an MCP server + audit dashboard wrapping WorkOS Pipes** *(Originally called "Pipes Audit" — rebranded because who works with pipes? Plumbers.)* --- ## What We Built An MCP (Model Context Protocol) server that lets Claude read a user's Gmail and Google Calendar through WorkOS Pipes, with every access logged to an audit trail. Plus a Next.js dashboard showing live agent activity, the Pipes connection widget, API key management, and copyable MCP config. ``` Claude ──stdio──> MCP Server ──> WorkOS Pipes (fresh token) ──> Gmail / Calendar API │ v audit.db (SQLite) ^ │ Dashboard <──poll──> API Server (port 3001) ``` --- ## The Timeline ### Phase 1: Greenfield Setup (~4am) > "Read all files in the planning/ folder, starting with AGENT_INSTRUCTIONS.md. Then build the MCP server first, verify it works, then build the dashboard. Ask questions as needed. Run concurrently as needed. We're in a greenfield project, this should be fun." Started with pre-written plan docs (project overview, MCP server plan, dashboard plan, types/mocks spec, integration guide). The plans were detailed — verified package versions, exact file structures, code snippets — the kind of thing you write when you know an AI agent is going to execute them. **First hiccup:** The planning folder was at `plans/` not `planning/`. Minor, but a sign of things to come — the gap between "what's in your head" vs "what's on disk." The initial build went smoothly: MCP server with mock tools (`list_connections`, `call_api`, `get_audit_log`), Express REST API, SQLite audit store, Next.js dashboard with Tailwind. All working with mock data within ~10 minutes. ### Phase 2: Making It Real — The Pipes Widget (~4:10am) > "But... this is just a mock UI, right? What do you need to actually embed the Pipes widget & start getting real data through this?" This is where things got interesting. Swapping from mocks to real WorkOS integration. > "Yes let's crack on — we have API access, we have a working account, let's goooooo" **Challenge 1: Widget Token Endpoint** The Pipes widget needs an auth token from `workos.widgets.getToken()`. We had to add a `/api/widget-token` endpoint to the API server. But: ``` GET https://api.workos.com/_widgets/DataIntegrations/mine 404 (Not Found) ``` The widget was hitting a 404. The issue: the widget token needed the correct scopes (`widgets:pipes:manage`), and the WorkOS SDK types didn't export the scope string as a union type, so we had to cast: `'widgets:pipes:manage' as any`. A small TypeScript annoyance that hinted at the SDK being newer than its type definitions. **Challenge 2: Where to configure allowed origins?** > "Where do I add localhost:3000 as the web origin in the WorkOS dash?" The dashboard needed `http://localhost:3000` registered as an allowed redirect URI in the WorkOS dashboard. Not immediately obvious where this lives in the WorkOS settings UI. **Challenge 3: Widget 500 errors** ``` GET http://localhost:3001/api/widget-token?user_id=...&organization_id=... 500 (Internal Server Error) ``` The widget token generation kept failing. The fix was ensuring the WorkOS SDK was properly initialized with the API key and that the user ID/org ID being passed matched real WorkOS entities. Once that clicked, the Pipes widget loaded and Gmail could be connected. > "Great — so now that works (aside from some ugly formatting of the dashboard)." ### Phase 3: Real Gmail via MCP (~4:47am - 5am) > "So now let's work through the purpose of this app — can we start an MCP server? Can we configure the MCP server URL/details in the UI?" This was the core feature: replace the mock `call_api` tool with real `list_emails` and `read_email` tools that go through WorkOS Pipes to hit the actual Gmail API. **Key design decision:** User ID and Org ID come from environment variables, not tool parameters. Claude doesn't need to know or pass these. Simpler tool schemas, less risk of ID leakage. **Key design decision:** Fresh token every call. No caching. `workos.pipes.getAccessToken()` is called on every single tool invocation. If a user revokes Gmail access between calls, the very next call fails. Security-first. **The Pipes `getAccessToken` response shape** was a bit surprising: ```typescript const result = await workos.pipes.getAccessToken({ provider, userId, organizationId }); // result.accessToken.accessToken <-- nested .accessToken.accessToken ``` The double-nesting (`result.accessToken.accessToken`) isn't immediately intuitive from the docs. You'd expect `result.accessToken` to be the string, but it's an object with its own `.accessToken` property. Not a bug, but a "read the types carefully" moment. Built the Gmail client (`gmail-client.ts`) from scratch — `listMessages`, `getMessage`, base64url decoding, header extraction, multipart body parsing. This was straightforward REST API work. **Late-night commit, call it a night at 5am:** > "Wrap this up into a new GitHub repo that's private on nbarraclough & we'll settle here for the night" > "Can you quickly add a little readme to that repo though, just explaining what's been done, how to start the server, etc, in case I lose this convo?" ### Phase 4: Morning — MCP Server Connection Issues (~2:45pm next day) > "Good morning Claude. Give me a run down please of where we're at with this project & where we need to take it." Started by trying to actually use the MCP server in Claude Desktop. **Challenge 4: Server disconnected error** > "I get a server disconnected error when I use that" The MCP config pointed to the right files, but the server was crashing on startup. The issue was the `DB_PATH` — it needed an absolute path, and the `cwd` in the MCP config needed to match where the built files lived. Also, `dotenv` wasn't loading in MCP mode because the working directory was different from where `.env` lived. **Challenge 5: `data_integration` not found** > "The data_integration is not found...?" When trying to get a Gmail token via Pipes, the error was about the provider string. The Pipes API expected `'gmail'` as the provider, but there was confusion about whether it should be `'gmail'`, `'google-mail'`, or `'data_integration'`. This was a documentation gap — the provider strings accepted by `workos.pipes.getAccessToken()` aren't prominently listed. This required reading the WorkOS docs on Pipes more carefully and testing different provider strings until one worked. ### Phase 5: Dashboard Polish (~3:12pm) > "Can you please improve the UI & UX of our dashboard, the styling is all off." > "The accent colour you can use is Yves Klein blue, which is my favourite colour." The dashboard got a visual overhaul. But the real UX issues were with the embedded WorkOS widgets: **Challenge 6: Widget height/sizing** > "Why is the integrations widget so long? It should only be as long as the number of services we have" > "No that just made the boundary around the widget smaller. Reverse that change." The Pipes widget rendered inside a Radix UI `` wrapper that had a hardcoded `min-height`. The widget itself couldn't be resized — it's an iframe controlled by WorkOS. The fix was constraining the container's `max-height` and setting `overflow: hidden`. A CSS workaround for what should ideally be a widget configuration option. > "I think it's `
` ... that is setting the min-height" The user had to dig into the DOM to figure this out. The Radix Theme root was injecting styles that fought with the widget layout. ### Phase 6: The API Key Revelation (~3:26pm) > "One of the things I didn't expect was having to provide my user ID & my WorkOS API key to make the requests. I was hoping that our product would handle that to a degree, obscure things as it were." This was the biggest "aha" moment. The initial MCP config required three environment variables: ```json { "env": { "WORKOS_API_KEY": "sk_test_...", "WORKOS_USER_ID": "user_...", "WORKOS_ORG_ID": "org_..." } } ``` Exposing `sk_test_...` to end users is a non-starter in production. User IDs are implementation details. The whole point of the dashboard is to abstract this away. **The solution:** Use WorkOS Organization API Keys as a proxy auth mechanism. The API server (which holds the real `sk_test_...`) validates the org API key, looks up the user, and proxies the Pipes token request. The MCP config becomes: ```json { "env": { "PIPES_API_URL": "http://localhost:3001", "PIPES_API_KEY": "wos_api_key_..." } } ``` No `sk_test_...`. No user ID. No org ID. Just one key. > "WorkOS has an API key widget — is that useful or relevant?" Yes. The API Keys widget lets users view and revoke their keys from the dashboard. We embedded it alongside the Pipes widget. ### Phase 7: API Key Integration Pain (~3:41pm - 4:25pm) **Challenge 7: API Keys widget 403** ``` GET https://api.workos.com/_widgets/ApiKeys/organization-api-keys?limit=10 403 (Forbidden) ``` The API Keys widget wouldn't load. The issue: the widget token needed an additional scope (`widgets:api-keys:manage`) alongside the Pipes scope. The fix was passing both scopes to `workos.widgets.getToken()`: ```typescript scopes: ['widgets:pipes:manage' as any, 'widgets:api-keys:manage' as any] ``` Again, the `as any` cast was needed because the SDK types didn't include these scope strings. > "Ok it works now — this element is way too long though, you need to do the same height thing you did to the integrations box" Same CSS height issue as the Pipes widget. Same fix. **Challenge 8: The full proxy flow** The token proxy (`POST /api/pipes/access-token`) required: 1. Validate the org API key via `workos.apiKeys.validateApiKey()` 2. Look up which user created the key (stored in SQLite `key_user_map` table) 3. Use that user's ID + the org ID to call `workos.pipes.getAccessToken()` 4. Return the fresh token This worked in the MCP inspector but initially failed in Claude Desktop: > "It doesn't work in Claude though — I get an error" The issue was that the Claude Desktop MCP config still had old environment variables. After generating fresh credentials and updating the config: > "It works! How can we improve on getting the model to put a better 'reason' for making the request?" ### Phase 8: Polish & Calendar Support (~4:25pm - 4:35pm) With the core flow working, rapid-fire improvements: - Pagination on the audit log (10 entries per page) - CSV export button - API Keys widget refresh after credential generation - Better `purpose` field descriptions in tool schemas (coaching Claude to write meaningful audit entries) - Hiding the "Create API Key" button on the widget (since we have our own generate flow) > "Can you add support for Google Calendar to our MCP server? I'd like to be able to retrieve calendars & events, but most users store their events on the primary calendar." Added `calendar-client.ts` following the same pattern as `gmail-client.ts`, with three new tools: `list_calendars`, `list_events`, `get_event`. The token proxy architecture (`resolveAccessToken('google-calendar')`) handled it cleanly — just a different provider string. --- ## WorkOS Product Feedback ### What Worked Well **Pipes as a token broker is genuinely useful.** The core value prop — "give me a fresh OAuth token for this user's Gmail" — is exactly what an MCP server needs. No token storage, no refresh token management, no OAuth flow implementation. Just `getAccessToken()` and go. **Fresh token per call is the right model for agents.** Every MCP tool invocation gets a fresh token. If the user revokes access, the next call fails immediately. This is how agent-to-API auth should work. **The Pipes widget is great for onboarding.** Embedding a pre-built "Connect your Gmail" widget saved days of OAuth flow implementation. Users click, authorize, done. **Organization API Keys for service-to-service auth.** Using org API keys as the auth mechanism between the MCP server and our API server was elegant. Users get one key, we handle the rest. ### What Was Frustrating **SDK type definitions lag behind features.** Widget scopes like `'widgets:pipes:manage'` and `'widgets:api-keys:manage'` aren't in the TypeScript types, requiring `as any` casts. For a product aimed at developers, this is a paper cut that happens on every integration. **`result.accessToken.accessToken` double nesting.** The Pipes `getAccessToken` response has a nested structure that isn't intuitive. `result.accessToken` is an object, not a string. You need `result.accessToken.accessToken` to get the actual token. The `result.active` boolean check is also required before accessing the token. This is the kind of thing that costs 10 minutes of debugging. **Provider strings aren't well-documented.** When calling `workos.pipes.getAccessToken({ provider: '???' })`, it's not immediately clear what string to use. Is it `'gmail'`, `'google-mail'`, `'google'`, `'data_integration'`? We hit errors until we found the right string. A prominent "supported providers" table in the docs would help. **Widget sizing is uncontrollable.** The Pipes and API Keys widgets render as iframes with their own internal sizing. The containing Radix Theme `
` sets `min-height` that fights with the layout. There's no `height`, `maxHeight`, or `compact` prop on the widget. We had to use CSS `max-height` + `overflow: hidden` as a workaround. Ideally the widget would accept size hints or have a compact mode. **Widget 403 errors aren't descriptive.** When the API Keys widget got a 403, there was no indication that it was a missing scope issue. The error was just "403 Forbidden" from `api.workos.com`. A more descriptive error ("Widget token missing required scope: widgets:api-keys:manage") would save significant debugging time. **No way to hide widget UI elements.** We wanted to hide the "Create API Key" button in the API Keys widget (since we have our own generation flow). There's no prop for this — we had to live with it or use CSS hacks. Widget customization options (hiding buttons, columns, changing labels) would be valuable. ### DevEx Improvement Suggestions 1. **Type-safe widget scopes.** Export scope strings as a TypeScript union type from the SDK. No more `as any`. 2. **Flatten the token response.** `getAccessToken()` could return `{ token: string, expiresAt: Date }` at the top level instead of nesting. 3. **Provider string constants.** Export an enum or const object: `Providers.GMAIL`, `Providers.GOOGLE_CALENDAR`, etc. Document which providers are available and what scopes they support. 4. **Widget configuration props.** Add `maxHeight`, `compact`, `hideCreateButton`, `hideColumns` props to the embeddable widgets. 5. **Descriptive widget errors.** When a widget fails to load, surface the specific reason (missing scope, invalid token, wrong org) instead of a generic 403/404. 6. **MCP server template/example.** Given that Pipes is positioned for the agent era, a reference implementation showing "here's how to build an MCP server with Pipes" would be compelling. The architecture (token proxy, audit logging, per-call fresh tokens) is non-obvious but powerful. 7. **Confusing "Confirm changes" copy when editing Pipes integration scopes.** When you edit the scopes for an existing Pipes integration, the confirmation dialog says *"Your application will not have access to new scopes until users reauthorize the installation."* This is confusing — "your application" is ambiguous (is it my app? the integration?), and "reauthorize the installation" is opaque jargon. Something like *"Users will need to reconnect this integration before the new scopes take effect"* would be clearer and use language consistent with the rest of the Pipes UI. 8. **Integration status shows "enabled" even with broken GCP config.** When you provide a client ID / client secret for a Pipes integration, the status immediately shows "enabled" — even if the underlying GCP OAuth config is wrong (e.g. requested scopes the app hasn't enabled, or the redirect URI doesn't match). The user only discovers the misconfiguration later when the OAuth flow fails at runtime. Pipes should validate the OAuth config on save — or at minimum, not show "enabled" until at least one successful token exchange has occurred. A status like "configured (untested)" or an explicit "Test connection" button would prevent false confidence. --- ## Phase 9: Replacing WorkOS Org API Keys with User-Scoped Tokens ### Why the change The initial approach used WorkOS Organization API Keys to authenticate the MCP server to the proxy. This worked — the org API key was validated via `workos.apiKeys.validateApiKey()`, mapped to a user via a `key_user_map` table, and used to fetch Pipes tokens. But it had problems: - **Org-scoped, not user-scoped.** Org API keys belong to the organization, so we needed a custom `key_user_map` table to pin each key to the user who created it — extra indirection for a fundamentally user-level operation. - **The API Keys widget shows all org keys to everyone.** In a shared org, every user can see every key. No way to filter by user without CSS hacks. - **Widget customization limitations.** We couldn't hide the "Create API Key" button (since we had our own generation flow) or filter the list — the widget is opaque. - **We were using an org-level primitive for a user-level job.** ### What replaced it A simple `user_tokens` table in SQLite: ```sql CREATE TABLE user_tokens ( token TEXT PRIMARY KEY, -- random UUID user_id TEXT NOT NULL, label TEXT, created_at TEXT NOT NULL ) ``` - `createToken(userId)` generates a UUID, stores it mapped to the user - `getUserForToken(token)` validates the token and returns the user — replaces `workos.apiKeys.validateApiKey()` + `getUserForKey()` - `listTokens(userId)` returns the user's tokens for the dashboard - `revokeToken(token, userId)` deletes a token, enforcing ownership The proxy endpoint (`POST /api/pipes/access-token`) now reads `WORKOS_ORG_ID` from the server environment instead of extracting it from the API key validation response. ### What was removed - `key_user_map` table and its methods (`storeKeyMapping`, `getUserForKey`) - `POST /api/mcp-keys` endpoint (replaced by `POST /api/mcp-tokens`) - `workos.apiKeys.validateApiKey()` call in the token proxy - `workos.organizations.createOrganizationApiKey()` call - `ApiKeysWidget.tsx` component (the WorkOS API Keys widget) - `organizationId` prop threading through `McpConfig` and `page.tsx` ### What stayed the same - `PIPES_API_KEY` env var name in MCP config — no need to break existing setups - `Authorization: Bearer ...` header format - `getAccessTokenViaProxy()` in `pipes-client.ts` — unchanged - `resolveAccessToken()` in `mcp-server.ts` — unchanged - All MCP tools, audit logging, Pipes widget --- ## Key Technical Decisions | Decision | Rationale | |----------|-----------| | Fresh token per call, no caching | Security > latency. Revocations take effect immediately. | | `purpose` field required (min 10 chars) | Accountability. Every access must be justified. | | User ID from env/proxy, not tool params | Claude doesn't need to know implementation details. | | SQLite WAL mode | Allows concurrent reads (dashboard) while MCP server writes. | | Specific tools over generic | `list_emails` > `call_api`. Easier to audit and reason about. | | User-scoped UUID tokens as proxy auth | End users never see `sk_test_...`. Simpler than org API keys, naturally user-scoped. | --- ## Phase 10: Consolidating to a Single Next.js App ### Why the change The original architecture ran two processes: the MCP server + REST API (`packages/mcp-server` on port 3001) and the Next.js dashboard (`packages/dashboard` on port 3000). The dashboard called the API server for audit logs, connections, and token management. This worked but added operational complexity — two processes to run, CORS to configure, a separate SQLite database to share. ### What changed Moved all API endpoints directly into the Next.js dashboard as API routes: - `GET /api/audit-log` — query audit entries (was on port 3001) - `POST /api/call` — simulate agent API calls (was on port 3001) - `GET /api/connections/[userId]` — user connection status (was on port 3001) - `POST /api/mcp-tokens`, `GET /api/mcp-tokens`, `DELETE /api/mcp-tokens/[token]` — token CRUD (was on port 3001) - `POST /api/pipes/access-token` — proxy endpoint for local MCP server (was on port 3001) Replaced SQLite (better-sqlite3) with Turso (libsql) for the audit store and token management. Turso works natively in serverless environments (Vercel), unlike SQLite which needs filesystem access. The dashboard went from a pure frontend to a full-stack Next.js app: frontend + API + database, all deployable as a single unit on Vercel. ### What stayed the same - `packages/mcp-server` — untouched, still works for local stdio development - All MCP tools and their behavior - The Pipes widget, audit log UI, and token management UI - The proxy auth flow (Bearer token → user lookup → Pipes token) --- ## Phase 11: Remote MCP Server via Streamable HTTP ### The problem Even with the consolidated dashboard, using The Plumber still required users to: 1. Clone the repo 2. Install dependencies 3. Build the MCP server locally 4. Configure local paths (`NEXT_PUBLIC_MCP_SERVER_PATH`, `NEXT_PUBLIC_NODE_PATH`) 5. Run a local Node.js process The whole point of the dashboard was to make things easy. Having users run a local process defeated that. ### The solution Host the MCP server on Vercel too, using the MCP SDK's **Streamable HTTP** transport. The MCP server becomes a Next.js API route (`/api/mcp`) — no local process needed. ``` BEFORE: Claude ──stdio──> Local MCP Server ──HTTP──> Vercel API (/api/pipes/access-token) AFTER: Claude ──HTTP──> Vercel (/api/mcp) ──direct──> WorkOS Pipes + Gmail/Calendar APIs ``` **Key architectural decisions:** - **Stateless mode** — `sessionIdGenerator: undefined`, `enableJsonResponse: true`. Each POST is a complete JSON-RPC round-trip. No sessions, no SSE, no WebSockets. Perfect for Vercel serverless functions which are ephemeral. - **Direct token resolution** — the local MCP server used a proxy (`/api/pipes/access-token`) because it didn't have the WorkOS API key. The remote MCP server IS the server — it resolves tokens directly via `getAccessToken(userId, provider)`. One fewer network hop. - **Per-request server creation** — each incoming request creates a fresh `McpServer` instance bound to the authenticated user's ID. No shared state between requests. This is the serverless way. ### New files | File | Purpose | |------|---------| | `lib/gmail-client.ts` | Gmail API client (copied from mcp-server, pure fetch) | | `lib/calendar-client.ts` | Google Calendar API client (copied from mcp-server, pure fetch) | | `lib/mcp-tools.ts` | `createMcpServer(userId)` factory — all 6 tools, parameterized by user | | `app/api/mcp/route.ts` | Streamable HTTP endpoint (POST/GET/DELETE handlers) | ### The Claude Desktop wrinkle The generated config initially used `"type": "streamable-http"` for Claude Desktop — which promptly errored: ``` "path": ["mcpServers", "the-plumber", "command"], "message": "Required" ``` Claude Desktop doesn't support remote HTTP MCP servers natively. It still requires `command`/`args` (stdio) configs. The solution was [mcp-remote](https://github.com/geelen/mcp-remote) — a stdio-to-HTTP bridge: ```json { "mcpServers": { "the-plumber": { "command": "npx", "args": ["-y", "mcp-remote", "https://your-app.vercel.app/api/mcp", "--header", "Authorization:${AUTH_TOKEN}"], "env": { "AUTH_TOKEN": "Bearer YOUR_TOKEN" } } } } ``` Note the `Authorization:${AUTH_TOKEN}` (no space after colon) — this works around a [known bug](https://www.npmjs.com/package/mcp-remote) where Claude Desktop mangles args with spaces. Claude Code supports HTTP transport natively: ```bash claude mcp add the-plumber --transport http -H "Authorization: Bearer TOKEN" -- URL ``` ### User experience change - **Before:** Generate token → copy 15-line JSON config → configure local node path → run local process - **After:** Generate token → paste one CLI command (Claude Code) or one JSON block (Claude Desktop) --- ## Key Technical Decisions | Decision | Rationale | |----------|-----------| | Fresh token per call, no caching | Security > latency. Revocations take effect immediately. | | `purpose` field required (min 10 chars) | Accountability. Every access must be justified. | | User ID from token, not tool params | Claude doesn't need to know implementation details. | | Stateless HTTP transport | Each request is self-contained. Perfect for serverless. No session cleanup. | | Per-request McpServer instances | No shared state between users or requests. Serverless-friendly. | | Turso over SQLite | Works in Vercel's serverless environment. No filesystem dependency. | | Specific tools over generic | `list_emails` > `call_api`. Easier to audit and reason about. | | User-scoped UUID tokens as auth | End users never see `sk_test_...`. Simpler than org API keys, naturally user-scoped. | --- ## Phase 12: WorkOS Audit Logs Integration ### The idea The Plumber already had its own local audit trail in Turso — every tool call, auth event, and token operation was logged. But the next step was integrating with WorkOS Audit Logs to push events to the platform level, giving org admins a centralized view and enabling Log Streams (Datadog, Splunk, S3). ### Implementation The `workos-audit.ts` module wraps `workos.auditLogs.createEvent()` with a feature flag, try/catch, and fire-and-forget semantics. Four domain-specific emitters cover the full event surface: - `emitToolCallEvent` — every MCP tool call (6 tools), with metadata: purpose, result, summary, duration, error - `emitAuthEvent` — sign in / sign out - `emitTokenEvent` — MCP key create / revoke - `emitOrgEvent` — org provision / user join - `emitExportEvent` — audit log export (added after initial build) All calls are non-blocking (`.catch(() => {})`) so audit failures never break the primary flow. ### Schema registration WorkOS requires event schemas to be registered before emitting events. We built `scripts/setup-audit-schemas.ts` using `workos.auditLogs.createSchema()` to register all 14 event types. Tool events carry metadata definitions (purpose, result, duration, etc.); auth and token events are metadata-free. ### What went wrong This integration had more friction than expected. Several rounds of "register schemas, emit events, hit errors, diagnose, fix, restart": **1. `actor.metadata` is required but not in the SDK types.** The `createEvent` types define actor as `{ type, id, name? }` — no metadata field. But the API rejects events without `actor: { metadata: {} }`. The error message (`incorrect or missing metadata keys`) doesn't mention the actor specifically — we only found this by curling the API directly and reading the full validation error. Fix: always spread `metadata: {}` onto the actor object. **2. Schema metadata format is unintuitive.** When calling `createSchema`, metadata field definitions use flat strings (`{ purpose: 'string' }`) not JSON Schema objects (`{ purpose: { type: 'string' } }`). The SDK serializer wraps them internally. We wrote `{ purpose: { type: 'string' } }` first (the intuitive format), which double-wrapped to `{ purpose: { type: { type: 'string' } } }` and WorkOS rejected it as invalid JSON schema. Two failed registration runs before we read the SDK serializer source code. **3. Empty `metadata: {}` on events is rejected.** If the schema defines no metadata fields but the code sends `metadata: {}`, WorkOS rejects it. The SDK serializer always includes the metadata field, so we had to conditionally omit it when there's nothing to send. **4. Admin Portal blocks iframe embedding.** We built a `/settings` page that embedded the WorkOS Admin Portal via `portal.generateLink()` in an iframe. It showed `setup.workos.com refused to connect`. WorkOS sets `X-Frame-Options` headers — the portal can't be embedded. Changed to a button that opens the portal in a new tab. **5. Finding the actual audit logs in the WorkOS dashboard.** The top-level "Audit Logs" tab in the WorkOS dashboard only shows event schema configuration. To view actual audit log events, you navigate Organization > Select an Org > Audit Logs. This isn't obvious at all — the tab name suggests you'll see logs there. ### Settings page Added `/settings` with a "Open Audit Logs Portal" button that generates a portal link via `/api/portal-link` (calls `workos.portal.generateLink({ intent: 'audit_logs' })`). The `returnUrl` points back to `/dashboard`. ### What we learned - WorkOS Audit Logs work well once configured — the event model is clean and the schema versioning is solid - But the integration path has sharp edges: undocumented required fields, unintuitive serialization, and vague error messages - The SDK types and the API requirements are out of sync in several places - Investing in a setup script (`setup-audit-schemas.ts`) that can be re-run safely was the right call — schema registration needed multiple iterations --- ## What We'd Build Next 1. **Write operations** — Send emails, create calendar events (with additional confirmation flow) 2. **More providers** — Slack, GitHub, Salesforce (Pipes supports them all) 3. **Permission scoping** — Task-scoped, time-limited tokens instead of full OAuth access 4. **Webhook-driven events** — Real-time notifications instead of polling the audit log 5. **Multi-user support** — Multiple users on the same dashboard, role-based audit access --- *Built across several sessions, Feb 10-11 2026. Multiple Claude Code sessions covering greenfield setup, real Pipes integration, dashboard polish, architecture consolidation, and remote MCP deployment.*