Skip to content

Commit ce3e49b

Browse files
committed
Enable passing custom payload in the trigger-task MCP tool
1 parent e00afc1 commit ce3e49b

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,25 @@ server.tool(
2424
"trigger-task",
2525
"Trigger a task",
2626
{
27-
id: z.string().describe("The id of the task to trigger"),
27+
id: z.string().describe("The ID of the task to trigger"),
28+
payload: z
29+
.string()
30+
.transform((val, ctx) => {
31+
try {
32+
return JSON.parse(val);
33+
} catch {
34+
ctx.addIssue({
35+
code: z.ZodIssueCode.custom,
36+
message: "The payload must be a valid JSON string",
37+
});
38+
return z.NEVER;
39+
}
40+
})
41+
.describe("The payload to pass to the task run, must be a valid JSON"),
2842
},
29-
async ({ id }) => {
43+
async ({ id, payload }) => {
3044
const result = await sdkApiClient.triggerTask(id, {
31-
// TODO: enable the user to pass in a custom payload
32-
payload: {},
45+
payload,
3346
});
3447

3548
const taskRunUrl = `${dashboardUrl}/projects/v3/${projectRef}/runs/${result.id}`;

0 commit comments

Comments
 (0)