| 42 | ToolName: toolName, |
| 43 | RawSchema: rawSchema, |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | func (t *MCPDynamicTool) DecodeInput(raw map[string]any) (any, error) { |
| 48 | schema := BuildMCPInputSchema(t.ToolName, t.RawSchema) |
| 49 | normalized := coerceMCPInputForSchema(raw, schema) |
| 50 | compiler := jsonschemavalidator.NewCompiler() |
| 51 | const schemaURL = "lumina://mcp-input.schema.json" |
| 52 | if err := compiler.AddResource(schemaURL, schema); err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | compiled, err := compiler.Compile(schemaURL) |
| 56 | if err != nil { |
| 57 | return nil, err |
| 58 | } |
| 59 | if err := compiled.Validate(normalized); err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | return filterMCPInputForModelDump(normalized, t.RawSchema), nil |