Skip to content

Extract MCP write dispatch helpers from tools.rs #2604

@YOMXXX

Description

@YOMXXX

Summary

Extract the MCP write-dispatch and audit helper flow from the oversized src/openhuman/mcp_server/tools.rs module into a focused sibling module, likely src/openhuman/mcp_server/write_dispatch.rs.

Problem

src/openhuman/mcp_server/tools.rs is currently around 2,750 lines and now owns both broad MCP tool registry behavior and the write-dispatch/audit pipeline. That makes future audit-policy changes, write-tool routing fixes, and review of write-specific behavior harder than necessary.

The immediate review context is #2566: the audit feature is already large enough, so moving this code in the same PR would be a heavy refactor orthogonal to the audit-log behavior.

Solution (optional)

Move write-specific helpers such as dispatch_write_tool, audit_write, audit_write_rejection, audit_write_rejection_without_config, summarize_write_args, and related small support functions into mcp_server/write_dispatch.rs. Keep public behavior unchanged and leave tools.rs as the registry/orchestration entrypoint that delegates to the write-dispatch module.

Scope should stay mechanical where possible:

  • preserve existing MCP write-tool response behavior
  • preserve best-effort audit semantics from [codex] Add MCP write audit log #2566
  • preserve logging/correlation fields
  • keep tests focused on no behavior regression

Acceptance criteria

  • Write dispatch extracted — write-dispatch and audit helper code lives in a focused sibling module instead of inflating tools.rs.
  • Behavior unchanged — existing write-tool success, rejection, and audit paths continue to produce the same tool responses and audit records.
  • Regression safety — targeted Rust tests cover at least one successful write audit path and one rejected/failed write audit path after extraction.
  • Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/coverage.yml).

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions