cloudflare / cloudflare/mcp-server-cloudflare

Workers Observability: custom console.log fields not returned in events view

Open
#342 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.2k
Forks
514
Avg merge
1d 21h
Merged PRs (30d)
2

Description

## Problem

When querying Workers logs via the `workers-observability` MCP server's **events view**, custom fields from structured `console.log()` calls are not included in the response. The fields are indexed and work for **filtering** and **calculations/groupBy**, but their values are never returned in event results.

### Example

A Worker logging:
```ts
console.log({ event: "sync_complete", userId: "abc-123", synced: 10, durationMs: 1307 })
```

**Cloudflare Dashboard** shows the full event with custom fields at the top level:
```json
{
"event": "sync_complete",
"userId": "abc-123",
"synced": 10,
"durationMs": 1307,
"$workers": { ... },
"$metadata": { "type": "cf-worker", ... }
}
```

**MCP events view** returns the same event (same `$metadata.id`) without the custom fields:
```json
{
"dataset": "cloudflare-workers",
"timestamp": 1775208144119,
"source": {},
"$workers": { ... },
"$metadata": { ... }
}
```

### What works vs what doesn't

| Feature | Custom fields work? |
|---------|-------------------|
| Filtering (`event eq "sync_complete"`) | Yes |
| `observability_values` (list values for `event`, `userId`) | Yes |
| Calculations with groupBy (count by `event` + `userId`) | Yes |
| **Events view — seeing the actual field values** | **No** |

### Current workaround

We currently have to call the REST API directly via a custom script to bypass the MCP and get the full event payload:

```js
const url = `https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/workers/observability/telemetry/query`;
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${API_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(query), // same query format as MCP
});
const data = await response.json();
const events = data.result?.events?.events; // these DO include custom fields
```

The API returns the custom fields correctly — it's only the MCP response that strips them.

## Question

Is this intentional, or is there a recommended way to retrieve the full console.log content through the MCP server that we're missing?

Contributor guide

Open the contributing guide

Research direction

Start at the workers-observability MCP server's events view and trace how the telemetry query response is mapped into event results. Compare that mapping with the REST endpoint response, focusing on structured console.log custom fields; done means event results include those fields while filtering, observability_values, and groupBy behavior remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.