@@ -3,7 +3,7 @@ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
33import { z } from "zod" ;
44import { logger } from "../utilities/logger.js" ;
55import { CliApiClient } from "../apiClient.js" ;
6- import { ApiClient } from "@trigger.dev/core/v3" ;
6+ import { ApiClient , RunStatus } from "@trigger.dev/core/v3" ;
77import polka from "polka" ;
88
99let projectRef : string ;
@@ -39,6 +39,7 @@ server.tool(
3939 }
4040 } )
4141 . describe ( "The payload to pass to the task run, must be a valid JSON" ) ,
42+ // TODO: expose more parameteres from the trigger options
4243 } ,
4344 async ( { id, payload } ) => {
4445 const result = await sdkApiClient . triggerTask ( id , {
@@ -58,6 +59,60 @@ server.tool(
5859 }
5960) ;
6061
62+ server . tool (
63+ "list-runs" ,
64+ "List task runs" ,
65+ {
66+ filters : z
67+ . object ( {
68+ status : RunStatus . optional ( ) . describe (
69+ "The status of the run. Can be WAITING_FOR_DEPLOY, QUEUED, EXECUTING, REATTEMPTING, or FROZEN"
70+ ) ,
71+ taskIdentifier : z
72+ . union ( [ z . array ( z . string ( ) ) , z . string ( ) ] )
73+ . optional ( )
74+ . describe ( "The identifier of the task that was run" ) ,
75+ version : z
76+ . union ( [ z . array ( z . string ( ) ) , z . string ( ) ] )
77+ . optional ( )
78+ . describe ( "The version of the worker that executed the run" ) ,
79+ from : z
80+ . union ( [ z . date ( ) , z . number ( ) ] )
81+ . optional ( )
82+ . describe ( "Start date/time for filtering runs" ) ,
83+ to : z . union ( [ z . date ( ) , z . number ( ) ] ) . optional ( ) . describe ( "End date/time for filtering runs" ) ,
84+ period : z . string ( ) . optional ( ) . describe ( "Time period for filtering runs" ) ,
85+ bulkAction : z
86+ . string ( )
87+ . optional ( )
88+ . describe ( "The bulk action ID to filter the runs by (e.g., bulk_1234)" ) ,
89+ tag : z
90+ . union ( [ z . array ( z . string ( ) ) , z . string ( ) ] )
91+ . optional ( )
92+ . describe ( "The tags that are attached to the run" ) ,
93+ schedule : z
94+ . string ( )
95+ . optional ( )
96+ . describe ( "The schedule ID to filter the runs by (e.g., schedule_1234)" ) ,
97+ isTest : z . boolean ( ) . optional ( ) . describe ( "Whether the run is a test run or not" ) ,
98+ batch : z . string ( ) . optional ( ) . describe ( "The batch identifier to filter runs by" ) ,
99+ } )
100+ . describe ( "Parameters for listing task runs" ) ,
101+ } ,
102+ async ( { filters } ) => {
103+ const { data, pagination } = await sdkApiClient . listRuns ( filters ) ;
104+
105+ return {
106+ content : [
107+ {
108+ type : "text" ,
109+ text : JSON . stringify ( { data, pagination } , null , 2 ) ,
110+ } ,
111+ ] ,
112+ } ;
113+ }
114+ ) ;
115+
61116const app = polka ( ) ;
62117app . get ( "/sse" , ( _req , res ) => {
63118 mcpTransport = new SSEServerTransport ( "/messages" , res ) ;
0 commit comments