Skip to main content
Most tools that accept user prose are good candidates for safetyCheck. This example shows the wrapper in isolation — same shape as the weather server’s summarizer tool.

summarizer.ts

What happens on a flagged input

If the safety API flags the text parameter:
  1. The wrapper doesn’t call your handler.
  2. It returns a structured blocked response:
  3. With output_screen: true, your terminal also prints:
  4. The active span gets mcp.safety_check.flagged = true plus latency and content attributes.

What happens on a clean input

The wrapper writes safety attributes (flagged: false, latency, success) to the span, then calls your handler with the original params unchanged.

Customizing the blocked response

The blocked response uses structuredContent.summary as the summary key. If your tool’s outputSchema uses a different key, you’ll either:
  • match the wrapper’s expectation (call your output field summary), or
  • fork the wrapper for that tool.

Performance

The wrapper adds one round-trip to api.sedata-ai.tech per call. Typical latency: tens of milliseconds. The wrapper records this latency on the span as mcp.safety_check.latency_ms so you can monitor it. If the safety API is unreachable, the wrapper fails open — your handler runs and the span attribute mcp.safety_check.success is false. Set up an alert on mcp.safety_check.success = false rate to catch outages.

See also

Safety checks concept

Detailed flow and failure modes.

safetyCheck reference

Full function signature.