Merged
Size
XL
Change Breakdown
Feature55%
Bug Fix20%
Performance15%
Maintenance10%
#3224feat(cli): Expand and improve the MCP server and dev CLI command

MCP server grows from 14 to 25 tools with query, profile, and dev server controls

MCP server grows from 14 to 25 tools with query, profile, and dev server controls

The MCP server now offers 25 tools — up from 14 — enabling AI assistants to query data directly, switch between CLI profiles per-project, and control the dev server. A nasty build directory leak that was hoarding 842MB on disk has also been fixed.

The MCP server for Trigger.dev just got a major upgrade. AI assistants can now execute TRQL queries directly against your Trigger.dev data, list and run dashboard widget queries, and manage CLI profiles — all without leaving the conversation.

Three profile-related tools solve a common pain point: developers working across multiple projects or accounts previously had to manually reconfigure their CLI. The new whoami, list_profiles, and switch_profile tools let AI agents switch profiles on the fly, with preferences persisted to in each project. This is particularly useful for agencies managing dozens of client projects.

A --readonly flag addresses a security concern for agents operating in sensitive environments. When enabled, it hides write tools (deploy, trigger_task, cancel_run) so agents can analyze and explore but can't make changes. Each tool now includes readOnlyHint and destructiveHint annotations for clients that support them.

The dev CLI had a disk space leak that was quietly accumulating build directories — up to 842MB observed in one case. Every rebuild created a new build-* directory in .trigger/tmp/ without cleaning up old ones. The fix adds three layers of protection: deprecated workers are pruned (capped at 2 retained) when no active runs reference them, the watchdog process cleans up temp directories when the CLI is killed ungracefully, and any orphans are wiped on next startup.

Bug fixes include list_deploys failing when deployments have null runtime or runtimeVersion fields (the Zod schema now uses .nullable()), search_docs breaking due to a Mintlify tool rename, and list_preview_branches crashing from incorrect response shape access.

These changes live primarily in the CLI package with new API routes in the webapp for schema discovery and dashboard listing.

View Original GitHub Description

Summary

Major expansion of the MCP server (14 → 25 tools), context efficiency optimizations, new API endpoints, and a fix for the dev CLI leaking build directories on disk.

New MCP tools

  • Query & analytics: get_query_schema, query, list_dashboards, run_dashboard_query — query your data using TRQL directly from AI assistants
  • Profile management: whoami, list_profiles, switch_profile — see and switch CLI profiles per-project (persisted to .trigger/mcp.json)
  • Dev server control: start_dev_server, stop_dev_server, dev_server_status — start/stop trigger dev and stream build output
  • Task introspection: get_task_schema — get payload schema for a specific task (split out from get_current_worker to reduce context)

New API endpoints

  • GET /api/v1/query/schema — discover TRQL tables and columns (server-driven, multi-table)
  • GET /api/v1/query/dashboards — list built-in dashboard widgets and their queries

New features

  • --readonly flag — hides write tools (deploy, trigger_task, cancel_run) so agents can't make changes
  • read:query JWT scope — new authorization scope for query endpoints, with per-table granularity (read:query:runs, read:query:llm_metrics, etc.)
  • Paginated trace outputget_run_details now paginates trace events via cursor, caching the full trace in a temp file so subsequent pages don't re-fetch
  • MCP tool annotations — all tools now have readOnlyHint/destructiveHint annotations for clients that support them
  • Project-scoped profile persistenceswitch_profile saves to .trigger/mcp.json (gitignored), automatically loaded on next MCP server start

Context optimizations

  • get_query_schema requires a table name — returns one table's schema instead of all tables (60-80% fewer tokens)
  • get_current_worker no longer inlines payload schemas — use get_task_schema for specific tasks
  • Query results formatted as text tables instead of JSON (~50% fewer tokens for flat data)
  • cancel_run, list_deploys, list_preview_branches formatted as text instead of raw JSON.stringify()
  • Schema and dashboard API responses cached (1hr and 5min respectively)

Bug fixes

  • Fixed search_docs failing due to renamed upstream Mintlify tool (SearchTriggerDevsearch_trigger_dev)
  • Fixed list_deploys failing when deployments have null runtime/runtimeVersion fields (fixes #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 /api/v1/query not accepting JWT auth (added allowJWT: true)

Dev CLI build directory fix

The dev CLI was leaking build-* directories in .trigger/tmp/ on every rebuild, accumulating hundreds of MB over time (842MB observed). Three layers of protection added:

  1. During session: deprecated workers are pruned (capped at 2 retained) when no active runs reference them, preventing unbounded accumulation
  2. On SIGKILL/crash: the watchdog process now cleans up .trigger/tmp/ when it detects the parent CLI was killed
  3. On next startup: existing clearTmpDirs() wipes any remaining orphans

Test plan

  • pnpm run mcp:smoke — 17 automated smoke tests for all read-only MCP tools
  • pnpm run mcp:test list — verify 25 tools registered (21 in --readonly mode)
  • pnpm run mcp:test --readonly list — verify write tools hidden
  • Manual: start dev server, trigger task, rebuild multiple times, verify build dirs stay capped at 4
  • Manual: SIGKILL the dev CLI, verify watchdog cleans up .trigger/tmp/
  • Verify new API endpoints return correct data: GET /api/v1/query/schema, GET /api/v1/query/dashboards

🤖 Generated with Claude Code

© 2026 · via Gitpulse