Repository navigation
Description
Problem
`sequant_run` can take up to 30 minutes. Currently the MCP client has no visibility into progress during execution — the only option is polling `sequant_status` from a separate tool call. This creates two problems:
-
Timeout risk: MCP clients have default timeouts (typically 60-120s). Without progress notifications, the `tools/call` request will timeout well before `sequant_run` completes. The MCP SDK's `resetTimeoutOnProgress: true` option automatically extends the timeout when progress notifications are received — but only if the server sends them.
-
Poor UX: The LLM has to interleave `sequant_status` polling between turns, which is awkward and uses extra tool calls. Progress notifications are pushed server-to-client during the call, giving real-time visibility without polling.
How MCP progress works
The client sends a `progressToken` in `_meta` when calling a tool. The server emits `notifications/progress` during execution. The SDK automatically resets the client-side timeout on each notification.
// Client side (handled by SDK)
const result = await client.callTool(
{ name: "sequant_run", arguments: { issues: [123] } },
{ resetTimeoutOnProgress: true, maxTotalTimeout: 1800_000 }
);
// Server side
if (progressToken !== undefined) {
await server.server.notification({
method: "notifications/progress",
params: { progress: 2, total: 6, progressToken, message: "Issue #123: exec phase started" }
});
}Current workaround
Poll `sequant_status` every 5-10 seconds. This works but requires the LLM to manage polling loops and wastes tool calls.
Acceptance Criteria
- AC-1: `sequant_run` reads `progressToken` from `extra._meta?.progressToken`
- AC-2: When `progressToken` is present, phase transitions emit `notifications/progress` with: phase name, issue number, human-readable message
- AC-3: Progress `total` is calculated from issue count × phase count (e.g., 2 issues × 3 phases = 6 steps)
- AC-4: Progress notifications are skipped when no `progressToken` is provided (backward compatible)
- AC-5: Existing tests pass; add test for progress emission when token is provided
Design
Where to emit
The `sequant_run` tool handler already parses stdout from the CLI subprocess for structured output. Phase transitions can be detected from the subprocess output and mapped to progress notifications:
// In the sequant_run handler
let currentStep = 0;
const totalSteps = issues.length * phaseList.length;
// On each phase transition detected from subprocess output
if (progressToken !== undefined) {
currentStep++;
await server.server.notification(
{
method: "notifications/progress",
params: {
progress: currentStep,
total: totalSteps,
progressToken,
message: \`Issue #\${issueNumber}: \${phase} phase \${status}\`,
},
},
{ relatedRequestId: extra.requestId },
);
}Progress granularity
| Event | Message format | Progress increment |
|---|---|---|
| Issue started | "Issue #123: starting" | +0 (no increment) |
| Phase started | "Issue #123: spec phase started" | +1 |
| Phase completed | "Issue #123: spec phase completed" | +0 (start of next phase increments) |
| Issue completed | "Issue #123: completed (passed)" | +0 (final phase start already incremented) |
Detecting phase transitions
The CLI subprocess writes to stdout/stderr. Options:
- Parse stderr for phase markers — the CLI already logs phase transitions
- Read state file periodically — poll `.sequant/state.json` for phase changes
- Structured progress output — add a `--progress-json` flag to the CLI that emits JSON progress lines
Option 1 is simplest and matches current architecture. Options 2-3 are more reliable but add complexity.
Files in Scope
- `src/mcp/tools/run.ts` — add progress notification emission
- `src/mcp/server.ts` — may need to expose server instance for `notification()` calls
References
- MCP Progress spec
- MCP SDK `resetTimeoutOnProgress` — client timeout management
- Everything server: trigger-long-running-operation — reference implementation
Non-goals
- Changing the polling pattern for `sequant_status` — it still works and is useful independently
- Client-side progress display — handled by the MCP client automatically
Activity
admarble commentedon Mar 25, 2026
Spec Plan — #421: MCP Progress Notifications for
sequant_runAcceptance Criteria (with Verification)
sequant_runreadsprogressTokenfromextra._meta?.progressToken_meta.progressToken, handler captures tokennotifications/progresswith phase name, issue number, messagesendNotificationcalled with correct paramstotal= issue count × phase countprogressToken(backward compatible)_meta→sendNotificationnever called, no errorssendNotificationfailures caught, don't abort runsendNotificationthrows → run still completesImplementation Plan
Phase 1: Extend
spawnAsync()for real-time stderr callbacksonStderr?: (chunk: string) => voidtoSpawnOptionsinterfaceproc.stderr.on("data", ...)alongside buffer accumulationPhase 2: Add progress notification logic to handler
3. Widen
extratype to include_metaandsendNotificationfrom SDK'sRequestHandlerExtra4. Calculate
totalSteps = issues.length * phaseList.length5. Create stderr parser for PhaseSpinner phase transition patterns
6. Emit
notifications/progressviaextra.sendNotification()on each phase start (guarded byprogressToken !== undefined)Phase 3: Tests
7. Add integration test with mock subprocess emitting phase stderr → verify notifications
8. Add unit test for no-token backward compatibility
9. Run full test suite for regressions
Design Review
src/mcp/tools/run.ts— handler owns subprocess lifecycleonStderrcallback + parse spinner output. No new files, no CLI changes.onAbortcallback inspawnAsync; follows MCP SDK reference server patternConflict Risk
src/mcp/tools/run.ts,src/mcp/server.ts, and test files. Recommend waiting for #420 to merge before starting exec.Files in Scope
src/mcp/tools/run.ts—SpawnOptions,spawnAsync(),registerRunTool()handlersrc/mcp/server-extended.test.ts— new progress notification testsNon-Goals
sequant_statuspolling pattern--progress-jsonCLI flag (future enhancement)Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: disabled
Label Review
Current: enhancement, cli → Recommended: enhancement, mcp
admarble commentedon Mar 25, 2026
Test Stubs Generated for Issue #421
Unit Test Stubs
File:
__tests__/mcp-progress-notifications.test.ts_meta)_meta,_metawithout token), 1 failure (nosendNotification)Integration Test Stubs
File:
__tests__/integration/mcp-progress-notifications.integration.test.tssendNotificationcallable)Assumptions to Validate Before Implementation
extra._meta?.progressTokenis provided by MCP SDK for clients that support progressextra.sendNotificationis callable and acceptsnotifications/progressformatonStderrcallback fires for each stderr data chunkNext steps:
throw new Error(...)with actual test logic)/exec 421to implement the featurenpm testGenerated with Claude Code
feat(#421): add MCP progress notifications for sequant_run
admarble commentedon Mar 25, 2026
Exec Progress Update — #421
AC Coverage
progressTokenfromextra._meta?.progressTokensrc/mcp/tools/run.ts:384notifications/progressparsePhaseStart+handleOutputChunkin handlertotal= issue count × phase countsrc/mcp/tools/run.ts:380progressToken(backward compatible)emitProgress+ callbacks only wired when token existssendNotificationfailures caught.catch()inemitProgressFiles Changed
src/mcp/tools/run.ts— progress notification logic,parsePhaseStart,onStdout/onStderrcallbacks__tests__/mcp-progress-notifications.test.ts— unit tests (AC-1, AC-3, AC-4, AC-6, parsePhaseStart)__tests__/integration/mcp-progress-notifications.integration.test.ts— integration tests (AC-2, AC-5, error scenarios)CHANGELOG.md— added entry for this featureChecks
npm run buildnpm run lintnpm testQuality Plan Alignment
N/A — No quality plan in issue
PR
✅ Created: #429
Generated with Claude Code
admarble commentedon Mar 25, 2026
QA Review for Issue #421
AC Coverage
progressTokenfromextra._meta?.progressTokenrun.ts:384— extracted fromextra._meta?.progressTokennotifications/progresswith phase name, issue number, messageparsePhaseStartdetects ⏳ lines →handleOutputChunkincrements step →emitProgresssends notificationtotal= issue count × phase countrun.ts:380—totalSteps = issues.length * phaseList.length. Tests verify 2×3=6, 1×2=2, 1×1=1progressToken(backward compatible)if (progressToken === undefined) returninemitProgress; callbacks only wired when token presentsendNotificationfailures caught, don't abort runtry/catchfor sync errors +.catch()for async promise rejection inemitProgressCoverage: 6/6 AC items fully met
CI Status
build (20.x)build (22.x)typecheckvalidate-skillsvalidate-pluginCI Summary: 5 passed, 0 failed
Quality Metrics
any)Test Coverage Analysis
src/mcp/tools/run.ts__tests__/mcp-progress-notifications.test.ts+ integrationCHANGELOG.mdCoverage: 1/1 changed source files have tests
Critical paths without tests: None
Code Review
Strengths:
parsePhaseStartis a pure function, easy to test independently.catch()for error resilience (AC-6)progressTokenis present — zero overhead for non-progress clients⏳hourglass from PhaseSpinner'sstart()method incli-ui.tsIssues:
Minor observations (not blocking):
Math.floor((currentStep - 1) / phaseList.length)assumes sequential issue processing, which is correct for the current implementation where issues are processed in a for-loopTest Quality Review
Anti-Pattern Detection
Code Patterns
No anti-patterns detected:
awaitin loops (fire-and-forget is intentional)Call-Site Review
New exported functions detected: 1 (
parsePhaseStart)parsePhaseStartrun.ts:420(inhandleOutputChunk)progressToken !== undefinedCHANGELOG Verification
Product Review
User-facing changes: MCP
sequant_runtool now emits progress notificationsprogressTokenresetTimeoutOnProgresssequant_runresponse unchangedGaps found: None
Self-Evaluation
Verdict: READY_FOR_MERGE
All 6 acceptance criteria are met. Implementation is clean, well-tested (21 new tests), backward compatible, and follows existing patterns. CI passes on all checks.
Documentation
Next Steps
QA completed: All AC met, A+ implementation
admarble commentedon Mar 25, 2026
QA Review for Issue #421
AC Coverage
progressTokenfromextra._meta?.progressTokenrun.ts:384— extracted correctlynotifications/progresswith phase name, issue number, messageparsePhaseStart→handleOutputChunk→emitProgresspipeline works. Message format:Issue #N: phase phase started (step/total)total= issue count × phase countrun.ts:380—totalSteps = issues.length * phaseList.length. Tests verify 2×3=6, 1×2=2, 1×1=1progressToken(backward compatible)if (progressToken === undefined) returninemitProgress;onStdout/onStderrcallbacks only wired when token presentsendNotificationfailures caught, don't abort runtry/catchfor sync errors +.catch()for async promise rejection inemitProgressCoverage: 6/6 AC items fully met
CI Status
build (20.x)build (22.x)typecheckvalidate-pluginvalidate-skillsCI Summary: 5 passed, 0 failed
Quality Metrics
any)Cache Status
N/A — Fresh run
Build Verification
N/A — Build passed
Test Coverage Analysis
src/mcp/tools/run.ts__tests__/mcp-progress-notifications.test.ts+__tests__/integration/mcp-progress-notifications.integration.test.tsCHANGELOG.mdCoverage: 1/1 changed source files have tests
Critical paths without tests: None
Code Review
Strengths:
parsePhaseStartis a pure function — easily testable, no side effectsvoid extra.sendNotification(...).catch(...)) avoids blocking subprocess output streamtry/catch+ async.catch()for AC-6 resilienceprogressTokenpresent — zero overhead for non-progress clientsInMemoryTransportfor high-fidelity integration testingIssues:
Minor observations (non-blocking):
Math.floor((currentStep - 1) / phaseList.length)assumes sequential issue processing — correct for current for-loop architecture but would need revisiting if parallel subprocess execution is added laterTest Quality Review
onprogress, not internal statechild_processandfsmocked; MCP SDK used for real via InMemoryTransportAnti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected:
awaitin loops (fire-and-forget is intentional design)Call-Site Review
New exported functions detected: 1 (
parsePhaseStart)parsePhaseStartrun.ts:420(inhandleOutputChunk)progressToken !== undefinedExecution Evidence
N/A — No executable scripts changed. Implementation is in MCP server tool handler.
Skill Command Verification
N/A — No skill files changed
CLI Registration Verification
N/A — No option interface changes
CHANGELOG Verification
Product Review
User-facing changes: MCP
sequant_runtool now emits progress notificationsprogressTokenGaps found: None
Smoke Test
Not Required — No workflow-affecting changes (no skills, scripts, or CLI modified)
Self-Evaluation
parsePhaseStartunit tests that validate format assumptionsVerdict: READY_FOR_MERGE
All 6 acceptance criteria are met. Implementation is clean, well-tested (21 new tests), backward compatible, and follows existing patterns. The fire-and-forget notification pattern correctly prevents blocking the subprocess output stream, and the double error handling (sync + async) ensures notification failures never abort a run.
Documentation
Next Steps
QA completed: All AC met, A+ implementation
fix(#421): use structured progress lines instead of spinner parsing
docs(#421): update MCP server docs with progress notifications
admarble commentedon Mar 25, 2026
Documentation Updated
File:
docs/features/mcp-server.md(updated existing doc)Sections Updated:
resetTimeoutOnProgressguidanceWhy update, not create:
Progress notifications are a capability of the existing
sequant_runMCP tool, already documented inmcp-server.md. A separate doc would fragment the reader's journey.Ready to merge!
chore(#421): resolve merge conflicts with origin/main
feat(#421): add MCP progress notifications for sequant_run (#429)