Skip to content

feat(#391): improve sequant_run MCP tool output structure - #407

Merged
admarble merged 4 commits into
mainfrom
feature/391-mcp-server-improve-sequant-run-output-structure
Mar 24, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/391-mcp-server-improve-sequant-run-output-structure

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Replace raw stdout tail with structured JSON containing per-issue summaries (status, phases, QA verdict, duration)
  • Parse run log files for rich data; fall back to raw output when logs unavailable
  • Enforce 64KB response size limit with progressive rawOutput truncation
  • Backwards compatible: status field preserved at top level

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original Structured JSON with per-issue summaries ✅ Implemented buildStructuredResponse() in run.ts:98
AC-2 Original Per-issue status/phases/verdict/duration ✅ Implemented RunToolIssueSummary interface, mapped from RunLog
AC-3 Original Raw output as secondary field ✅ Implemented rawOutput field, truncated to 2000 chars
AC-4 Original MCP response size limits ✅ Implemented enforceResponseSizeLimit() at 64KB
AC-5 Derived Graceful fallback when log unavailable ✅ Implemented buildFallbackResponse() returns issues: [] with raw output
AC-6 Derived Backwards-compatible status field ✅ Implemented Top-level status field preserved

Test plan

  • 16 unit tests for structured response construction
  • Tests for size limit enforcement, fallback on missing/corrupt logs, empty/single/multi-issue runs
  • Existing MCP integration tests updated for new response shape
  • All 1773 tests pass, build clean, lint clean

Closes #391

🤖 Generated with Claude Code

Replace raw stdout tail with structured per-issue summaries parsed from
run log files. Response includes status, phases, QA verdict, duration
per issue, plus summary stats. Raw output retained as secondary field.
Enforces 64KB response size limit with progressive truncation. Falls
back to raw output when log file is unavailable.

Entire-Checkpoint: 5581a0f7108f
…flicts

- Resolve merge conflicts in src/mcp/tools/run.ts: keep async
  spawnAsync + resolveCliBinary from main, structured output from #391
- Convert readLatestRunLog to async (fs/promises instead of sync I/O)
- Add run correlation via runStartTime parameter to filter stale logs
- Fix size limit enforcement to use Buffer.byteLength (bytes, not chars)
- Add multi-byte content test for size limit enforcement
- Update mcp-run-async tests: mock fs for resolveCliBinary fallback,
  use new structured response fields (rawOutput, issues[], summary)
- Fix pre-existing mcp-run-async test failures from #389 (resolveCliBinary
  changed spawn command from npx to process.argv[0])

Entire-Checkpoint: 5581a0f7108f
- Convert resolveLogDir to async (fs/promises.access instead of existsSync)
- Make enforceResponseSizeLimit pure (returns new object, no mutation)
- Add last-resort issues array truncation when structured data exceeds 64KB
- Document structured response format in docs/features/mcp-server.md
- Add tests: immutability check, multi-byte content, issues truncation
- Mock fs/promises.access in test suites for async resolveLogDir

Entire-Checkpoint: 5581a0f7108f
Revert three changes that added complexity without practical benefit:
- resolveLogDir: back to existsSync (2 stat calls, negligible)
- enforceResponseSizeLimit: back to simple mutation (private, single caller)
- issues array truncation: removed (unrealistic edge case, O(n^2))

Keep: response format documentation in mcp-server.md (useful for clients)
Entire-Checkpoint: 5581a0f7108f
@admarble
admarble merged commit 90d62b6 into main Mar 24, 2026
5 checks passed
@admarble
admarble deleted the feature/391-mcp-server-improve-sequant-run-output-structure branch March 24, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP server: improve sequant_run output structure

1 participant