Skip to content

Extract MCP write dispatch helpers from tools.rs #17

@ElioNeto

Description

@ElioNeto

Original issue tinyhumansai#2604 by @YOMXXX on 2026-05-25T06:00:10Z


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 tinyhumansai#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:

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions