-
-
Notifications
You must be signed in to change notification settings - Fork 798
feat(mcp): add wait_for_run_to_complete tool so agents don't spam the get_run_details call after triggering #2445
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
Conversation
… get_run_details call after triggering This also fixes the search docs MCP tool
🦋 Changeset detectedLatest commit: ab59db8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Walkthrough
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Rationale: Mix of small text/config tweaks and a new streaming-based tool with API client usage, event loop handling, and new formatter. Changes span multiple files but most are straightforward; primary reasoning needed is in runs.ts implementation and formatter correctness. Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/cli-v3/src/commands/install-mcp.ts (1)
154-156
: Fix typo in user-facing help text ("effect" → "affect").Minor but visible in CLI help.
- "The CLI log level to use (debug, info, log, warn, error, none). This does not effect the log level of your trigger.dev tasks.", + "The CLI log level to use (debug, info, log, warn, error, none). This does not affect the log level of your trigger.dev tasks.",
🧹 Nitpick comments (4)
.changeset/eleven-games-relate.md (1)
1-5
: Expand the changeset summary to cover all user-facing tweaks (docs search + install tag).Currently only mentions the new tool. Consider briefly noting the docs search tool fix and the default install tag change to make the patch notes self-contained.
Apply this tweak:
-add wait_for_run_to_complete tool so agents don't spam the get_run_details call after triggering +Add wait_for_run_to_complete MCP tool so agents don't spam get_run_details after triggering. + +- Fix docs search MCP tool name. +- Default MCP install uses @latest (or @v4-beta when applicable).packages/cli-v3/src/mcp/config.ts (1)
67-72
: Add long-running operation note and progress token hint towait_for_run_to_complete
Please update the tool metadata in packages/cli-v3/src/mcp/config.ts to call out that this operation can take time and that clients should pass a progress token:
• File: packages/cli-v3/src/mcp/config.ts
Lines: ~67–72wait_for_run_to_complete: { name: "wait_for_run_to_complete", title: "Wait for Run to Complete", - description: - "Wait for a run to complete. The run ID is the ID of the run that was triggered. It starts with run_", + description: + "Wait for a run to complete. The run ID is the ID of the run that was triggered (starts with run_). This is a long-running operation; include a progress token to surface progress to the user.", },packages/cli-v3/src/mcp/tools/runs.ts (2)
111-113
: Optional: include dashboard URL in the outputAdding the run URL improves UX parity with get_run_details.
- return { - content: [{ type: "text", text: formatRunShape(run) }], - }; + const runUrl = await ctx.getDashboardUrl( + `/projects/v3/${projectRef}/runs/${run.id}` + ); + return { + content: [ + { + type: "text", + text: `${formatRunShape(run)}\n\n[View in dashboard](${runUrl})`, + }, + ], + };
64-115
: Optionally emit progress notifications while waitingLeverage createProgressTracker to signal “subscribing” and “waiting for completion,” improving agent UX for long waits.
- handler: toolHandler(CommonRunsInput.shape, async (input, { ctx, signal }) => { + handler: toolHandler(CommonRunsInput.shape, async (input, { ctx, signal, createProgressTracker }) => { + const progress = createProgressTracker(2); + await progress.next("Subscribing to run stream…"); @@ - try { + try { + await progress.next("Waiting for run to complete…");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (8)
.changeset/eleven-games-relate.md
(1 hunks)packages/cli-v3/src/commands/install-mcp.ts
(1 hunks)packages/cli-v3/src/mcp/config.ts
(1 hunks)packages/cli-v3/src/mcp/formatters.ts
(2 hunks)packages/cli-v3/src/mcp/mintlifyClient.ts
(1 hunks)packages/cli-v3/src/mcp/tools.ts
(2 hunks)packages/cli-v3/src/mcp/tools/runs.ts
(2 hunks)packages/cli-v3/src/mcp/tools/tasks.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}
: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations
Files:
packages/cli-v3/src/mcp/tools/tasks.ts
packages/cli-v3/src/mcp/mintlifyClient.ts
packages/cli-v3/src/mcp/formatters.ts
packages/cli-v3/src/mcp/tools.ts
packages/cli-v3/src/mcp/config.ts
packages/cli-v3/src/mcp/tools/runs.ts
packages/cli-v3/src/commands/install-mcp.ts
🧠 Learnings (2)
📚 Learning: 2025-08-18T10:07:17.368Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.368Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Define tasks using task({ id, run, ... }) with a unique id per project
Applied to files:
packages/cli-v3/src/mcp/tools/tasks.ts
📚 Learning: 2025-08-18T10:07:17.368Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.368Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Import Trigger.dev APIs from "trigger.dev/sdk/v3" when writing tasks or related utilities
Applied to files:
packages/cli-v3/src/mcp/tools/runs.ts
🧬 Code graph analysis (4)
packages/cli-v3/src/mcp/tools/tasks.ts (1)
packages/cli-v3/src/mcp/config.ts (1)
toolsMetadata
(12-103)
packages/cli-v3/src/mcp/formatters.ts (2)
packages/core/src/v3/apiClient/index.ts (1)
AnyRunShape
(130-130)apps/webapp/app/components/primitives/DateTime.tsx (1)
formatDateTime
(64-80)
packages/cli-v3/src/mcp/tools.ts (1)
packages/cli-v3/src/mcp/tools/runs.ts (1)
waitForRunToCompleteTool
(64-115)
packages/cli-v3/src/mcp/tools/runs.ts (4)
packages/cli-v3/src/mcp/config.ts (1)
toolsMetadata
(12-103)packages/cli-v3/src/mcp/schemas.ts (2)
CommonRunsInput
(120-122)CommonRunsInput
(124-124)packages/cli-v3/src/mcp/utils.ts (2)
toolHandler
(43-63)respondWithError
(5-15)packages/cli-v3/src/mcp/formatters.ts (1)
formatRunShape
(104-130)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (22)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: typecheck / typecheck
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
packages/cli-v3/src/commands/install-mcp.ts (1)
115-115
: Default tag now uses cliTag (latest/v4-beta) — aligns with PR goal.Nice improvement for DX and stability.
packages/cli-v3/src/mcp/config.ts (1)
59-60
: Good guidance to prefer waiting before fetching run details.Clearer agent behavior; reduces polling.
packages/cli-v3/src/mcp/formatters.ts (1)
104-130
: Ignore defensive date handling suggestionThe
createdAt
andfinishedAt
fields inAnyRunShape
are guaranteed to beDate
objects, not raw strings:
- In the zod schema for incoming shapes, both
RawShapeDate
andRawOptionalShapeDate
transform any string timestamps intoDate
instances before they ever reach the client code.- The
RunShape
type defines
•createdAt: Date
•finishedAt?: Date
(packages/core/src/v3/apiClient/runStream.ts)Since all date strings are parsed into
Date
by the schema and the TypeScript types reflect that,formatDateTime
will always receive aDate
and cannot throw on a string input. No coercion or widening offormatDateTime
is necessary.Likely an incorrect or invalid review comment.
packages/cli-v3/src/mcp/tools/tasks.ts (1)
133-134
: Good: dynamic guidance references registered tool namesSwitching to toolsMetadata for tool names keeps the message in sync with actual registrations. No action needed.
packages/cli-v3/src/mcp/tools.ts (2)
11-16
: Tool import wiring looks correctImporting waitForRunToCompleteTool alongside existing run tools is consistent with the current pattern.
31-32
: Registration order is fineAdding waitForRunToCompleteTool to the registry maintains discoverability and doesn’t affect existing tools.
packages/cli-v3/src/mcp/tools/runs.ts (2)
1-1
: Type import aligns with downstream usageAnyRunShape is the right choice for formatting and completion checks.
3-3
: Formatter import is appropriateUsing formatRunShape keeps output consistent with other run formatters.
@latest
tag instead of@<current version>