MCPcopy
hub / github.com/coder/mux / validateArgs

Method validateArgs

src/node/services/ptc/toolBridge.ts:119–131  ·  view source on GitHub ↗
(toolName: string, tool: Tool, args: unknown)

Source from the content-addressed store, hash-verified

117 }
118
119 private validateArgs(toolName: string, tool: Tool, args: unknown): unknown {
120 // Access the tool's Zod schema - AI SDK tools use 'inputSchema', some use 'parameters'
121 const toolRecord = tool as { inputSchema?: z.ZodType; parameters?: z.ZodType };
122 const schema = toolRecord.inputSchema ?? toolRecord.parameters;
123 if (!schema) return args;
124
125 const result = schema.safeParse(args);
126 if (!result.success) {
127 const issues = result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
128 throw new Error(`Invalid arguments for ${toolName}: ${issues}`);
129 }
130 return result.data;
131 }
132
133 private serializeResult(result: unknown): unknown {
134 try {

Callers 1

registerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected