Skip to content

Commit 985a11a

Browse files
committed
improve calculations
1 parent 111952e commit 985a11a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

apps/workers-observability/src/tools/observability.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ This tool provides three primary views of your Worker data:
5454
- Before applying filters, use the observability_keys and observability_values tools to confirm available filter fields and the correct filter value to add unless you have the data in a response from a previous query.
5555
- Common filter fields: $metadata.service, $metadata.trigger, $metadata.message, $metadata.level, $metadata.requestId,
5656
57+
## Calculation Best Practices
58+
- Before applying calculations, use the observability_keys tools to confirm key that should be used for the calculation
59+
5760
## Troubleshooting
5861
- If no results are returned, suggest broadening the time range or relaxing filters
5962
- For errors about invalid fields, recommend using observability_keys to see available options

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,14 @@ export const zQueryFilter = z.object({
5959
6060
• DO NOT guess keys - always use verified keys from either:
6161
- Previous query results
62-
- The '/keys' endpoint response
62+
- The observability_keys response
6363
6464
• PREFERRED KEYS (faster & always available):
6565
- $metadata.service: Worker service name
6666
- $metadata.origin: Trigger type (e.g., fetch, scheduled, etc.)
6767
- $metadata.trigger: Trigger type (e.g., GET /users, POST /orders, etc.)
6868
- $metadata.message: Log message text (present in nearly all logs)
6969
- $metadata.error: Error message (when applicable)
70-
71-
• ADVANCED USAGE:
72-
When using the '/keys' endpoint, set limit=1000+ to retrieve comprehensive key options
73-
without needing additional filtering
7470
`),
7571
operation: zQueryOperation,
7672
value: zPrimitiveUnion.optional().describe(`Filter comparison value. IMPORTANT:
@@ -99,7 +95,12 @@ export const zQueryFilter = z.object({
9995
`)
10096

10197
export const zQueryCalculation = z.object({
102-
key: z.string().optional(),
98+
key: z.string().optional().describe(`The key to use for the calculation. This key must exist in the logs.
99+
Use the Keys endpoint to confirm that this key exists
100+
101+
• DO NOT guess keys - always use verified keys from either:
102+
- Previous query results
103+
- The observability_keys response`),
103104
keyType: z.enum(['string', 'number', 'boolean']).optional(),
104105
operator: zQueryOperator,
105106
alias: z.string().optional(),
@@ -393,7 +394,9 @@ export const zKeysRequest = z.object({
393394
.default([])
394395
.describe('Leave this empty to use the default datasets'),
395396
filters: z.array(zQueryFilter).default([]),
396-
limit: z.number().optional(),
397+
limit: z.number().optional().describe(`
398+
• ADVANCED USAGE:
399+
set limit=1000+ to retrieve comprehensive key options without needing additional filtering`),
397400
needle: zSearchNeedle.optional(),
398401
keyNeedle: zSearchNeedle.optional()
399402
.describe(`If the user makes a suggestion for a key, use this to narrow down the list of keys returned.

0 commit comments

Comments
 (0)