MCPcopy
hub / github.com/Doorman11991/smallcode / sanitizeToolOutput

Function sanitizeToolOutput

src/security/sanitize.js:234–240  ·  view source on GitHub ↗

* Sanitize a tool result string before adding it to model context: * 1. Strip ANSI / C1 controls * 2. Redact secrets * 3. Normalize line endings

(input)

Source from the content-addressed store, hash-verified

232 * 3. Normalize line endings
233 */
234function sanitizeToolOutput(input) {
235 if (typeof input !== 'string') return input;
236 let out = stripAnsi(input);
237 out = redactString(out);
238 out = out.replace(/\r\n/g, '\n');
239 return out;
240}
241
242// ─── Listener leak guard (for long-running stdio servers) ───────────────────
243

Callers 11

runTestsFunction · 0.85
_drainMethod · 0.85
callToolMethod · 0.85
_fetchWithBrowserFunction · 0.85
_fetchSimpleFunction · 0.85
resolveReferencesFunction · 0.85
getGitDiffContextFunction · 0.85
_chatCompletionMethod · 0.85
_executeToolMethod · 0.85
handleMCPToolCallFunction · 0.85
executeToolFunction · 0.85

Calls 2

redactStringFunction · 0.85
stripAnsiFunction · 0.70

Tested by

no test coverage detected