@centure/node-sdk
A fully type-safe TypeScript SDK for interacting with Centure's API for prompt injection detection.
Installation
npm install @centure/node-sdk
Power your agent
คำสั่งของผู้เผยแพร่เอง ไม่ใช่เอนด์พอยต์ของ PlugMCP
Host a copy with our keys and logs.
npx -y @centure/[email protected]Claude Code ไม่มีลิงก์ติดตั้งสำหรับคำสั่งแบบโลคัล ให้คัดลอกคำสั่งด้านล่างแล้วรันในเทอร์มินัล
claude mcp add centure-node-sdk -- npx -y @centure/node-sdk@0.1.0รันในเทอร์มินัล
{ "mcpServers": { "centure-node-sdk": { "command": "npx", "args": [ "-y", "@centure/[email protected]" ] } }}claude_desktop_config.json
URL แบบรีโมตหรือคำสั่งบนเครื่องของคุณ? การติดตั้งสองแบบต่างกันอย่างไร
รันบน PlugMCP
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
เปิดจากผู้เผยแพร่
A fully type-safe TypeScript SDK for interacting with Centure's API for prompt injection detection.
npm install @centure/node-sdk
A Typescript SDK for interacting with Centure's API
import { CentureClient } from "@centure/node-sdk";
// Using environment variable CENTURE_API_KEY
const client = new CentureClient();
// Or provide API key directly
const client = new CentureClient({
apiKey: "your-api-key",
baseUrl: "https://api.centure.ai", // Optional, defaults to production
});
const result = await client.scanText("Your text content here");
console.log("Is safe:", result.is_safe);
console.log("Detected categories:", result.categories);
console.log("Reason:", result.reason); // Explanation when flagged
console.log("Request ID:", result.request_id);
Both scanText and scanImage accept an optional ScanOptions parameter:
// Only scan for specific categories
const result = await client.scanText("content", {
only: ["data_exfiltration", "unauthorized_actions"],
});
// Exclude certain categories
const result = await client.scanText("content", {
exclude: ["output_manipulation"],
});
// Set minimum confidence threshold
const result = await client.scanText("content", {
minimum_confidence: "high",
});
All options are optional.
// Using base64 string
const base64Image = "iVBORw0KGgoAAAANSUhEUgAA...";
const result = await client.scanImage(base64Image);
console.log("Is safe:", result.is_safe);
console.log("Detected threats:", result.categories);
// Using Buffer (Node.js) - automatically converted to base64
import fs from "fs";
const imageBuffer = fs.readFileSync("./image.png");
const result = await client.scanImage(imageBuffer);
All scan methods return a ScanResponse object:
interface ScanResponse {
is_safe: boolean;
categories: DetectedCategory[];
reason?: string;
request_id: string;
api_key_id: string;
request_units: number;
billed_request_units: number;
service_tier: ServiceTier;
}
interface DetectedCategory {
code: ThreatCategory;
confidence: ConfidenceLevel;
}
The SDK provides a transport wrapper for the Model Context Protocol (MCP) that automatically scans messages for prompt injection attacks.
The CentureMCPClientTransport wraps any MCP transport and intercepts messages to scan them for security threats before they reach your MCP server.
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { CentureClient } from "@centure/node-sdk";
import { CentureMCPClientTransport } from "@centure/node-sdk/mcp";
// Create your underlying MCP transport
const stdioTransport = new StdioClientTransport({
command: "your-mcp-server",
args: ["--arg1", "--arg2"],
});
// Wrap it with Centure security scanning
const secureTransport = new CentureMCPClientTransport({
client: new CentureClient({
apiKey: "your-api-key",
}),
transport: stdioTransport,
});
// Use with MCP client
const client = new Client({
name: "your-client",
version: "1.0.0",
});
await client.connect(secureTransport);
transport (Transport): The underlying MCP transport to wrap (e.g., StdioClientTransport, SSEClientTransport)client (CentureClient): Centure API client instance for scanning messagesshouldScanMessage ((context: ShouldScanMessageContext) => boolean | ShouldScanMessageResult):
Determines whether a specific message should be scanned. Return false or { scan: false } to skip scanning.
shouldScanMessage: ({ message, extra }) => {
// Skip scanning for tool list requests
if (message.method === "tool/list") {
return false;
}
return true;
};
onAfterScan ((context: OnAfterScanContext) => void | OnAfterScanResult):
Called after a message is scanned, regardless of the result. Can return { passthrough: true } to allow the message even if unsafe.
onAfterScan: ({ message, scanResult }) => {
console.log(`Scanned ${message.method}: ${scanResult.is_safe}`);
};
onUnsafeMessage ((context: OnUnsafeMessageContext) => OnUnsafeMessageResult):
Called when an unsafe message is detected. Must return an object specifying whether to allow or block the message.
onUnsafeMessage: ({ message, scanResult }) => {
// Allow medium-confidence threats
const isMedium = scanResult.categories.every(
(c) => c.confidence === "medium",
);
if (isMedium) {
return { passthrough: true };
}
// Block high-confidence threats with custom error
return {
passthrough: false,
replace: {
jsonrpc: "2.0",
id: message.id,
error: {
code: -32001,
message: "Security violation detected",
},
},
};
};
onBeforeSend ((context: { message: JSONRPCMessage, extra?: MessageExtraInfo }) => void):
Called before any message is sent through the transport.
onBeforeSend: ({ message, extra }) => {
console.log(`Sending ${message.method}`);
};
const secureTransport = new CentureMCPClientTransport({
client: new CentureClient({
baseUrl: "http://localhost:3001",
apiKey: "your-api-key",
}),
transport: stdioTransport,
shouldScanMessage: ({ message }) => {
// Skip scanning for certain safe methods
if (message.method === "tool/list") {
return false;
}
return true;
},
onUnsafeMessage: ({ message, scanResult }) => {
// Allow medium-confidence detections
const isMedium = scanResult.categories.every(
(c) => c.confidence === "medium",
);
if (isMedium) {
return { passthrough: true };
}
// Block high-confidence threats
return {
passthrough: false,
replace: {
jsonrpc: "2.0",
id: message.id,
error: {
code: -32001,
message: "Unsafe Message!",
},
},
};
},
});
type ShouldScanMessageContext = {
message: JSONRPCMessage;
extra?: MessageExtraInfo;
};
type OnAfterScanContext = {
message: JSONRPCMessage;
extra?: MessageExtraInfo;
scanResult: ScanResponse;
};
type OnUnsafeMessageContext = {
message: JSONRPCMessage;
extra?: MessageExtraInfo;
scanResult: ScanResponse;
};
type OnUnsafeMessageResult = {
passthrough: boolean;
replace?: JSONRPCMessage;
};
The SDK provides specific error classes for different scenarios:
import {
CentureClient,
BadRequestError,
UnauthorizedError,
PayloadTooLargeError,
MissingApiKeyError,
} from "@centure/node-sdk";
try {
const result = await client.scanText("content");
} catch (error) {
if (error instanceof UnauthorizedError) {
console.error("Invalid API key");
} else if (error instanceof BadRequestError) {
console.error("Invalid request:", error.message);
} else if (error instanceof PayloadTooLargeError) {
console.error("Image too large");
}
}
const client = new CentureClient({
apiKey: "your-api-key",
fetchOptions: {
timeout: 30000,
headers: {
"X-Custom-Header": "value",
},
},
});
import fetch from "node-fetch";
const client = new CentureClient({
apiKey: "your-api-key",
fetch: fetch as any,
});
The API detects the following threat categories:
MIT
A Typescript SDK for interacting with Centure's API
{ "mcpServers": { "centure-node-sdk": { "command": "npx", "args": [ "-y", "@centure/[email protected]" ] } }}เครื่องมือ
ยังไม่มีรายการเครื่องมือ เซิร์ฟเวอร์แบบรีโมตจะได้รายการหลังการตรวจสอบสถานะครั้งแรก
FAQ
คัดลอกคอนฟิก stdio สำหรับ Cursor, Claude Desktop, Claude Code หรือ VS Code ได้ในหน้านี้ คอนฟิกนี้ใช้การติดตั้งของผู้เผยแพร่ ไม่ใช่พร็อกซีของ PlugMCP
ระเบียนนี้ไม่ได้ระบุตัวแปรสภาพแวดล้อมที่จำเป็น
@centure/node Sdk ทำงานแบบโลคัลผ่าน stdio
ตรวจสอบล่าสุดเมื่อ 2026-11-14 A Typescript SDK for interacting with Centure's API