@centure/node-sdk provides a transport wrapper for the Model Context Protocol (MCP) that automatically scans messages for prompt injection attacks before they reach your MCP server.
What is MCP?
The Model Context Protocol is a standard for connecting AI models to external tools and data sources. The Centure SDK intercepts MCP messages to detect and block malicious prompts.Installation
Install both the Centure SDK and the MCP SDK:Basic Setup
Wrap any MCP transport withCentureMCPClientTransport to add automatic scanning:
The transport intercepts all messages sent through the MCP client and scans them before forwarding to the server.
Configuration Hooks
The transport provides hooks to customize scanning behavior:shouldScanMessage
Determines whether a specific message should be scanned. Returnfalse to skip scanning.
message(JSONRPCMessage) - The MCP message to potentially scanextra(MessageExtraInfo) - Additional context about the message
boolean or { scan: boolean }
onAfterScan
Called after a message is scanned, regardless of the result. Use this for logging or metrics.message(JSONRPCMessage) - The scanned messageextra(MessageExtraInfo) - Additional contextscanResult(ScanResponse) - The scan result from Centure API
void or { passthrough: boolean }
onUnsafeMessage
Called when an unsafe message is detected. Controls whether to block or allow the message.message(JSONRPCMessage) - The unsafe messageextra(MessageExtraInfo) - Additional contextscanResult(ScanResponse) - The scan result from Centure API
{ passthrough: boolean, replace?: JSONRPCMessage }
onBeforeSend
Called before any message is sent through the transport, before scanning occurs.message(JSONRPCMessage) - The message about to be sentextra(MessageExtraInfo) - Additional context
void
Complete Example
Here’s a production-ready configuration with all hooks:Transport Types
CentureMCPClientTransportOptions
Configuration options for the transport wrapper:Hook Context Types
Best Practices
Supported Transports
TheCentureMCPClientTransport works with any MCP transport implementation:
- StdioClientTransport - Communicate with servers via stdin/stdout
- SSEClientTransport - Communicate with servers via Server-Sent Events
- Custom transports - Any transport implementing the MCP Transport interface
Error Handling
The transport handles scanning errors gracefully:If the Centure API is unreachable or returns an error, the message is blocked by default. Use
onAfterScan to implement custom fallback behavior.Next Steps
Quickstart
Get started with basic SDK usage
API Reference
Explore response types and configuration options
MCP Documentation
Learn more about the Model Context Protocol
GitHub Repository
View source code and examples

