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:
@@ -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);
|
||||
|
||||
@@ -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() }),
|
||||
|
||||
Reference in New Issue
Block a user