MCPcopy
hub / github.com/infinitered/reactotron / createRedactor

Function createRedactor

lib/reactotron-mcp/src/redaction.ts:125–156  ·  view source on GitHub ↗
(
  server: ReactotronServer,
  serverRedactionConfig: McpRedactionServerConfig,
)

Source from the content-addressed store, hash-verified

123const NO_CLIENT = "\0__no_client__"
124
125export function createRedactor(
126 server: ReactotronServer,
127 serverRedactionConfig: McpRedactionServerConfig,
128): Redactor {
129 const cache = new Map<string, ParsedRules | null>()
130
131 function parsedFor(clientId?: string): ParsedRules | null {
132 const key = clientId ?? NO_CLIENT
133 if (cache.has(key)) return cache.get(key)!
134 const clientConfig = getClientRedactionConfig(server, clientId)
135 const rules = resolveEffectiveRules(serverRedactionConfig, clientConfig)
136 const parsed = rules ? parseRules(rules) : null
137 cache.set(key, parsed)
138 return parsed
139 }
140
141 return {
142 redact(data, clientId) {
143 const parsed = parsedFor(clientId)
144 return parsed ? redactWithParsed(data, parsed) : data
145 },
146 redactState(data, clientId, statePath) {
147 const parsed = parsedFor(clientId)
148 return parsed ? redactWithParsed(data, parsed, statePath) : data
149 },
150 redactAsyncStorage(data, clientId) {
151 const parsed = parsedFor(clientId)
152 if (!parsed) return data
153 return redactWithParsed(redactAsyncStorageWithParsed(data, parsed), parsed)
154 },
155 }
156}
157
158function deepCopyRules(rules: McpRedactionRules): McpRedactionRules {
159 return {

Callers 3

redaction.test.tsFile · 0.90
registerToolsFunction · 0.90
registerResourcesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected