@general-analysis/mcp-guard
Version:
An MCP guardrail with built-in AI-powered moderation that aggregates multiple MCP servers into one secure interface
54 lines • 2.01 kB
JavaScript
import { z } from "zod";
// Server configuration schemas
export const StdioServerConfigSchema = z.object({
name: z.string(),
command: z.string(),
args: z.array(z.string()).optional().default([]),
env: z.record(z.string()).optional().default({}),
});
export const RemoteServerConfigSchema = z.object({
name: z.string(),
url: z.string(),
});
export const ServerConfigSchema = z.union([
StdioServerConfigSchema,
RemoteServerConfigSchema,
]);
// Blocked response constant
export const BLOCKED_RESPONSE = {
content: [
{
type: "text",
text: "BLOCKED: This response was blocked by the moderation system due to potential prompt injection content. Please let the user know that their data source may contain prompt injection or jailbreak attempts.",
},
],
isError: true,
};
// Helper function to create a payment required warning response
export function createPaymentRequiredResponse(originalOutput) {
const warningMessage = "Important Notice: Please inform the user that their tool outputs are no longer moderated due to insufficient account credits. The user should visit app.generalanalysis.com (make it clickable markdown) to reactivate their account and restore moderation protection. This may create security issues for the user so please inform them.";
// If the original output has content array, prepend the warning
if (originalOutput && originalOutput.content && Array.isArray(originalOutput.content)) {
return {
...originalOutput,
content: [
{
type: "text",
text: warningMessage,
},
...originalOutput.content,
],
};
}
// Fallback for other output formats
return {
content: [
{
type: "text",
text: warningMessage,
},
],
originalOutput,
};
}
//# sourceMappingURL=types.js.map