Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUv872878a61667
diff --git a/v3/mcp/tool-registry.ts b/v3/mcp/tool-registry.ts
index 3b019410cd..2529ab7df4 100644
--- a/v3/mcp/tool-registry.ts
+++ b/v3/mcp/tool-registry.ts
@@ -345,6 +345,30 @@ export class ToolRegistry extends EventEmitter {
return Array.from(this.tagIndex.keys());
}
+ /**
+ * Validate input against schema
+ */
+ private validateInput(input: Record<string, unknown>, schema: JSONSchema): { valid: boolean; errors?: string[] } {
+ try {
+ const validate = ajv.compile(schema);
+ const valid = validate(input);
+
+ if (!valid && validate.errors) {
+ return {
+ valid: false,
+ errors: validate.errors.map(e => `${e.instancePath || 'input'}: ${e.message}`),
+ };
+ }
+
+ return { valid: true };
+ } catch (error) {
+ return {
+ valid: false,
+ errors: [`Schema validation error: ${error instanceof Error ? error.message : String(error)}`],
+ };
+ }
+ }
+
/**
* Execute a tool
*/
@@ -363,6 +387,19 @@ export class ToolRegistry extends EventEmitter {
};
}
+ // Validate input against schema before execution (security boundary)
+ const validation = this.validateInput(input, metadata.tool.inputSchema);
+ if (!validation.valid) {
+ this.logger.warn('Tool input validation failed', {
+ name,
+ errors: validation.errors,
+ });
+ return {
+ content: [{ type: 'text', text: `Input validation failed: ${validation.errors?.join(', ')}` }],
+ isError: true,
+ };
+ }
+
const execContext = { ...this.defaultContext, ...context };
this.totalExecutions++;
metadata.callCount++;