Skip to content

Workers Observability migrate responses to TSV's #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 2, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tag wobs api usage as mcp
  • Loading branch information
Ankcorn committed May 2, 2025
commit 3d6fbc95709e24d15bdad89587c9e98983f33290
4 changes: 4 additions & 0 deletions packages/mcp-common/src/api/workers-observability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { V4Schema } from '../v4-api'

import type { z } from 'zod'
import type { zKeysRequest, zQueryRunRequest, zValuesRequest } from '../types/workers-logs-schemas'
import { env } from 'cloudflare:workers'

type QueryRunRequest = z.infer<typeof zQueryRunRequest>

Expand All @@ -23,6 +24,8 @@ export async function queryWorkersObservability(
accountId: string,
query: QueryRunRequest
): Promise<z.infer<typeof zReturnedQueryRunResult> | null> {
// @ts-expect-error We don't have actual env in this package
const environment = env.ENVIRONMENT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably also pass through this env in the params so we don't need to expect error here.

Kinda like what do here https://github.com/cloudflare/mcp-server-cloudflare/blob/main/packages/mcp-common/src/dev-mode.ts#L6

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in a follow up on monday :)

const data = await fetchCloudflareApi({
endpoint: '/workers/observability/telemetry/query',
accountId,
Expand All @@ -32,6 +35,7 @@ export async function queryWorkersObservability(
method: 'POST',
headers: {
'Content-Type': 'application/json',
'workers-observability-origin': `workers-observability-mcp-${environment}`,
Copy link
Member

@Maximo-Guk Maximo-Guk May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can come up with a general header name, which every mcp server uses?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specific to our backend, happy to add a general one too

Copy link
Member

@Maximo-Guk Maximo-Guk May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, maybe we can set our user agent to the server name / version ( the ones pulled from package.json )

Also doesn't have to be in this PR!

},
body: JSON.stringify({ ...query, timeframe: fixTimeframe(query.timeframe) }),
},
Expand Down
Loading