Skip to content
WebMCP Agents
Esc
↑↓navigate↵open⌘Jpreview
On this page

getRedactor

Returns the page's (or the server process's) redactor, which every library sink uses.

Returns the page’s redactor in a browser, or the process’s on a server. Every library sink uses it: the devtools log, the chat’s tool card, URLs and console lines leaving the page. It has the default rules until configureRedaction sets others. Use it to pass your own data through the same rules before you log or send it.

Import

import { getRedactor } from "@webmcp-agents/core/redact";

Example

Log an agent’s tool calls with the page’s rules applied:

import { onAgentEvent } from "@webmcp-agents/core";
import { getRedactor } from "@webmcp-agents/core/redact";

onAgentEvent((e) => {
  if (e.type === "start") console.log(e.tool, getRedactor()(e.args, { kind: "tool-input" }));
});

Options

None: getRedactor() takes no arguments.

Returns

The current Redactor. It is created with the defaults on first use and kept on globalThis, so two copies of the package on one page share it.

Notes

  • Read it where you use it, not once at start-up: a later configureRedaction replaces it.

See also

Was this page helpful?