Skip to content

Commit f77355c

Browse files
authored
fix(mcp-common): support workflow eventType in observability schema (#361)
Add 'workflow' to the eventType enum and make wallTimeMs/cpuTimeMs optional on zCloudflareEvent. Cloudflare Workflow events emit eventType: "workflow" and do not always carry the time fields, so the workers-observability MCP's query_worker_observability tool was rejecting any response that contained a workflow event with a Zod validation error, returning no data to the caller. Made-with: Cursor
1 parent 17a9785 commit f77355c

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@repo/mcp-common': patch
3+
---
4+
5+
fix(mcp-common): allow `workflow` `eventType` and treat `wallTimeMs`/`cpuTimeMs` as optional in observability response schema
6+
7+
The Workers Observability response schema (`zCloudflareMiniEvent` / `zCloudflareEvent` in `packages/mcp-common/src/types/workers-logs.types.ts`) was missing `'workflow'` from the `eventType` enum, and `zCloudflareEvent` re-declared `cpuTimeMs` / `wallTimeMs` as required. Cloudflare Workflow events emit `eventType: "workflow"` and do not always include the time fields, so the workers-observability MCP's `query_worker_observability` tool would reject any response containing a workflow event with a Zod validation error and return no data to the caller.
8+
9+
This left the MCP unable to surface logs from any Worker built on Cloudflare Workflows. Adding `'workflow'` to the enum and making the time fields optional unblocks those queries.

packages/mcp-common/src/types/workers-logs.types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ export const zCloudflareMiniEvent = z.object({
259259
'tail',
260260
'rpc',
261261
'websocket',
262+
'workflow',
262263
'unknown',
263264
]),
264265
entrypoint: z.string().optional(),
@@ -287,8 +288,8 @@ export const zCloudflareEvent = zCloudflareMiniEvent.extend({
287288
)
288289
.optional(),
289290
dispatchNamespace: z.string().optional(),
290-
wallTimeMs: z.number(),
291-
cpuTimeMs: z.number(),
291+
wallTimeMs: z.number().optional(),
292+
cpuTimeMs: z.number().optional(),
292293
})
293294

294295
const zSourceSchema = z.object({

0 commit comments

Comments
 (0)