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
This commit is contained in:
saadi
2025-03-11 16:20:56 +01:00
parent ed1f4cea12
commit 2e2632d5cc
2 changed files with 32 additions and 0 deletions
+20
View File
@@ -182,6 +182,26 @@ server.tool(
}
);
server.tool(
"get-run-logs",
"Retrieve the logs output of a task run.",
{
runId: z.string().describe("The ID of the task run to get"),
},
async ({ runId }) => {
const result = await sdkApiClient.listRunEvents(runId);
return {
content: [
{
text: JSON.stringify(result, null, 2),
type: "text",
},
],
};
}
);
const app = polka();
app.get("/sse", (_req, res) => {
mcpTransport = new SSEServerTransport("/messages", res);
+12
View File
@@ -404,6 +404,18 @@ export class ApiClient {
);
}
listRunEvents(runId: string, requestOptions?: ZodFetchOptions) {
return zodfetch(
z.any(), // TODO: define a proper schema for this
`${this.baseUrl}/api/v1/runs/${runId}/events`,
{
method: "GET",
headers: this.#getHeaders(false),
},
mergeRequestOptions(this.defaultRequestOptions, requestOptions)
);
}
addTags(runId: string, body: AddTagsRequestBody, requestOptions?: ZodFetchOptions) {
return zodfetch(
z.object({ message: z.string() }),