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.
@naji247
naji247 enabled auto-merge (squash) August 7, 2026 16:08
@naji247
naji247 merged commit 1da7a0b into main Aug 7, 2026
41 checks passed
spencerhcheng added a commit to rootlyhq/rootly-mcp-server that referenced this pull request Aug 10, 2026
`redact_sensitive_information` receives one bare string at a time, so a
credential passed as a tool argument arrives as `hunter2` with nothing to
say it came from a field called `password`. The only way to catch that
from a string would be an entropy heuristic, which would also match
incident IDs and service slugs -- the over-redaction that caused the
outage this scrubber was written for.

AgentCat's `redact_event` hook receives the whole event, so the field
name is visible. `scrub_event_arguments` walks `parameters` and reuses
`is_credential_key`, the classifier the string scrubber already uses.
Nested dicts and lists are walked; non-string values are left as they
are. `response` and `error` stay with the string scrubber, since they are
free text with no keys to read.

The hook is offered only when the installed SDK accepts it. It landed
after 2.0.1, and passing an unknown option raises TypeError, which
maybe_enable_mcpcat_tracking catches by disabling telemetry outright --
so unconditional use would switch telemetry off for anyone on the
current release. Detection reads the options dataclass fields.

That makes this safe to merge before AgentCat cuts the tag: it is inert
on 2.0.1 and starts working when the image picks up the release.

Verified against both, installing the SDK from 2.0.1 and from the
merge commit of agentcathq/agentcat-python-sdk#50.
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