Skip to content

Commit 2e2632d

Browse files
committed
Add new MCP tool to list the logs for a run
This enables some basic level of debugging capabilities in combinatio with the other MCP tools
1 parent ed1f4ce commit 2e2632d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

packages/cli-v3/src/dev/mcpServer.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,26 @@ server.tool(
182182
}
183183
);
184184

185+
server.tool(
186+
"get-run-logs",
187+
"Retrieve the logs output of a task run.",
188+
{
189+
runId: z.string().describe("The ID of the task run to get"),
190+
},
191+
async ({ runId }) => {
192+
const result = await sdkApiClient.listRunEvents(runId);
193+
194+
return {
195+
content: [
196+
{
197+
text: JSON.stringify(result, null, 2),
198+
type: "text",
199+
},
200+
],
201+
};
202+
}
203+
);
204+
185205
const app = polka();
186206
app.get("/sse", (_req, res) => {
187207
mcpTransport = new SSEServerTransport("/messages", res);

packages/core/src/v3/apiClient/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,18 @@ export class ApiClient {
404404
);
405405
}
406406

407+
listRunEvents(runId: string, requestOptions?: ZodFetchOptions) {
408+
return zodfetch(
409+
z.any(), // TODO: define a proper schema for this
410+
`${this.baseUrl}/api/v1/runs/${runId}/events`,
411+
{
412+
method: "GET",
413+
headers: this.#getHeaders(false),
414+
},
415+
mergeRequestOptions(this.defaultRequestOptions, requestOptions)
416+
);
417+
}
418+
407419
addTags(runId: string, body: AddTagsRequestBody, requestOptions?: ZodFetchOptions) {
408420
return zodfetch(
409421
z.object({ message: z.string() }),

0 commit comments

Comments
 (0)