feat: Add output schema support to MCP tools (#153)
This commit is contained in:
parent
4c3e5e61c7
commit
c0938a19bd
1 changed files with 605 additions and 55 deletions
|
|
@ -346,4 +346,45 @@ final class SchemaGeneratorTest extends TestCase
|
|||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->schemaGenerator->generate($method);
|
||||
}
|
||||
|
||||
public function testGenerateOutputSchemaReturnsNullForVoidReturnType(): void
|
||||
{
|
||||
$method = new \ReflectionMethod(SchemaGeneratorFixture::class, 'noParams');
|
||||
$schema = $this->schemaGenerator->generateOutputSchema($method);
|
||||
$this->assertNull($schema);
|
||||
}
|
||||
|
||||
public function testGenerateOutputSchemaWithReturnDescription(): void
|
||||
{
|
||||
$method = new \ReflectionMethod(SchemaGeneratorFixture::class, 'returnWithExplicitOutputSchema');
|
||||
$schema = $this->schemaGenerator->generateOutputSchema($method);
|
||||
$this->assertEquals([
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'message' => ['type' => 'string'],
|
||||
],
|
||||
'required' => ['message'],
|
||||
'description' => 'The result of the operation',
|
||||
], $schema);
|
||||
}
|
||||
|
||||
public function testGenerateOutputSchemaForArrayReturnType(): void
|
||||
{
|
||||
$method = new \ReflectionMethod(SchemaGeneratorFixture::class, 'noParamsWithSchema');
|
||||
$schema = $this->schemaGenerator->generateOutputSchema($method);
|
||||
$this->assertEquals([
|
||||
'type' => 'object',
|
||||
'additionalProperties' => true,
|
||||
], $schema);
|
||||
}
|
||||
|
||||
public function testGenerateOutputSchemaForComplexNestedSchema(): void
|
||||
{
|
||||
$method = new \ReflectionMethod(SchemaGeneratorFixture::class, 'complexNestedSchema');
|
||||
$schema = $this->schemaGenerator->generateOutputSchema($method);
|
||||
$this->assertEquals([
|
||||
'type' => 'object',
|
||||
'additionalProperties' => true,
|
||||
], $schema);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue