Skip to content

audit: option to record a JSON-RPC application error's code without its message #7371

Backlog

Description

@rdimitrov

Problem

audit.Config.DetectApplicationErrors does two things in pkg/audit/auditor.go (logAuditEvent):

  • It marks a JSON-RPC error inside an HTTP 200 response with the outcome application_error.
  • It copies the error's message, up to 256 bytes, into Metadata.Extra["jsonrpc_error_message"].

The message comes from the backend MCP server, and nothing redacts it. Errors such as "invalid params" often echo argument values. Upstream API errors can echo tokens or other credentials. An embedder whose audit policy forbids error text and unrestricted payload content in records has to turn detection off entirely. A failed call is then recorded as success.

Proposal

Add a setting that keeps detection and the outcome while dropping the message. For example:

// RecordApplicationErrorMessage, when false, keeps the application_error
// outcome and jsonrpc_error_code but leaves out jsonrpc_error_message.
// Nil keeps today's behaviour.
RecordApplicationErrorMessage *bool `json:"recordApplicationErrorMessage,omitempty"`

Defaulting nil to today's behaviour keeps existing deployments unchanged.

Context

Mecatl embeds the vMCP as an MCP gateway with audit on. It turns DetectApplicationErrors off for this reason, and so loses the application_error outcome on gateway tool calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions