-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(cli): Expand and improve the MCP server and dev CLI command #3224
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
Draft
ericallam
wants to merge
3
commits into
main
Choose a base branch
from
feat/mcp-dev-enhancements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,5 @@ | ||
| --- | ||
| "trigger.dev": patch | ||
| --- | ||
|
|
||
| Fix dev CLI leaking build directories on rebuild, causing disk space accumulation. Deprecated workers are now pruned (capped at 2 retained) when no active runs reference them. The watchdog process also cleans up `.trigger/tmp/` when the dev CLI is killed ungracefully (e.g. SIGKILL from pnpm). |
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,5 @@ | ||
| --- | ||
| "@trigger.dev/core": patch | ||
| --- | ||
|
|
||
| Fix `list_deploys` MCP tool failing when deployments have null `runtime` or `runtimeVersion` fields. |
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,42 @@ | ||
| --- | ||
| "@trigger.dev/core": patch | ||
| "trigger.dev": patch | ||
| --- | ||
|
|
||
| MCP server improvements: new tools, bug fixes, and new flags. | ||
|
|
||
| **New tools:** | ||
| - `get_query_schema` — discover available TRQL tables and columns | ||
| - `query` — execute TRQL queries against your data | ||
| - `list_dashboards` — list built-in dashboards and their widgets | ||
| - `run_dashboard_query` — execute a single dashboard widget query | ||
| - `whoami` — show current profile, user, and API URL | ||
| - `list_profiles` — list all configured CLI profiles | ||
| - `switch_profile` — switch active profile for the MCP session | ||
| - `start_dev_server` — start `trigger dev` in the background and stream output | ||
| - `stop_dev_server` — stop the running dev server | ||
| - `dev_server_status` — check dev server status and view recent logs | ||
|
|
||
| **New API endpoints:** | ||
| - `GET /api/v1/query/schema` — query table schema discovery | ||
| - `GET /api/v1/query/dashboards` — list built-in dashboards | ||
|
|
||
| **New features:** | ||
| - `--readonly` flag hides write tools (`deploy`, `trigger_task`, `cancel_run`) so the AI cannot make changes | ||
| - `read:query` JWT scope for query endpoint authorization | ||
| - `get_run_details` trace output is now paginated with cursor support | ||
| - MCP tool annotations (`readOnlyHint`, `destructiveHint`) for all tools | ||
|
|
||
| **Bug fixes:** | ||
| - Fixed `search_docs` tool failing due to renamed upstream Mintlify tool (`SearchTriggerDev` → `search_trigger_dev`) | ||
| - Fixed `list_deploys` failing when deployments have null `runtime`/`runtimeVersion` fields (#3139) | ||
| - Fixed `list_preview_branches` crashing due to incorrect response shape access | ||
| - Fixed `metrics` table column documented as `value` instead of `metric_value` in query docs | ||
| - Fixed dev CLI leaking build directories on rebuild — deprecated workers now clean up their build dirs when their last run completes | ||
|
|
||
| **Context optimizations:** | ||
| - `get_query_schema` now requires a table name and returns only one table's schema (was returning all tables) | ||
| - `get_current_worker` no longer inlines payload schemas; use new `get_task_schema` tool instead | ||
| - Query results formatted as text tables instead of JSON (~50% fewer tokens) | ||
| - `cancel_run`, `list_deploys`, `list_preview_branches` formatted as text instead of raw JSON | ||
| - Schema and dashboard API responses cached to avoid redundant fetches |
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,54 @@ | ||
| import { json } from "@remix-run/server-runtime"; | ||
| import type { DashboardSummary, DashboardWidgetSummary } from "@trigger.dev/core/v3/schemas"; | ||
| import type { BuiltInDashboard } from "~/presenters/v3/MetricDashboardPresenter.server"; | ||
| import { createLoaderApiRoute } from "~/services/routeBuilders/apiBuilder.server"; | ||
| import { builtInDashboard } from "~/presenters/v3/BuiltInDashboards.server"; | ||
|
|
||
| const BUILT_IN_DASHBOARD_KEYS = ["overview", "llm"]; | ||
|
|
||
| function serializeDashboard(dashboard: BuiltInDashboard): DashboardSummary { | ||
| const widgets: DashboardWidgetSummary[] = []; | ||
|
|
||
| if (dashboard.layout.version === "1") { | ||
| for (const [id, widget] of Object.entries(dashboard.layout.widgets)) { | ||
| // Skip title widgets — they're just section headers | ||
| if (widget.display.type === "title") continue; | ||
|
|
||
| widgets.push({ | ||
| id, | ||
| title: widget.title, | ||
| query: widget.query, | ||
| type: widget.display.type, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| key: dashboard.key, | ||
| title: dashboard.title, | ||
| widgets, | ||
| }; | ||
| } | ||
|
|
||
| export const loader = createLoaderApiRoute( | ||
| { | ||
| allowJWT: true, | ||
| corsStrategy: "all", | ||
| findResource: async () => 1, | ||
| authorization: { | ||
| action: "read", | ||
| resource: () => ({ query: "dashboards" }), | ||
| superScopes: ["read:query", "read:all", "admin"], | ||
| }, | ||
| }, | ||
| async () => { | ||
| const dashboards = BUILT_IN_DASHBOARD_KEYS.map((key) => { | ||
| try { | ||
| return serializeDashboard(builtInDashboard(key)); | ||
| } catch { | ||
| return null; | ||
| } | ||
| }).filter((d): d is DashboardSummary => d !== null); | ||
| return json({ dashboards }); | ||
| } | ||
| ); | ||
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,58 @@ | ||
| import { json } from "@remix-run/server-runtime"; | ||
| import type { ColumnSchema, TableSchema } from "@internal/tsql"; | ||
| import { createLoaderApiRoute } from "~/services/routeBuilders/apiBuilder.server"; | ||
| import { querySchemas } from "~/v3/querySchemas"; | ||
|
|
||
| function serializeColumn(col: ColumnSchema) { | ||
| const result: Record<string, unknown> = { | ||
| name: col.name, | ||
| type: col.type, | ||
| }; | ||
|
|
||
| if (col.description) { | ||
| result.description = col.description; | ||
| } | ||
| if (col.example) { | ||
| result.example = col.example; | ||
| } | ||
| if (col.allowedValues && col.allowedValues.length > 0) { | ||
| if (col.valueMap) { | ||
| result.allowedValues = Object.values(col.valueMap); | ||
| } else { | ||
| result.allowedValues = col.allowedValues; | ||
| } | ||
| } | ||
| if (col.coreColumn) { | ||
| result.coreColumn = true; | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| function serializeTable(table: TableSchema) { | ||
| const columns = Object.values(table.columns).map(serializeColumn); | ||
|
|
||
| return { | ||
| name: table.name, | ||
| description: table.description, | ||
| timeColumn: table.timeConstraint, | ||
| columns, | ||
| }; | ||
| } | ||
|
|
||
| export const loader = createLoaderApiRoute( | ||
| { | ||
| allowJWT: true, | ||
| corsStrategy: "all", | ||
| findResource: async () => 1, | ||
| authorization: { | ||
| action: "read", | ||
| resource: () => ({ query: "schema" }), | ||
| superScopes: ["read:query", "read:all", "admin"], | ||
| }, | ||
| }, | ||
| async () => { | ||
| const tables = querySchemas.map(serializeTable); | ||
| return json({ tables }); | ||
| } | ||
| ); |
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
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.
🧩 Analysis chain
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 127
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 262
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 96
🏁 Script executed:
# Read the file to see the actual code cat -n apps/webapp/app/routes/api.v1.query.dashboards._index.tsRepository: triggerdotdev/trigger.dev
Length of output: 2057
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 868
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 507
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 3271
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 3534
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 51
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 4513
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 1214
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 601
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 178
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 530
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 282
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 2527
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 51
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 614
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 1386
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 1572
Add Zod validation to the response body.
This public API route returns a typed response but skips runtime validation. Per the coding guidelines for
apps/webapp, validate the response using Zod before returning it to enforce contract safety.Suggested change
🤖 Prompt for AI Agents