Kick off the SDK based on Symfony's MCP SDK
This commit is contained in:
parent
0044ffb365
commit
ee0dffe369
7 changed files with 3924 additions and 0 deletions
29
src/Capability/Tool/CollectionInterface.php
Normal file
29
src/Capability/Tool/CollectionInterface.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Capability\Tool;
|
||||
|
||||
use Mcp\Exception\InvalidCursorException;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
interface CollectionInterface
|
||||
{
|
||||
/**
|
||||
* @param int $count the number of metadata items to return
|
||||
*
|
||||
* @return iterable<MetadataInterface>
|
||||
*
|
||||
* @throws InvalidCursorException if no item with $lastIdentifier was found
|
||||
*/
|
||||
public function getMetadata(int $count, ?string $lastIdentifier = null): iterable;
|
||||
}
|
||||
20
src/Capability/Tool/IdentifierInterface.php
Normal file
20
src/Capability/Tool/IdentifierInterface.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Capability\Tool;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
interface IdentifierInterface
|
||||
{
|
||||
public function getName(): string;
|
||||
}
|
||||
32
src/Capability/Tool/MetadataInterface.php
Normal file
32
src/Capability/Tool/MetadataInterface.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Capability\Tool;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
interface MetadataInterface extends IdentifierInterface
|
||||
{
|
||||
public function getDescription(): string;
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* type?: string,
|
||||
* required?: list<string>,
|
||||
* properties?: array<string, array{
|
||||
* type: string,
|
||||
* description?: string,
|
||||
* }>,
|
||||
* }
|
||||
*/
|
||||
public function getInputSchema(): array;
|
||||
}
|
||||
28
src/Capability/Tool/ToolCall.php
Normal file
28
src/Capability/Tool/ToolCall.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Capability\Tool;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
final class ToolCall
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $arguments
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $id,
|
||||
public readonly string $name,
|
||||
public readonly array $arguments = [],
|
||||
) {
|
||||
}
|
||||
}
|
||||
30
src/Capability/Tool/ToolCallResult.php
Normal file
30
src/Capability/Tool/ToolCallResult.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Capability\Tool;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
final class ToolCallResult
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $result,
|
||||
/**
|
||||
* @var "text"|"image"|"audio"|"resource"|non-empty-string
|
||||
*/
|
||||
public readonly string $type = 'text',
|
||||
public readonly string $mimeType = 'text/plan',
|
||||
public readonly bool $isError = false,
|
||||
public readonly ?string $uri = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
23
src/Capability/Tool/ToolCollectionInterface.php
Normal file
23
src/Capability/Tool/ToolCollectionInterface.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Capability\Tool;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
interface ToolCollectionInterface
|
||||
{
|
||||
/**
|
||||
* @return MetadataInterface[]
|
||||
*/
|
||||
public function getMetadata(): array;
|
||||
}
|
||||
27
src/Capability/Tool/ToolExecutorInterface.php
Normal file
27
src/Capability/Tool/ToolExecutorInterface.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Capability\Tool;
|
||||
|
||||
use Mcp\Exception\ToolExecutionException;
|
||||
use Mcp\Exception\ToolNotFoundException;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
interface ToolExecutorInterface
|
||||
{
|
||||
/**
|
||||
* @throws ToolExecutionException if the tool execution fails
|
||||
* @throws ToolNotFoundException if the tool is not found
|
||||
*/
|
||||
public function call(ToolCall $input): ToolCallResult;
|
||||
}
|
||||
Loading…
Reference in a new issue