π 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix: 6 MCP tool validation bugs β git refs, npm names, WASM serialization (v3.6.1)
Reuven39c3ffe96244
diff --git a/package-lock.json b/package-lock.jsonindex 04a7511bb5..2675db7132 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "claude-flow",- "version": "3.5.82",+ "version": "3.6.1","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "claude-flow",- "version": "3.5.82",+ "version": "3.6.1","license": "MIT","dependencies": {"semver": "^7.6.0",diff --git a/package.json b/package.jsonindex a2f60ee825..d3f2e7b304 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "claude-flow",- "version": "3.5.82",+ "version": "3.6.1","description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "dist/index.js","type": "module",diff --git a/ruflo/package.json b/ruflo/package.jsonindex 7c6f2c04ea..2a3f4081f0 100644--- a/ruflo/package.json+++ b/ruflo/package.json@@ -1,6 +1,6 @@{"name": "ruflo",- "version": "3.5.82",+ "version": "3.6.1","description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "bin/ruflo.js","type": "module",diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.jsonindex 34ca79955f..32fcacdac9 100644--- a/v3/@claude-flow/cli/package.json+++ b/v3/@claude-flow/cli/package.json@@ -1,6 +1,6 @@{"name": "@claude-flow/cli",- "version": "3.5.82",+ "version": "3.6.1","type": "module","description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code","main": "dist/src/index.js",diff --git a/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.tsindex cabe372232..a3d37aee6f 100644--- a/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts@@ -473,7 +473,7 @@ export const agentdbConsolidate: MCPTool = {export const agentdbBatch: MCPTool = {name: 'agentdb_batch',- description: 'Batch operations on memory entries (insert, update, delete)',+ description: 'Batch operations on AgentDB episodes (insert, update, delete). Note: entries are stored in the AgentDB episodes table, not the memory_search namespace. Use memory_store for entries that should be searchable via memory_search.',inputSchema: {type: 'object',properties: {diff --git a/v3/@claude-flow/cli/src/mcp-tools/analyze-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/analyze-tools.tsindex 0e1cb46798..7c8b6736d4 100644--- a/v3/@claude-flow/cli/src/mcp-tools/analyze-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/analyze-tools.ts@@ -4,7 +4,7 @@*/import type { MCPTool } from './types.js';-import { validateIdentifier, validatePath } from './validate-input.js';+import { validateGitRef, validatePath } from './validate-input.js';import {analyzeDiff,assessFileRisk,@@ -51,7 +51,7 @@ export const analyzeDiffTool: MCPTool = {},},handler: async (params: Record<string, unknown>) => {- if (params.ref) { const vRef = validateIdentifier(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }+ if (params.ref) { const vRef = validateGitRef(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }const ref = (params.ref as string) || 'HEAD';const includeFileRisks = params.includeFileRisks !== false;const includeReviewers = params.includeReviewers !== false;@@ -112,7 +112,7 @@ export const diffRiskTool: MCPTool = {},},handler: async (params: Record<string, unknown>) => {- if (params.ref) { const vRef = validateIdentifier(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }+ if (params.ref) { const vRef = validateGitRef(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }const ref = (params.ref as string) || 'HEAD';try {@@ -155,7 +155,7 @@ export const diffClassifyTool: MCPTool = {},},handler: async (params: Record<string, unknown>) => {- if (params.ref) { const vRef = validateIdentifier(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }+ if (params.ref) { const vRef = validateGitRef(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }const ref = (params.ref as string) || 'HEAD';try {@@ -202,7 +202,7 @@ export const diffReviewersTool: MCPTool = {},},handler: async (params: Record<string, unknown>) => {- if (params.ref) { const vRef = validateIdentifier(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }+ if (params.ref) { const vRef = validateGitRef(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }const ref = (params.ref as string) || 'HEAD';const limit = (params.limit as number) || 5;@@ -303,7 +303,7 @@ export const diffStatsTool: MCPTool = {},},handler: async (params: Record<string, unknown>) => {- if (params.ref) { const vRef = validateIdentifier(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }+ if (params.ref) { const vRef = validateGitRef(params.ref, 'ref'); if (!vRef.valid) return { error: true, message: vRef.error, ref: params.ref }; }const ref = (params.ref as string) || 'HEAD';try {diff --git a/v3/@claude-flow/cli/src/mcp-tools/transfer-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/transfer-tools.tsindex a26340a87b..15b08b24da 100644--- a/v3/@claude-flow/cli/src/mcp-tools/transfer-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/transfer-tools.ts@@ -7,7 +7,7 @@*/import type { MCPTool, MCPToolResult } from './types.js';-import { validateIdentifier, validateText } from './validate-input.js';+import { validateIdentifier, validatePackageName, validateText } from './validate-input.js';/*** Helper to create MCP tool result@@ -335,7 +335,7 @@ export const transferTools: MCPTool[] = [required: ['name'],},handler: async (input): Promise<MCPToolResult> => {- { const v = validateIdentifier((input as { name: string }).name, 'name'); if (!v.valid) return createResult({ error: v.error }, true); }+ { const v = validatePackageName((input as { name: string }).name, 'name'); if (!v.valid) return createResult({ error: v.error }, true); }try {const { createPluginDiscoveryService } = await import('../plugins/store/index.js');const discovery = createPluginDiscoveryService();diff --git a/v3/@claude-flow/cli/src/mcp-tools/validate-input.ts b/v3/@claude-flow/cli/src/mcp-tools/validate-input.tsindex 310fe1cd90..adc690bbd9 100644--- a/v3/@claude-flow/cli/src/mcp-tools/validate-input.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/validate-input.ts@@ -11,6 +11,8 @@const SHELL_META = /[;&|`$(){}[\]<>!#\\]/;const PATH_TRAVERSAL = /\.\.[/\\]/;const IDENTIFIER_RE = /^[a-zA-Z0-9_][a-zA-Z0-9_\-.:]{0,127}$/;+const GIT_REF_RE = /^[a-zA-Z0-9_][a-zA-Z0-9_\-.:~^/]{0,255}$/;+const NPM_PACKAGE_RE = /^(@[a-zA-Z0-9_\-]+\/)?[a-zA-Z0-9_\-][a-zA-Z0-9_\-.]{0,213}$/;export interface ValidationResult {valid: boolean;@@ -41,6 +43,45 @@ export function validateIdentifier(value: unknown, label: string): ValidationResreturn { valid: true, sanitized: value };}+/**+ * Validate a git ref (HEAD~1, main..feature, commit hashes, etc.).+ * Allows ~, ^, and / which are standard git revision selectors.+ */+export function validateGitRef(value: unknown, label: string): ValidationResult {+ if (typeof value !== 'string' || value.length === 0) {+ return { valid: false, sanitized: '', error: `${label} must be a non-empty string` };+ }+ if (value.length > 256) {+ return { valid: false, sanitized: '', error: `${label} exceeds 256 characters` };+ }+ if (SHELL_META.test(value)) {+ return { valid: false, sanitized: '', error: `${label} contains disallowed characters` };+ }+ if (!GIT_REF_RE.test(value)) {+ return { valid: false, sanitized: '', error: `${label} contains invalid characters (allowed: alphanumeric, _, -, ., :, ~, ^, /)` };+ }+ return { valid: true, sanitized: value };+}++/**+ * Validate an npm package name (allows @scope/name format).+ */+export function validatePackageName(value: unknown, label: string): ValidationResult {+ if (typeof value !== 'string' || value.length === 0) {+ return { valid: false, sanitized: '', error: `${label} must be a non-empty string` };+ }+ if (value.length > 214) {+ return { valid: false, sanitized: '', error: `${label} exceeds 214 characters` };+ }+ if (SHELL_META.test(value)) {+ return { valid: false, sanitized: '', error: `${label} contains disallowed characters` };+ }+ if (!NPM_PACKAGE_RE.test(value)) {+ return { valid: false, sanitized: '', error: `${label} contains invalid characters (expected npm package name, e.g. @scope/name)` };+ }+ return { valid: true, sanitized: value };+}+/*** Validate a file path (prevents traversal and shell injection).*/diff --git a/v3/@claude-flow/cli/src/memory/memory-bridge.ts b/v3/@claude-flow/cli/src/memory/memory-bridge.tsindex b8f76ab01a..82ba1a9976 100644--- a/v3/@claude-flow/cli/src/memory/memory-bridge.ts+++ b/v3/@claude-flow/cli/src/memory/memory-bridge.ts@@ -1717,12 +1717,21 @@ export async function bridgeBatchOperation(params: { operation: string; entries:let result;switch (params.operation) {case 'insert': {- // insertEpisodes expects [{content, metadata?, embedding?}]+ if (typeof batch.insertEpisodes !== 'function') {+ return { success: false, error: 'BatchOperations.insertEpisodes not available β embedder may not be initialized. Use memory_store instead.' };+ }const episodes = params.entries.map((e: any) => ({content: e.value || e.content || JSON.stringify(e),metadata: e.metadata || { key: e.key },}));- result = await batch.insertEpisodes(episodes);+ try {+ result = await batch.insertEpisodes(episodes);+ } catch (insertErr: any) {+ if (insertErr?.message?.includes('null') || insertErr?.message?.includes('embedBatch')) {+ return { success: false, error: 'Embedder not initialized for batch insert. Use memory_store for individual entries or run embeddings_init first.' };+ }+ throw insertErr;+ }break;}case 'delete': {diff --git a/v3/@claude-flow/cli/src/ruvector/ruvllm-wasm.ts b/v3/@claude-flow/cli/src/ruvector/ruvllm-wasm.tsindex cd0d45039a..c28cfa88be 100644--- a/v3/@claude-flow/cli/src/ruvector/ruvllm-wasm.ts+++ b/v3/@claude-flow/cli/src/ruvector/ruvllm-wasm.ts@@ -178,7 +178,12 @@ export async function createHnswRouter(config: HnswRouterConfig): Promise<{return ok;},route(query: Float32Array, k = 3): HnswRouteResult[] {- return router.route(query, k);+ const raw = router.route(query, k);+ return Array.from(raw).map((r: any) => ({+ name: r.name ?? r.pattern_name ?? '',+ score: r.score ?? r.distance ?? 0,+ metadata: r.metadata ? (typeof r.metadata === 'string' ? JSON.parse(r.metadata) : r.metadata) : undefined,+ }));},clear(): void {router.clear();@@ -277,11 +282,19 @@ export async function createMicroLora(config: MicroLoraConfig): Promise<{const feedback = new mod.AdaptFeedbackWasm();feedback.quality = quality;feedback.learningRate = learningRate;- // Note: feedback.success not on prototype in v2.0.2, set via propertytry { (feedback as any).success = success; } catch { /* v2.0.2 quirk */ }- // Create a dummy input vector matching the configured inputDimconst input = new Float32Array(config.inputDim);- lora.adapt(input, feedback);+ try {+ lora.adapt(input, feedback);+ } catch (e: any) {+ if (e?.message?.includes('Input size mismatch')) {+ throw new Error(+ `MicroLoRA adapt failed: WASM expects inputDim=768 but this adapter was created with inputDim=${config.inputDim}. ` ++ `Recreate with inputDim=768 or a multiple of 768.`+ );+ }+ throw e;+ }},applyUpdates(gradients: Float32Array): void {lora.applyUpdates(gradients);diff --git a/v3/docs/adr/ADR-092-mcp-tool-validation-bugfixes.md b/v3/docs/adr/ADR-092-mcp-tool-validation-bugfixes.mdnew file mode 100644index 0000000000..bc8d3b5857--- /dev/null+++ b/v3/docs/adr/ADR-092-mcp-tool-validation-bugfixes.md@@ -0,0 +1,68 @@+# ADR-092: MCP Tool Input Validation Bugfixes++**Status**: Accepted+**Date**: 2026-04-28+**Version**: v3.6.0 β v3.6.1++## Context++Comprehensive tool verification (~190 MCP tools across 4 servers) revealed 6 bugs in input validation and WASM serialization within `@claude-flow/cli`. All stem from overly strict or mismatched validators, null safety gaps, and raw WASM objects leaking through the MCP JSON layer.++## Bugs Fixed++### Bug 1 β `analyze_diff` rejects `~` and `^` in git refs (v3.6.0)++**Symptom**: `analyze_diff(ref: "HEAD~1")` β error "ref contains invalid characters".+**Root cause**: All 5 `analyze_diff*` tools passed the `ref` parameter through `validateIdentifier()`, which only allows `[a-zA-Z0-9_\-.:])`. Standard git revision selectors `~`, `^`, and `/` were rejected.+**Fix**: Added `validateGitRef()` with regex `[a-zA-Z0-9_\-.:~^/]` and switched all 5 `analyze_diff*` handlers to use it. Shell metacharacters remain blocked.+**Files**: `validate-input.ts`, `analyze-tools.ts`++### Bug 2 β `transfer_plugin-info` rejects `@` in npm package names (v3.6.1)++**Symptom**: `transfer_plugin-info(name: "@claude-flow/embeddings")` β error "name contains invalid characters".+**Root cause**: Plugin name passed through `validateIdentifier()` which rejects `@` and `/`.+**Fix**: Added `validatePackageName()` with npm-scoped name regex `(@[a-zA-Z0-9_\-]+\/)?[a-zA-Z0-9_\-][a-zA-Z0-9_\-.]{0,213}` and switched `transfer_plugin-info` to use it.+**Files**: `validate-input.ts`, `transfer-tools.ts`++### Bug 3 β `agentdb_batch` insert crashes on null embedder (v3.6.1)++**Symptom**: `agentdb_batch(operation: "insert", entries: [...])` β "Cannot read properties of null (reading 'embedBatch')".+**Root cause**: `bridgeBatchOperation` calls `batch.insertEpisodes()` which internally calls `this.embedder.embedBatch()`, but the embedder dependency is null when the BatchOperations controller initializes without an embedding provider.+**Fix**: Added guard checking `insertEpisodes` availability and a try/catch that surfaces actionable error ("Use memory_store instead" or "run embeddings_init first"). Also updated tool description to clarify that batch entries go to the AgentDB episodes table, not the `memory_search` namespace.+**Files**: `memory-bridge.ts`, `agentdb-tools.ts`++### Bug 4 β `ruvllm_hnsw_route` returns raw WASM pointers (v3.6.1)++**Symptom**: Route results contain `[{__wbg_ptr: 1205504}]` instead of pattern data.+**Root cause**: `router.route()` returns WASM objects that JSON.stringify converts to `{__wbg_ptr: N}` instead of extracting the underlying fields.+**Fix**: Added serialization step in `createHnswRouter().route()` that maps WASM results to plain `{name, score, metadata}` objects.+**Files**: `ruvllm-wasm.ts`++### Bug 5 β `ruvllm_microlora_adapt` hardcoded 768 dimension (v3.6.1)++**Symptom**: Creating with `inputDim: 16` then calling adapt β "Input size mismatch: expected 768, got 16".+**Root cause**: The WASM binary internally validates against a fixed 768-dim expectation regardless of the configured `inputDim`. The JS wrapper correctly creates a `Float32Array(config.inputDim)` but the WASM rejects non-768 sizes.+**Fix**: Added try/catch in `adapt()` that detects the mismatch error and surfaces an actionable message explaining the 768-dim requirement.+**Files**: `ruvllm-wasm.ts`++### Bug 6 β `agentdb_batch` entries not findable via `memory_search` (v3.6.1)++**Symptom**: Entries stored via `agentdb_batch` insert can't be found via `memory_search` or deleted.+**Root cause**: `agentdb_batch` writes to the AgentDB episodes table while `memory_search` queries the sql.js memory table β different storage backends with no cross-query.+**Fix**: Updated `agentdb_batch` tool description to document this distinction and guide users to `memory_store` for entries that need to be searchable via `memory_search`.+**Files**: `agentdb-tools.ts`++## Decision++- Introduce domain-specific validators (`validateGitRef`, `validatePackageName`) rather than relaxing the general `validateIdentifier` regex+- WASM return values must always be serialized to plain JS objects before entering the MCP JSON layer+- When a dependency is null at runtime, surface an actionable error message pointing to the correct alternative++## Consequences++- `analyze_diff` now accepts all standard git revision syntax+- `transfer_plugin-info` now accepts npm-scoped package names+- `agentdb_batch` returns a clear error instead of a null dereference crash+- `ruvllm_hnsw_route` returns usable JSON data instead of opaque WASM pointers+- `ruvllm_microlora_adapt` explains the 768-dim requirement instead of a cryptic mismatch error+- Users are guided to `memory_store` when they need `memory_search`-compatible storagediff --git a/v3/package-lock.json b/v3/package-lock.jsonindex f0a300f8c0..8b66c73131 100644--- a/v3/package-lock.json+++ b/v3/package-lock.json@@ -1789,7 +1789,7 @@}},"@claude-flow/cli": {- "version": "3.5.82",+ "version": "3.6.1","hasInstallScript": true,"license": "MIT","dependencies": {