Skip to content

Commit af3af9c

Browse files
committed
Add MCP tool to get a single run
This can be used in combination with the trigger-task tool from LLMs to show details about the run after triggering the task.
1 parent 1d7224d commit af3af9c

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
22
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
3-
import { z } from "zod";
3+
import { optional, union, z } from "zod";
44
import { logger } from "../utilities/logger.js";
55
import { CliApiClient } from "../apiClient.js";
66
import { ApiClient, RunStatus } from "@trigger.dev/core/v3";
@@ -61,7 +61,7 @@ server.tool(
6161

6262
server.tool(
6363
"list-runs",
64-
"List task runs",
64+
"List task runs. This returns a paginated list which shows the details of the runs, e.g., status, attempts, cost, etc.",
6565
{
6666
filters: z
6767
.object({
@@ -113,6 +113,26 @@ server.tool(
113113
}
114114
);
115115

116+
server.tool(
117+
"get-run",
118+
"Retrieve the details of a task run, e.g., status, attempts, cost, etc.",
119+
{
120+
runId: z.string().describe("The ID of the task run to get"),
121+
},
122+
async ({ runId }) => {
123+
const result = await sdkApiClient.retrieveRun(runId);
124+
125+
return {
126+
content: [
127+
{
128+
type: "text",
129+
text: JSON.stringify(result, null, 2),
130+
},
131+
],
132+
};
133+
}
134+
);
135+
116136
const app = polka();
117137
app.get("/sse", (_req, res) => {
118138
mcpTransport = new SSEServerTransport("/messages", res);

0 commit comments

Comments
 (0)