Skip to content

feat(mcp): per-call result size override via _meta annotation#6343

Merged
bug-ops merged 1 commit into
mainfrom
feat/issue-3079/per-tool-result-size-override
Jul 17, 2026
Merged

feat(mcp): per-call result size override via _meta annotation#6343
bug-ops merged 1 commit into
mainfrom
feat/issue-3079/per-tool-result-size-override

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • MCP servers can now request a larger truncation limit for a single tool result via _meta["zeph/maxResultSizeChars"], mirroring Claude Code's _meta["anthropic/maxResultSizeChars"] pattern.
  • The requested size is clamped server-side to a new operator-configured ceiling, [tools.overflow].max_per_call_override (default 131072 = 128 KiB) — the MCP server can never exceed this ceiling and can only raise the effective limit above the existing global threshold, never lower it.
  • Absent or malformed _meta values fall back to exactly the prior global-threshold behavior (fail-closed, zero regression for servers that don't opt in).
  • max_per_call_override = 0 disables the feature entirely and logs a tracing::warn! if misconfigured (0 < max_per_call_override <= threshold).
  • Includes a config migration (step 89, migrate_overflow_max_per_call_override) so existing on-disk configs surface the new key via --migrate-config.

Closes #3079

Design

Full architecture review chain: architect → critic (approved) → developer → tester/perf/security/impl-critic (parallel validation) → code review (2 rounds). See .local/handoff/ in this branch's history for the complete design and audit trail.

Notable findings resolved during review:

  • Config migration step (CLAUDE.md Dev-Rule M4: Telegram bot channel #5) was initially skipped, then added per impl-critic finding.
  • Root config/default.toml was initially missed (only crates/zeph-core/config/default.toml got the new key) — caught by code review, fixed.
  • Security audit confirmed no bypass path for the clamp, no integer overflow, and that zeph-sanitizer's independent max_content_size (64 KiB default) further bounds the real effective ceiling below the documented 128 KiB.

Test plan

  • 24 new unit/integration tests: clamp formula edge cases, fail-closed _meta parsing (missing/non-numeric/negative/float/bool/overflow), M2 misconfiguration warning, E2E ToolOutputprocess_one_tool_result path
  • Migration step-89 tests: adds-when-absent, noop-when-present, idempotent
  • Full targeted workspace test run: 4805/4805 pass
  • Full CI-matching check suite (fmt, clippy --profile ci, nextest full workspace, rustdoc gate, gitleaks) — clean
  • .local/testing/playbooks/mcp.md updated with 4 new scenarios (valid override, above-ceiling clamp, malformed/missing fallback, disabled-via-zero)
  • .local/testing/coverage-status.md row added (Status: Untested — pending live-session verification)

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate config Configuration file changes enhancement New feature or request size/XL Extra large PR (500+ lines) labels Jul 16, 2026
@bug-ops
bug-ops force-pushed the feat/issue-3079/per-tool-result-size-override branch from a2dbf52 to a372fd3 Compare July 16, 2026 22:56
MCP servers can now request a larger truncation threshold for a single
tool call by annotating the result with _meta["zeph/maxResultSizeChars"],
clamped server-side to the new [tools.overflow].max_per_call_override
ceiling (default 128K). Absent or malformed annotations fall back to the
existing global threshold unchanged. Includes a config migration
(step 89) so existing on-disk configs surface the new key.
@bug-ops
bug-ops enabled auto-merge (squash) July 17, 2026 00:24
@bug-ops
bug-ops force-pushed the feat/issue-3079/per-tool-result-size-override branch from a372fd3 to c393be9 Compare July 17, 2026 00:24
@bug-ops
bug-ops merged commit 2c12acc into main Jul 17, 2026
43 checks passed
@bug-ops
bug-ops deleted the feat/issue-3079/per-tool-result-size-override branch July 17, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

research(mcp): per-tool result size override via _meta annotation — Claude Code pattern

1 participant