-
-
Notifications
You must be signed in to change notification settings - Fork 703
Add support for running a local MCP server via the dev
CLI command
#1785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5c0158e
Expose a basic version of the MCP server as an option for the `dev` C…
myftija e00afc1
Use the v2 run engine by default in the SDK API client
myftija ce3e49b
Enable passing custom payload in the trigger-task MCP tool
myftija 1d7224d
Add MCP tool to list runs
myftija af3af9c
Add MCP tool to get a single run
myftija 2e7b1a7
Make the MCP server port configurable via a flag in the `dev` command
myftija 9cd6d40
Shut down the MCP server when the dev session stops
myftija b6b25b0
Add MCP tool to cancel task runs
myftija ed1f4ce
Expose a new API endpoint to list events for a given task run
myftija 2e2632d
Add new MCP tool to list the logs for a run
myftija 603c903
Add MCP tool to list all available tasks and enable fuzzy task matching
myftija 7d65aa9
Describe the MCP server feature in the readme
myftija File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"mcpServers": { | ||
"trigger.dev": { | ||
"url": "http://localhost:3333/sse" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { json } from "@remix-run/server-runtime"; | ||
import { z } from "zod"; | ||
import { getTaskEventStoreTableForRun } from "~/v3/taskEventStore.server"; | ||
import { createLoaderApiRoute } from "~/services/routeBuilders/apiBuilder.server"; | ||
import { eventRepository } from "~/v3/eventRepository.server"; | ||
import { ApiRetrieveRunPresenter } from "~/presenters/v3/ApiRetrieveRunPresenter.server"; | ||
|
||
const ParamsSchema = z.object({ | ||
runId: z.string(), // This is the run friendly ID | ||
}); | ||
|
||
// TODO: paginate the results | ||
export const loader = createLoaderApiRoute( | ||
{ | ||
params: ParamsSchema, | ||
allowJWT: true, | ||
corsStrategy: "all", | ||
findResource: (params, auth) => { | ||
return ApiRetrieveRunPresenter.findRun(params.runId, auth.environment); | ||
}, | ||
shouldRetryNotFound: true, | ||
authorization: { | ||
action: "read", | ||
resource: (run) => ({ | ||
runs: run.friendlyId, | ||
tags: run.runTags, | ||
batch: run.batch?.friendlyId, | ||
tasks: run.taskIdentifier, | ||
}), | ||
superScopes: ["read:runs", "read:all", "admin"], | ||
}, | ||
}, | ||
async ({ resource: run }) => { | ||
const runEvents = await eventRepository.getRunEvents( | ||
getTaskEventStoreTableForRun(run), | ||
run.friendlyId, | ||
run.createdAt, | ||
run.completedAt ?? undefined | ||
); | ||
|
||
// TODO: return only relevant fields, avoid returning the whole events | ||
return json( | ||
{ | ||
events: runEvents.map((event) => { | ||
return JSON.parse( | ||
JSON.stringify(event, (_, value) => | ||
// needed as JSON.stringify doesn't know how to handle BigInt values by default | ||
typeof value === "bigint" ? value.toString() : value | ||
) | ||
); | ||
}), | ||
}, | ||
{ status: 200 } | ||
); | ||
} | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to implement pagination.
The TODO comment correctly identifies the need for pagination. Without it, large result sets could cause performance issues or timeout errors, especially if runs can generate many events.
Consider implementing standard pagination parameters (limit/offset or cursor-based) and returning metadata about total count and next page.