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 */
|
/** Returns MCP-formatted tool definitions for tools/list response */
|
||||||
public function getToolDefinitions(): array {
|
public function getToolDefinitions(): array {
|
||||||
return array_values(array_map(fn($t) => [
|
return array_values(array_map(function($t) {
|
||||||
'name' => $t['name'],
|
$schema = $t['inputSchema'];
|
||||||
'description' => $t['description'],
|
// PHP encodes empty [] as JSON array — cast to stdClass to get {}
|
||||||
'inputSchema' => $t['inputSchema'],
|
if (isset($schema['properties']) && $schema['properties'] === []) {
|
||||||
], $this->tools));
|
$schema['properties'] = new \stdClass();
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'name' => $t['name'],
|
||||||
|
'description' => $t['description'],
|
||||||
|
'inputSchema' => $schema,
|
||||||
|
];
|
||||||
|
}, $this->tools));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns callable handler for a tool, or null if not found */
|
/** Returns callable handler for a tool, or null if not found */
|
||||||
|
|||||||
Reference in New Issue
Block a user