Skip to content

Add event-level redact_event hook, protect server/client identity fields - #50

Merged
naji247 merged 1 commit into
mainfrom
feat/event-level-redaction-hook-and-protected-fields
Aug 7, 2026
Merged

Add event-level redact_event hook, protect server/client identity fields#50
naji247 merged 1 commit into
mainfrom
feat/event-level-redaction-hook-and-protected-fields

Conversation

@naji247

@naji247 naji247 commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds an event-level redact_event hook (AgentCatOptions.redact_event), matching the redactEvent/RedactEvent hooks already available in the TypeScript and Go SDKs. It runs before redact_sensitive_information, receives the full event, and may return a modified event or None to drop it entirely. id, session_id, project_id, event_type, and timestamp are restored from the original event afterward regardless of what the hook returns.
  • Adds server_name, server_version, client_name, and client_version to PROTECTED_FIELDS: these are system-reported MCP metadata, not user-supplied content, and should always reach the dashboard intact rather than passing through redact_sensitive_information.

Example

from agentcat import AgentCatOptions

def redact_event(event):
    if event.resource_name == "get_credentials":
        return None
    if event.resource_name == "export_report":
        event.response = None
    return event

agentcat.track(server, "proj_0000000", AgentCatOptions(redact_event=redact_event))

Test plan

  • Full test suite passes
  • New tests covering the event-level hook: raw-value visibility, mutation, drop, restored fields, hook failures, sync/async, and pipeline ordering relative to redact_sensitive_information
  • README updated with usage docs

…ient identity fields

Add an event-level redact_event hook (AgentCatOptions.redact_event),
matching the redactEvent/RedactEvent hooks already available in the
TypeScript and Go SDKs. It runs before redact_sensitive_information,
receives the full event, and may return a modified event or None to
drop it entirely. id, session_id, project_id, event_type, and
timestamp are restored from the original event afterward regardless
of what the hook returns.

Also add server_name, server_version, client_name, and client_version
to PROTECTED_FIELDS: these are system-reported MCP metadata, not
user-supplied content, and should always reach the dashboard intact
rather than passing through redact_sensitive_information.
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.

2 participants