[Quality audit] Simplify MCP coordinator and tool surface

未关闭
#159 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
冷清
技术栈
typescript
领域
devtools

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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
主要语言
TypeScript
星标
1k
派生
144
平均合并
4 天 19 小时
30 天内合并 PR
28

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

johannesjo/parallel-code 的其他 Issue

查看 johannesjo/parallel-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。