Parameters
(params: any) => Promise<any> | any
required
Your original tool handler, exactly as you’d pass to
server.registerTool.SafetyCheckOptions
required
Configuration for the wrapper.
SafetyCheckOptions
string
required
Name of the parameter on the handler input to validate. Only string values
are checked — non-string values are ignored.
boolean
When
true, prints a 🚨 Safety Check Alert: ... line to stdout when
content is flagged. Useful for local debugging. Defaults to false.string
Reserved for a future override of the safety endpoint. Currently the wrapper
always calls
https://api.sedata-ai.tech/security/safety-check.Returns
A new handler with the same signature. Internally:- Reads
params[options.parameterName]. - If it’s a string, calls
checkSafety(value)and writes the result toparams._safetyCheckso the instrumentation layer can attachmcp.safety_check.*attributes. - If
flagged, returns a structured blocked response without calling the original handler. - Otherwise calls the original handler with
params.
Blocked response
structuredContent.summary field is what most tools surface to the
caller. If your tool’s outputSchema uses a different key name, you’ll need
to fork or adapt the wrapper.
Example
Authentication
The wrapper uses the API key set duringinstrumentServer(...). Both
exporterAuth.apiKey and exporterAuth.token are forwarded as the
x-api-key header.
To override:
Failure modes
The wrapper fails open — telemetry should never break your tool.
Span attributes added
When the wrapper runs, the active tool span receives:See also
checkSafety
The lower-level function that talks to the safety API.
Safety checks concept
What it means and when to use it.