test(schema): add test for setting tool schemas with no argument input
Some checks failed
CI / build-and-test (push) Failing after -30m38s

This commit is contained in:
2026-04-05 16:19:55 +02:00
parent 5f48a197e8
commit 02bcbdabd8
2 changed files with 25 additions and 0 deletions

View File

@@ -221,12 +221,19 @@ func formatLogDuration(d time.Duration) string {
return fmt.Sprintf("%02d:%02d:%03d", minutes, seconds, milliseconds)
}
func normalizeObjectSchema(schema *jsonschema.Schema) {
if schema != nil && schema.Type == "object" && schema.Properties == nil {
schema.Properties = map[string]*jsonschema.Schema{}
}
}
func setToolSchemas[In any, Out any](tool *mcp.Tool) error {
if tool.InputSchema == nil {
inputSchema, err := jsonschema.For[In](toolSchemaOptions)
if err != nil {
return fmt.Errorf("infer input schema: %w", err)
}
normalizeObjectSchema(inputSchema)
tool.InputSchema = inputSchema
}