Repository navigation
Description
MCP Server: Real-Time Progress Reporting
Depends on: #388 (async spawn — prerequisite for all approaches)
Related: #372 (MCP server), #391 (structured output), #370 (CI integration)
Priority: P2 — essential for usable MCP experience
Problem
When an MCP client calls sequant_run, the workflow can take 5–30 minutes. During that time the client has zero visibility into progress. Users see nothing — no phase updates, no issue status, no indication the server is even working. This makes the MCP server feel broken for anything beyond trivial runs.
Goal
Provide real-time progress reporting during MCP-triggered workflow runs, using protocol-appropriate mechanisms at each maturity stage.
Implementation Phases
Phase 1: Polling via sequant_status (v1 — after #388)
Prerequisite: #388 replaces spawnSync with async spawn so the server can handle concurrent requests.
Once the event loop is unblocked, MCP clients can poll sequant_status while sequant_run is in progress. The state file (.sequant/state.json) is already updated per-phase by the orchestrator, so polling gives phase-level progress with no additional server changes.
Acceptance Criteria:
-
sequant_statusreturns current phase and phase status whilesequant_runis executing - State file reflects in-progress phase within seconds of phase start
- Document recommended polling interval for MCP clients (e.g., every 10s)
-
sequant_statusresponse includesisRunning: trueindicator when a run is active
Client usage pattern:
Client: sequant_run({ issues: [42], phases: "spec,exec,qa" })
Client: sequant_status({ issue: 42 }) // poll every 10s
→ { issue: 42, status: "in_progress", currentPhase: "exec", phases: { spec: "completed", exec: "in_progress", qa: "pending" } }
Effort: Small (mostly documentation + isRunning flag)
Phase 2: MCP Notifications (v2 — protocol-native)
The MCP spec supports server-initiated notifications. This is the "right" answer — no polling, clients get pushed updates as phases complete.
Acceptance Criteria:
- Server emits
notifications/progress(or customsequant/progress) as each phase starts and completes - Notification payload includes:
{ issue, phase, status, duration?, error? } - Notifications work over both stdio and SSE transports
- Clients that don't support notifications are unaffected (graceful degradation)
- Test coverage for notification emission timing and payload
Notification design:
// Using MCP SDK's built-in notification support
server.notification({
method: "sequant/progress",
params: {
issue: 42,
phase: "exec",
status: "completed",
durationSeconds: 145
}
});MCP SDK support: server.sendNotification() or server.notification() — verify current API against MCP TypeScript SDK docs.
Client compatibility:
- Claude Desktop: supports server notifications
- Cursor: supports server notifications
- MCP Inspector: displays notifications in UI
Effort: Medium (notification emission + phase lifecycle hooks)
Phase 3: Resource Subscriptions on sequant://state (v2+)
The sequant://state MCP resource already exists (#372). Adding subscription support lets clients subscribe to state changes and receive updates whenever the state file changes.
Acceptance Criteria:
-
sequant://stateresource supports MCP resource subscriptions - Server watches
.sequant/state.jsonwithfs.watch()and pushes updates on change - Debounce file watch events (state may update rapidly during phase transitions)
- Subscription is cleaned up on client disconnect
- Works over both stdio and SSE transports
Implementation notes:
- Use
fs.watch()(notfs.watchFile()— polling-based and slower) - Debounce to ~500ms to avoid flooding clients during rapid state updates
- The resource handler already reads and returns the state file — subscription just adds the push trigger
Effort: Medium
Phase 4: Webhook Callbacks (future — for remote/CI use)
For SSE transport running on a server, webhook callbacks on phase completion would let external systems (Slack, dashboards, CI pipelines) react to workflow progress.
Acceptance Criteria:
-
sequant_runaccepts optionalwebhookUrlparameter - Server POSTs phase completion events to the webhook URL
- Payload matches notification format for consistency
- Webhook failures are logged but don't block the workflow
- Authentication token support for webhook endpoints
Note: This overlaps with #370 (GitHub Actions integration). Coordinate to avoid duplicate webhook infrastructure.
Effort: Medium
Recommended Rollout
| Phase | When | Depends On | Value |
|---|---|---|---|
| 1. Polling | Immediately after #388 | #388 (async spawn) | Unblocks basic progress visibility |
| 2. Notifications | Next iteration | Phase 1 | Protocol-native, no polling overhead |
| 3. Subscriptions | After Phase 2 | Phase 2 | Richer state visibility for dashboards |
| 4. Webhooks | When CI integration lands | #370 | Remote/server use cases |
Phase 1 is the minimum viable solution. Phase 2 is what MCP clients (Claude Desktop, Cursor) are built to consume. Phases 3–4 are for power users and CI.
Testing Strategy
- Phase 1: Verify
sequant_statusreturns accurate in-progress state during a run (integration test with short-running workflow) - Phase 2: Verify notifications are emitted at correct lifecycle points using
InMemoryTransportin unit tests - Phase 3: Verify file watch triggers resource update notifications (mock
fs.watch) - Phase 4: Verify webhook POST with mock HTTP server
Activity
admarble commentedon Mar 23, 2026
Spec Plan — #394 MCP Server: Real-Time Progress Reporting
AC Quality Check
The issue contains 19 AC items across 4 implementation phases. AC items lack
AC-N:prefixes (reformatted below). Quality notes:✅ Remaining AC items are clear and testable.
Scope Assessment
Non-Goals (from issue body)
The issue explicitly scopes 4 phases with a recommended rollout. Phase 4 (Webhooks) is marked as "future — for remote/CI use" and overlaps with #370.
Recommended non-goals for this implementation:
notifications/resources/updatedand progress tokens)sequant_statusresponse schemaScope Metrics
src/mcp/,src/lib/workflow/)Scope Verdict
❌ SCOPE_SPLIT_RECOMMENDED — This issue bundles 4 distinct features. Recommendation: Implement Phase 1 only in this issue. Phase 2 (notifications) and Phase 3 (subscriptions) should be separate issues.
However, the issue itself defines a phased rollout and explicitly notes "Phase 1 is the minimum viable solution." I recommend implementing Phase 1 only in this PR, with Phase 2 and Phase 3 as follow-up issues.
Acceptance Criteria (Phase 1 Only)
AC-1:
sequant_statusreturns current phase and phase status whilesequant_runis executingVerification Method: Integration Test
Test Scenario:
sequant_runis in progress for issue sequant run: SDK exits with code 1 but direct claude invocation works #42 (mocked spawn that stays alive)sequant_status({ issue: 42 })status: "in_progress",currentPhaseis set, phases object shows in-progress and completed phasesIntegration Points: StateManager, sequant_run async spawn, sequant_status tool
Assumptions to Validate:
AC-2: State file reflects in-progress phase within seconds of phase start
Verification Method: Integration Test (same test as AC-1)
Test Scenario:
in_progress.sequant/state.jsoncontains the updated phase statusNote: This is already true —
batch-executor.tscallsmanager.updatePhaseStatus()beforeexecutePhaseWithRetry(). This AC validates existing behavior works end-to-end through MCP.AC-3: Document recommended polling interval for MCP clients
Verification Method: Manual Test
Test Scenario:
sequant_statustool registrationAC-4:
sequant_statusresponse includesisRunning: trueindicator when a run is activeVerification Method: Integration Test
Test Scenario:
Given: A
sequant_runis actively executing (tracked via in-memory run registry)When: Client calls
sequant_status({ issue: 42 })Then: Response JSON includes
"isRunning": trueGiven: No
sequant_runis executingWhen: Client calls
sequant_status({ issue: 42 })Then: Response JSON includes
"isRunning": falseIntegration Points: New run-tracking mechanism needed (see implementation plan)
Derived ACs
isRunningreturnsfalseif run process has exited but state wasn't cleaned upImplementation Plan
Phase 1: Active Run Registry (AC-4, AC-5, AC-6)
Create run registry module (
src/mcp/run-registry.ts)Map<number, { pid: number; startedAt: string }>tracking active runs by issue numberregisterRun(issue, pid)/unregisterRun(issue)/isRunning(issue)/getActiveRuns()Wire registry into
sequant_run(src/mcp/tools/run.ts)registerRun()after successful spawnunregisterRun()in the settlement function (on close, error, abort, timeout)Phase 2: Enhance
sequant_statusResponse (AC-1, AC-4)Add
isRunningto status response (src/mcp/tools/status.ts)isRunning()from run registryisRunning: isRunning(issue)to response JSONisRunning: falsefor untracked issuesUpdate tool description (
src/mcp/tools/status.ts)Phase 3: Documentation (AC-3)
sequant_statuspolling pattern with recommended intervalPhase 4: Tests (AC-7)
src/mcp/server-extended.test.tsor newsrc/mcp/tools/status.test.ts)isRunning: truewhen run is active (mock spawn that doesn't close)isRunning: falsewhen no run activeisRunning: falseafter run completessequant_statuscalls during activesequant_runParallel Groups
Conflict Risk Analysis
In-flight work detected:
src/mcp/tools/run.ts,src/mcp/server-extended.test.tssrc/mcp/tools/run.ts,src/mcp/server-extended.test.tsOverlapping files:
src/mcp/tools/run.ts— MCP server: real-time progress reporting for workflow runs #394 adds registry calls to spawn/settlement; MCP server: prevent nested npx version mismatch in sequant_run #389 and MCP server: improve sequant_run output structure #391 modify output/spawn logicsrc/mcp/server-extended.test.ts— all three issues add testsRecommended approach:
src/mcp/tools/status.test.ts) avoids test file conflicts entirelyDependencies
Depends on: #388 (async spawn) — Status: CLOSED (merged) ✅
Feature Quality Planning
Completeness Check
Error Handling
isRunningreturnsfalsefor untracked issues (not an error)isRunning: false(acceptable, next poll catches it)Code Quality
ActiveRuninterface for registry entriesTest Coverage Plan
Best Practices
Open Questions
Should
isRunningbe per-issue or server-wide?activeRuns: numberto a futuresequant_server_infotool for server-wide view.Should Phase 2 (notifications) and Phase 3 (subscriptions) be filed as separate issues now?
Should the run registry persist across server restarts?
isRunningwill be false but state showsin_progress. Acceptable — state reconciliation already handles this.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Well-defined Phase 1 scope with clear AC. Small change footprint (new module + 2 modified files). No UI components. Dependency #388 is merged. Wait for #389/#391 to merge before starting exec to minimize conflicts.
Label Review
Current: enhancement, multi-agent
Recommended: enhancement, multi-agent, mcp
Reason: All changes are in
src/mcp/—mcplabel aids filtering→
gh issue edit 394 --add-label mcpEffort Estimate
feat(#394): add real-time progress reporting for MCP workflow runs
admarble commentedon Mar 23, 2026
Exec Phase — Progress Update
AC Coverage
sequant_statusreturns current phase during runisRunningindicator in status responseisRunning: falseafter process exitsKey Files Changed
src/mcp/run-registry.tssrc/mcp/run-registry.test.tssrc/mcp/tools/run.tssrc/mcp/tools/status.tsisRunningfield + polling guidance in descriptionsrc/mcp/server-extended.test.tsCHANGELOG.mdQuality Gates
npm run buildnpm run lintnpm testQuality Plan Alignment
Derived ACs: 3/3 addressed
PR
✅ Created: #408
admarble commentedon Mar 23, 2026
QA Review for Issue #394
AC Coverage
sequant_statusreturns current phase during run.sequant/state.jsonwhich is updated by batch-executor before phase execution. Integration test confirms.batch-executor.tscallsupdatePhaseStatus()before phase handler. Validated end-to-end.isRunning: trueindicator when run is activeisRunningfield added to both tracked and untracked issue responses. Registry-backed viarun-registry.ts.run-registry.tssingleton withMap<number, ActiveRun>. Register before spawn, unregister infinally.isRunning: falseafter process exitsfinallyblock ensuresunregisterRunruns on success, error, and abort paths. Unit tests confirm.server-extended.test.tstests mid-run status polling with mock process, verifies lifecycle transition.Coverage: 7/7 AC items fully met
Original ACs: 4/4 met
Derived ACs: 3/3 met
Quality Plan Verification
Derived ACs: 3/3 addressed
Quality Plan Status: Complete
CI Status
No CI checks configured for this repository.
Quality Metrics
any)Build Verification
N/A — Build passed (
npm run buildexits 0)Test Coverage Analysis
src/mcp/run-registry.tssrc/mcp/run-registry.test.tssrc/mcp/tools/run.ts__tests__/mcp-run-async.test.ts,src/mcp/server-extended.test.tssrc/mcp/tools/status.tssrc/mcp/server-extended.test.tsCHANGELOG.mdCoverage: 3/3 changed source files have corresponding tests
Critical paths without tests: None
Code Review
Strengths:
finallyblock ensures cleanup on all exit paths (success, error, abort, timeout)isRunningadded to both tracked and untracked responses — consistent APIisRunningfield without changing existing response shapeIssues:
registerRun(issue, process.pid)atrun.ts:82stores the MCP server's own PID, not the spawned child's PID. The child PID isn't available untilspawnAsyncstarts internally. Functionally harmless sinceisRunning()only checks map presence, but thepidfield inActiveRunis misleading. Consider renaming toserverPidor deferring PID capture.Suggestions:
ActiveRun.pidis ever used for process management.Test Quality Review
isRunningoutput, not registry internalschild_process.spawn(external dependency)setTimeout(r, 10)for event loop tick — minimal timing sensitivityAnti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected:
awaitin loops (thefor..ofloops in run.ts are synchronousregisterRun/unregisterRuncalls)Call-Site Review
New exported functions detected: 5
registerRun()run.ts:82unregisterRun()run.ts:141finallyblockisRunning()status.ts:53,status.ts:69getActiveRuns()clearRegistry()@internaltesting utilityFindings: All call sites match AC constraints. No issues.
Execution Evidence
N/A — No scripts changed. MCP tool changes verified via integration tests.
Skill Command Verification
N/A — No skill files changed.
CLI Registration Verification
N/A — No option interface changes.
Smoke Test
Not Required — No workflow-affecting changes (no skills, scripts, or CLI changes).
CHANGELOG Verification
Result: CHANGELOG requirements met
Self-Evaluation
isRunningfield, and cleanup failuresfinallyblock doesn't fire (e.g., process crash). Acceptable — in-memory registry is ephemeral by design, and server restart clears all state.Verdict: READY_FOR_MERGE
All 7 AC items (4 original + 3 derived) are met. Implementation is clean, backward compatible, and well-tested. The minor PID semantics issue is cosmetic and doesn't affect functionality.
Documentation
Next Steps
Documentation: Before merging, run
/docs 394to generate feature documentation.fix(#394): merge main and resolve conflicts with #389 and #391
admarble commentedon Mar 24, 2026
Merge Resolution Complete
Branch rebased onto current main (was 7 commits behind). Resolved conflicts in 3 files:
src/mcp/tools/run.tsregisterRun/unregisterRuncalls into the updated async handler withresolveCliBinary(#389) and structured output (#391)src/mcp/server-extended.test.tsexistsSyncimport (#389) and run-registry imports (#394)CHANGELOG.mdBuild: Passes
Tests: 84/84 MCP-related tests pass
Ready for
/qa 394.admarble commentedon Mar 24, 2026
QA Review for Issue #394
AC Coverage
sequant_statusreturns current phase during run.sequant/state.jsonwhich is updated by batch-executor before phase execution. Integration test confirms via MCP transport.batch-executor.tscallsupdatePhaseStatus()before phase handler. Validated end-to-end.server-extended.test.ts:510).isRunning: trueindicator when run is activeisRunningfield added to both tracked and untracked issue responses. Registry-backed viarun-registry.ts.run-registry.tssingleton withMap<number, ActiveRun>. Register before spawn, unregister infinally.isRunning: falseafter process exitsfinallyblock ensuresunregisterRunruns on success, error, and abort paths. Unit tests confirm.server-extended.test.ts:456-502tests mid-run status polling with mock process, verifies lifecycle transition.Coverage: 7/7 AC items fully met
Original ACs: 4/4 met
Derived ACs: 3/3 met
Quality Plan Verification
Derived ACs: 3/3 addressed
Quality Plan Status: Complete
CI Status
build (20.x)build (22.x)validate-skillstypecheckvalidate-pluginCI Summary: 5 passed, 0 pending, 0 failed
Stale Branch Check
Quality Metrics
any)Build Verification
N/A — Build passed (
npm run buildexits 0)Test Coverage Analysis
src/mcp/run-registry.tssrc/mcp/run-registry.test.tssrc/mcp/tools/run.tssrc/mcp/server-extended.test.tssrc/mcp/tools/status.tssrc/mcp/server-extended.test.tsCHANGELOG.mdCoverage: 3/3 changed source files have corresponding tests
Critical paths without tests: None
Code Review
Strengths:
finallyblock ensures cleanup on all exit paths (success, error, abort, timeout)isRunningadded to both tracked and untracked responses — consistent API surfaceisRunningfield without changing existing response shapeIssues:
registerRun(issue, process.pid)atrun.ts:338stores the MCP server's own PID, not the spawned child's PID. The child PID isn't available untilspawnAsyncstarts internally. Functionally harmless sinceisRunning()only checks map presence, but thepidfield inActiveRunis misleading. Consider renaming toserverPidor documenting the limitation.Suggestions:
ActiveRun.pidis ever used for process management.Test Quality Review
isRunningoutput and MCP response shape, not registry internalschild_process.spawn(external dependency)setTimeout(r, 10)for event loop tick — minimal timing sensitivityAnti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected:
awaitin loopsCritical Issues: 0
Warnings: 0
Call-Site Review
New exported functions detected: 5
registerRun()run.ts:338unregisterRun()run.ts:404finallyblockisRunning()status.ts:53,status.ts:69getActiveRuns()clearRegistry()@internaltesting utilityFindings: All call sites match AC constraints. No issues.
Execution Evidence
N/A — No scripts changed. MCP tool changes verified via integration tests.
Skill Command Verification
N/A — No skill files changed.
CLI Registration Verification
N/A — No option interface changes.
Smoke Test
Not Required — No workflow-affecting changes (no skills, scripts, or CLI changes).
CHANGELOG Verification
Result: CHANGELOG requirements met
Self-Evaluation
isRunningfield, and cleanup failuresfinallyblock doesn't fire (e.g., process crash). Acceptable — in-memory registry is ephemeral by design, server restart clears all state.Verdict: READY_FOR_MERGE
All 7 AC items (4 original + 3 derived) are met. Implementation is clean, backward compatible, and well-tested. CI is 5/5 green. The minor PID semantics note is cosmetic and doesn't affect functionality.
Documentation
Next Steps
Documentation: Before merging, run
/docs 394to generate feature documentation.fix(#394): remove misleading pid from run registry, update docs
docs(#394): add sequant_status response table and polling guidance
admarble commentedon Mar 24, 2026
Documentation Updated
File:
docs/features/mcp-server.md(existing file updated — no new file needed)Changes:
sequant_statusresponse field table (matchingsequant_runresponse table style)isRunningfield with polling guidance (5–10 second interval)isRunningpidfield from run registry (code cleanup)Sections Updated:
sequant_status(response table + polling)Quality Check:
Ready to merge!
Merge pull request #408 from sequant-io/feature/394-mcp-server-real-t…