[Quality audit] Simplify MCP coordinator and tool surface

Aperta
#159 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
devtools

Direzione di ricerca

Start with CODE_QUALITY_FINDINGS.md and the cited files under electron/mcp/**, especially coordinator.ts, server.ts, and validation.ts; inspect the existing config builder and related tests before choosing a finding. Run the MCP coordinator, validation, and tool-list tests, including the listed token-rotation, hydration, Docker path, prompt, idle, and cleanup cases. Done means the scoped duplications and unreachable validation branch are addressed and all acceptance checks pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Derived from the local audit report CODE_QUALITY_FINDINGS.md created on 2026-05-30.

Scope

This issue tracks complexity and duplication in electron/mcp/**.

Findings

  • Finding 9: tested MCP config builder is bypassed.
    • Evidence: buildCoordinatorMCPConfig is defined and tested, but StartMCPServer manually rebuilds the same object.
    • Fix direction: call buildCoordinatorMCPConfig in StartMCPServer.
  • Finding 10: sub-task MCP config construction is duplicated.
    • Evidence: duplicated mcpServers["parallel-code"] construction in restart rewrite, task creation, and hydration.
    • Fix direction: extract buildSubTaskMcpConfig, writeSubTaskMcpConfig, and isAllowedSubTaskMcpConfigPath; confirm mcpServerInfo.token contract.
  • Finding 15: agent output monitoring is copied in MCP coordinator.
    • Evidence: duplicated base64 decode, tail buffering, ANSI stripping, prompt detection, idle transitions, and resolver flushing.
    • Fix direction: extract createAgentOutputMonitor(task) and handlePromptDetected(task).
  • Finding 16: task teardown cleanup repeats in MCP coordinator.
    • Evidence: removeCoordinatedTask, cleanupTask, and deregisterCoordinator repeat lifecycle cleanup with subtle behavior differences.
    • Fix direction: extract narrow helpers for subscriptions, idle waiters, config cleanup, and control-state clearing.
  • Finding 17: MCP createTask has too many responsibilities.
    • Evidence: electron/mcp/coordinator.ts:398-740.
    • Fix direction: move preamble write/restore logic into preamble.ts and use small queued file mutation helpers.
  • Finding 18: MCP tool diff formatting and truncation is duplicated.
    • Evidence: electron/mcp/server.ts and electron/mcp/coordinator.ts both format/truncate diffs.
    • Fix direction: centralize formatDiffForTool(result, mergeInfo?) and one MAX_DIFF_BYTES.
  • Finding 19: deprecated review_and_merge_task is still advertised.
    • Evidence: electron/mcp/mcp-tool-list.ts, electron/mcp/server.ts, electron/mcp/client.ts.
    • Fix direction: keep compatibility handler if needed but remove the tool from advertised tools.
  • Finding 35: validation has an unreachable specific branch and duplicate tests.
    • Evidence: electron/mcp/validation.ts, duplicated validation coverage in coordinator tests.
    • Fix direction: move the @{ check before the generic invalid-character regex, or remove the branch; keep validation tests in validation.test.ts.

Acceptance checks

  • MCP coordinator test suite
  • MCP validation tests
  • MCP tool-list tests
  • token-rotation, hydration, Docker path, prompt, idle, and cleanup cases
Lingua principale
TypeScript
Stelle
1k
Fork
144
Merge medio
4g 19h
PR unite (30g)
28

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di johannesjo/parallel-code

Tutte le issue di johannesjo/parallel-code

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.