Skip to content

Commit 51c75af

Browse files
committed
Use full workers logs schema for workers logs tool responses
1 parent 444f294 commit 51c75af

File tree

7 files changed

+318
-457
lines changed

7 files changed

+318
-457
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z } from 'zod'
22

3-
import { handleWorkerLogs, handleWorkerLogsKeys } from '@repo/mcp-common/src/api/logs'
3+
import { handleWorkerLogs, handleWorkerLogsKeys } from '@repo/mcp-common/src/api/workers-logs'
44

55
import type { MyMCP } from '../index'
66

@@ -16,9 +16,9 @@ const limitParam = z
1616
const minutesAgoParam = z
1717
.number()
1818
.min(1)
19-
.max(1440)
19+
.max(10080)
2020
.default(30)
21-
.describe('Minutes in the past to look for logs (1-1440, default 30)')
21+
.describe('Minutes in the past to look for logs (1-10080, default 30)')
2222
const rayIdParam = z.string().optional().describe('Filter logs by specific Cloudflare Ray ID')
2323

2424
/**
@@ -53,7 +53,7 @@ export function registerLogsTools(agent: MyMCP) {
5353
}
5454
try {
5555
const { scriptName, shouldFilterErrors, limitParam, minutesAgoParam, rayId } = params
56-
const { relevantLogs, from, to } = await handleWorkerLogs({
56+
const { logs, from, to } = await handleWorkerLogs({
5757
scriptName,
5858
limit: limitParam,
5959
minutesAgo: minutesAgoParam,
@@ -67,9 +67,8 @@ export function registerLogsTools(agent: MyMCP) {
6767
{
6868
type: 'text',
6969
text: JSON.stringify({
70-
logs: relevantLogs,
70+
logs,
7171
stats: {
72-
total: relevantLogs.length,
7372
timeRange: {
7473
from,
7574
to,
@@ -118,7 +117,7 @@ export function registerLogsTools(agent: MyMCP) {
118117
}
119118
try {
120119
const { rayId, shouldFilterErrors, limitParam, minutesAgoParam } = params
121-
const { relevantLogs, from, to } = await handleWorkerLogs({
120+
const { logs, from, to } = await handleWorkerLogs({
122121
limit: limitParam,
123122
minutesAgo: minutesAgoParam,
124123
accountId,
@@ -131,9 +130,8 @@ export function registerLogsTools(agent: MyMCP) {
131130
{
132131
type: 'text',
133132
text: JSON.stringify({
134-
logs: relevantLogs,
133+
logs,
135134
stats: {
136-
total: relevantLogs.length,
137135
timeRange: {
138136
from,
139137
to,
@@ -192,7 +190,7 @@ export function registerLogsTools(agent: MyMCP) {
192190
keys: keys.map((key) => ({
193191
key: key.key,
194192
type: key.type,
195-
lastSeen: key.lastSeen ? new Date(key.lastSeen).toISOString() : null,
193+
lastSeenAt: key.lastSeenAt ? new Date(key.lastSeenAt).toISOString() : null,
196194
})),
197195
stats: {
198196
total: keys.length,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"check:turbo": "run-turbo check",
2424
"test:ci": "run-vitest-ci",
2525
"test": "vitest run",
26-
"lint": "prettier . --write",
26+
"fix:format": "prettier . --write",
2727
"test:watch": "vitest"
2828
},
2929
"devDependencies": {

packages/mcp-common/src/api/logs.ts

Lines changed: 0 additions & 319 deletions
This file was deleted.

0 commit comments

Comments
 (0)