fix: cast empty properties arrays to stdClass to prevent JSON [] instead of {}
This commit is contained in:
@@ -29,11 +29,18 @@ class Registry {
|
||||
|
||||
/** Returns MCP-formatted tool definitions for tools/list response */
|
||||
public function getToolDefinitions(): array {
|
||||
return array_values(array_map(fn($t) => [
|
||||
return array_values(array_map(function($t) {
|
||||
$schema = $t['inputSchema'];
|
||||
// PHP encodes empty [] as JSON array — cast to stdClass to get {}
|
||||
if (isset($schema['properties']) && $schema['properties'] === []) {
|
||||
$schema['properties'] = new \stdClass();
|
||||
}
|
||||
return [
|
||||
'name' => $t['name'],
|
||||
'description' => $t['description'],
|
||||
'inputSchema' => $t['inputSchema'],
|
||||
], $this->tools));
|
||||
'inputSchema' => $schema,
|
||||
];
|
||||
}, $this->tools));
|
||||
}
|
||||
|
||||
/** Returns callable handler for a tool, or null if not found */
|
||||
|
||||
Reference in New Issue
Block a user