Skip to content

fix(platform): keep zero request/response byte counts in tools_call audit records - #122

Closed
devopssquaddev wants to merge 1 commit into
mainfrom
fix/mcp-audit-zero-bytes
Closed

devopssquaddev wants to merge 1 commit into
mainfrom
fix/mcp-audit-zero-bytes

Conversation

@devopssquaddev

Copy link
Copy Markdown
Owner

Problem

Every native MCP tools/call writes one audit record (event: tools_call) that must carry tool, tenant_id, status, elapsed_s, request_bytes and response_bytes, including denials.

The shared JsonFormatter only kept a 0 value for a short allowlist (elapsed_s, since_send_s, sse_drops, id, pending_id). A denied or failed call has response_bytes: 0, so its audit record was logged without response_bytes, and request_bytes disappeared for calls with empty arguments. The live S-73 audit test caught it on a denied postgres__query record.

Fix

request_bytes and response_bytes join the keys whose 0 is kept. No other keys change behavior.

Verification

  • New test_json_formatter_keeps_zero_byte_counts_on_denied_audit_record fails before the fix (KeyError: 'request_bytes') and passes after.
  • tests/test_platform_logging.py + tests/test_mcp_tool_policy.py: 49 passed.

The formatter ships in every first-party image; only records that log byte counters (MCP backends, sidecar) are affected.

🤖 Generated with Claude Code

…udit records

The shared JsonFormatter only kept a 0 value for a few keys, so a denied or
failed tools/call (response_bytes=0) logged its audit record without
response_bytes, and request_bytes vanished for empty arguments. The native MCP
audit record requires both fields on every tools/call, including denials.

Found by the live S-73 audit test: the denied record it read had no
response_bytes. The new contract test fails before the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 472831b 2026-11-16T08:05:23.121Z Visit the dashboard ↗

@devopssquaddev

Copy link
Copy Markdown
Owner Author

Superseded by #123 (release 2.4.5), which carries this commit unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant