Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d9f988b7c0bd32e140f62ac92a205c9788c024c9cc8784c001647b1cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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). |
| 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. |
| 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 |
| 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 }); | ||
| } | ||
| ); | ||
| 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 }); | ||
| } | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,6 +5,7 @@ import { createActionApiRoute } from "~/services/routeBuilders/apiBuilder.server | ||
| import { executeQuery, type QueryScope } from "~/services/queryService.server"; | ||
| import { logger } from "~/services/logger.server"; | ||
| import { rowsToCSV } from "~/utils/dataExport"; | ||
| import { querySchemas } from "~/v3/querySchemas"; | ||
| const BodySchema = z.object({ | ||
| query: z.string(), | ||
| @@ -15,10 +16,30 @@ const BodySchema = z.object({ | ||
| format: z.enum(["json", "csv"]).default("json"), | ||
| }); | ||
| /** Extract table names from a TRQL query for authorization */ | ||
| function detectTables(query: string): string[] { | ||
| return querySchemas | ||
| .filter((s) => { | ||
| const escaped = s.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
| return new RegExp(`\\bFROM\\s+${escaped}\\b`, "i").test(query); | ||
| }) | ||
| .map((s) => s.name); | ||
| } | ||
| const { action, loader } = createActionApiRoute( | ||
| { | ||
| body: BodySchema, | ||
| allowJWT: true, | ||
| corsStrategy: "all", | ||
| findResource: async () => 1, | ||
| authorization: { | ||
| action: "read", | ||
| resource: (_, __, ___, body) => { | ||
| const tables = detectTables(body.query); | ||
| return { query: tables.length > 0 ? tables : "all" }; | ||
ericallam marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }, | ||
| superScopes: ["read:query", "read:all", "admin"], | ||
| }, | ||
| }, | ||
| async ({ body, authentication }) => { | ||
| const { query, scope, period, from, to, format } = body; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.