safetyCheck wrapper sits in front of any tool handler and runs the input
through Sedata’s safety API before your code sees it. Flagged content gets a
canned blocked response; clean content passes through transparently.
Flow
1
Wrap the handler
safetyCheck(handler, { parameterName: 'text' }) returns a new handler
that knows which input field to inspect.2
Inspect the parameter
On invocation, the wrapper reads
params[parameterName]. If it’s a string,
it sends a POST to https://api.sedata-ai.tech/security/safety-check
with { "content": "<value>" }.3
Decide
- Flagged → return a structured “blocked” response without calling your handler.
- Not flagged → call your handler with the original params.
- API error → log a warning and call your handler (fail-open).
4
Annotate the span
Either way, the wrapper writes
params._safetyCheck so the
instrumentation layer can attach mcp.safety_check.* attributes to the
active span.Authentication
The safety API expects anx-api-key header. The wrapper picks it up
automatically from your instrumentServer config:
Blocked response shape
When content is flagged, the wrapper returns a response that satisfies most tool output schemas:Failure modes
The wrapper is designed to fail open — telemetry should never take down
your tool. If you want fail-closed semantics, layer your own retry / strict
check on top.
When to use it
UsesafetyCheck for any tool whose input is free-form user content:
- summarizers, translators, classifiers
- code generators / interpreters
- anything that could be prompt-injected
- structured numeric inputs (no content to flag)
- internal tools called only by trusted automation
- tools where blocking would break correctness (calculators, lookups)
Span attributes added
When the wrapper runs, the span for that tool call includes:Next
safetyCheck reference
The full function signature, options, and types.
Example with safety
A complete summarizer tool with
safetyCheck.