From da16b7cd4d5721010eb102871ed2be3d80bdf243 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 29 May 2025 13:40:32 +0200 Subject: [PATCH] add readme and license headers --- .doctor-rst.yaml | 96 ++++++++++++++ .php-cs-fixer.dist.php | 51 +++++++- CONTRIBUTING.md | 26 ++++ README.md | 20 +++ src/mcp-sdk/README.md | 121 ++---------------- src/mcp-sdk/composer.json | 2 +- src/mcp-sdk/doc/index.rst | 32 +++++ src/mcp-sdk/examples/cli/index.php | 11 ++ src/mcp-sdk/examples/cli/src/Builder.php | 11 ++ .../examples/cli/src/ExamplePrompt.php | 13 +- .../examples/cli/src/ExampleResource.php | 11 ++ src/mcp-sdk/examples/cli/src/ExampleTool.php | 11 ++ .../Capability/Prompt/CollectionInterface.php | 11 ++ .../Capability/Prompt/IdentifierInterface.php | 11 ++ .../Capability/Prompt/MetadataInterface.php | 9 ++ .../src/Capability/Prompt/PromptGet.php | 9 ++ .../src/Capability/Prompt/PromptGetResult.php | 9 ++ .../Prompt/PromptGetResultMessages.php | 9 ++ .../Prompt/PromptGetterInterface.php | 11 ++ src/mcp-sdk/src/Capability/PromptChain.php | 11 ++ .../Resource/CollectionInterface.php | 11 ++ .../Resource/IdentifierInterface.php | 11 ++ .../Capability/Resource/MetadataInterface.php | 9 ++ .../src/Capability/Resource/ResourceRead.php | 9 ++ .../Resource/ResourceReadResult.php | 9 ++ .../Resource/ResourceReaderInterface.php | 11 ++ src/mcp-sdk/src/Capability/ResourceChain.php | 11 ++ .../Capability/Tool/CollectionInterface.php | 11 ++ .../Capability/Tool/IdentifierInterface.php | 11 ++ .../src/Capability/Tool/MetadataInterface.php | 9 ++ src/mcp-sdk/src/Capability/Tool/ToolCall.php | 9 ++ .../src/Capability/Tool/ToolCallResult.php | 9 ++ .../Tool/ToolCollectionInterface.php | 11 ++ .../Capability/Tool/ToolExecutorInterface.php | 11 ++ src/mcp-sdk/src/Capability/ToolChain.php | 11 ++ .../src/Exception/ExceptionInterface.php | 9 ++ .../Exception/NotFoundExceptionInterface.php | 9 ++ .../src/Exception/PromptGetException.php | 11 +- .../src/Exception/PromptNotFoundException.php | 11 +- .../Exception/ResourceNotFoundException.php | 11 +- .../src/Exception/ResourceReadException.php | 11 +- .../src/Exception/ToolExecutionException.php | 11 +- .../src/Exception/ToolNotFoundException.php | 11 +- src/mcp-sdk/src/Message/Error.php | 9 ++ src/mcp-sdk/src/Message/Factory.php | 11 +- src/mcp-sdk/src/Message/Notification.php | 11 +- src/mcp-sdk/src/Message/Request.php | 11 +- src/mcp-sdk/src/Message/Response.php | 9 ++ src/mcp-sdk/src/Server.php | 9 ++ src/mcp-sdk/src/Server/JsonRpcHandler.php | 19 ++- .../BaseNotificationHandler.php | 11 +- .../InitializedHandler.php | 9 ++ .../Server/NotificationHandlerInterface.php | 9 ++ .../RequestHandler/BaseRequestHandler.php | 9 ++ .../RequestHandler/InitializeHandler.php | 9 ++ .../src/Server/RequestHandler/PingHandler.php | 9 ++ .../RequestHandler/PromptGetHandler.php | 9 ++ .../RequestHandler/PromptListHandler.php | 9 ++ .../RequestHandler/ResourceListHandler.php | 9 ++ .../RequestHandler/ResourceReadHandler.php | 9 ++ .../Server/RequestHandler/ToolCallHandler.php | 9 ++ .../Server/RequestHandler/ToolListHandler.php | 9 ++ .../src/Server/RequestHandlerInterface.php | 9 ++ .../Transport/Sse/Store/CachePoolStore.php | 9 ++ .../Server/Transport/Sse/StoreInterface.php | 9 ++ .../Server/Transport/Sse/StreamTransport.php | 15 ++- .../Stdio/SymfonyConsoleTransport.php | 17 ++- src/mcp-sdk/src/Server/TransportInterface.php | 9 ++ src/mcp-sdk/tests/Message/ErrorTest.php | 9 ++ src/mcp-sdk/tests/Message/FactoryTest.php | 9 ++ src/mcp-sdk/tests/Message/ResponseTest.php | 9 ++ src/mcp-sdk/tests/ServerTest.php | 11 ++ 72 files changed, 881 insertions(+), 136 deletions(-) create mode 100644 .doctor-rst.yaml create mode 100644 CONTRIBUTING.md create mode 100644 README.md create mode 100644 src/mcp-sdk/doc/index.rst diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml new file mode 100644 index 00000000..b90f9eff --- /dev/null +++ b/.doctor-rst.yaml @@ -0,0 +1,96 @@ +rules: + american_english: ~ + argument_variable_must_match_type: ~ + avoid_repetetive_words: ~ +# be_kind_to_newcomers: ~ + blank_line_after_anchor: ~ +# blank_line_after_colon: ~ + blank_line_after_directive: ~ +# blank_line_after_filepath_in_code_block: ~ +# blank_line_after_filepath_in_php_code_block: ~ +# blank_line_after_filepath_in_twig_code_block: ~ +# blank_line_after_filepath_in_xml_code_block: ~ +# blank_line_after_filepath_in_yaml_code_block: ~ + blank_line_before_directive: ~ +# composer_dev_option_at_the_end: ~ + composer_dev_option_not_at_the_end: ~ + correct_code_block_directive_based_on_the_content: ~ + deprecated_directive_major_version: + major_version: 2 + deprecated_directive_min_version: + min_version: '2.0' + deprecated_directive_should_have_version: ~ + ensure_bash_prompt_before_composer_command: ~ + ensure_exactly_one_space_before_directive_type: ~ + ensure_exactly_one_space_between_link_definition_and_link: ~ + ensure_link_definition_contains_valid_url: ~ + ensure_order_of_code_blocks_in_configuration_block: ~ + extend_abstract_admin: ~ + extend_abstract_controller: ~ +# extend_controller: ~ + extension_xlf_instead_of_xliff: ~ +# filename_uses_dashes_only: ~ +# filename_uses_underscores_only: ~ + final_admin_classes: ~ + final_admin_extension_classes: ~ + forbidden_directives: + directives: + - '.. index::' + indention: ~ + kernel_instead_of_app_kernel: ~ +# line_length: ~ + lowercase_as_in_use_statements: ~ + max_blank_lines: + max: 2 + max_colons: ~ + no_admin_yaml: ~ + no_app_bundle: ~ + no_app_console: ~ +# no_bash_prompt: ~ + no_blank_line_after_filepath_in_code_block: ~ + no_blank_line_after_filepath_in_php_code_block: ~ + no_blank_line_after_filepath_in_twig_code_block: ~ + no_blank_line_after_filepath_in_xml_code_block: ~ + no_blank_line_after_filepath_in_yaml_code_block: ~ + no_brackets_in_method_directive: ~ + no_composer_phar: ~ + no_composer_req: ~ + no_config_yaml: ~ +# no_contraction: ~ + no_directive_after_shorthand: ~ + no_explicit_use_of_code_block_php: ~ + no_inheritdoc_in_code_examples: ~ + no_merge_conflict: ~ + no_namespace_after_use_statements: ~ + no_php_open_tag_in_code_block_php_directive: ~ +# no_php_prefix_before_bin_console: ~ +# no_php_prefix_before_composer: ~ +# no_space_before_self_xml_closing_tag: ~ + only_backslashes_in_namespace_in_php_code_block: ~ + only_backslashes_in_use_statements_in_php_code_block: ~ + ordered_use_statements: ~ +# php_open_tag_in_code_block_php_directive: ~ + php_prefix_before_bin_console: ~ + replace_code_block_types: ~ + replacement: ~ + short_array_syntax: ~ +# space_before_self_xml_closing_tag: ~ + space_between_label_and_link_in_doc: ~ + space_between_label_and_link_in_ref: ~ + string_replacement: ~ + title_underline_length_must_match_title_length: ~ + typo: ~ + unused_links: ~ + use_deprecated_directive_instead_of_versionadded: ~ + use_https_xsd_urls: ~ +# use_named_constructor_without_new_keyword_rule: ~ + valid_inline_highlighted_namespaces: ~ + valid_use_statements: ~ + versionadded_directive_major_version: + major_version: 2 + versionadded_directive_min_version: + min_version: '2.0' + versionadded_directive_should_have_version: ~ + yaml_instead_of_yml_suffix: ~ + yarn_dev_option_at_the_end: ~ +# yarn_dev_option_not_at_the_end: ~ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 67788bbf..84c9bb48 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,13 +1,54 @@ in('src') - ->exclude(['var', 'vendor']) -; +declare(strict_types=1); + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (!file_exists(__DIR__.'/src')) { + exit(0); +} + +$fileHeaderParts = [ + <<<'EOF' + This file is part of the Symfony package. + + (c) Fabien Potencier + + EOF, + <<<'EOF' + + For the full copyright and license information, please view the LICENSE + file that was distributed with this source code. + EOF, +]; return (new PhpCsFixer\Config()) + // @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7777 + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setRules([ + '@PHP71Migration' => true, + '@PHPUnit75Migration:risky' => true, '@Symfony' => true, + '@Symfony:risky' => true, + 'protected_to_private' => false, + 'declare_strict_types' => true, + 'header_comment' => [ + 'header' => implode('', $fileHeaderParts), + ], ]) - ->setFinder($finder) + ->setRiskyAllowed(true) + ->setFinder( + (new PhpCsFixer\Finder()) + ->in(__DIR__.'/src') + ->append([__FILE__]) + ->notPath('#/Fixtures/#') + ) + ->setCacheFile('.php-cs-fixer.cache') ; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..7902d9af --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,26 @@ +Contributing +------------ + +Symfony is an open source, community-driven project. + +If you'd like to contribute, please read the following documents: + +* [Reviewing issues/pull requests][0] +* [Reporting a Bug][1] +* [Submitting a Patch][2] +* [Symfony Core Team][3] +* [Security Issues][4] +* [Running Symfony Tests][5] +* [Our Backwards Compatibility Promise][6] +* [Coding Standards][7] +* [Conventions][8] + +[0]: https://symfony.com/doc/current/contributing/community/reviews.html +[1]: https://symfony.com/doc/current/contributing/code/bugs.html +[2]: https://symfony.com/doc/current/contributing/code/patches.html +[3]: https://symfony.com/doc/current/contributing/code/core_team.html +[4]: https://symfony.com/doc/current/contributing/code/security.html +[5]: https://symfony.com/doc/current/contributing/code/tests.html +[6]: https://symfony.com/doc/current/contributing/code/bc.html +[7]: https://symfony.com/doc/current/contributing/code/standards.html +[8]: https://symfony.com/doc/current/contributing/code/conventions.html diff --git a/README.md b/README.md new file mode 100644 index 00000000..09119044 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +

+ Symfony Logo +

+ +

+ Symfony AI +

+ +Symfony AI is a set of packages that integrate AI capabilities into PHP applications. + +## Sponsor + +Help Symfony by [sponsoring][2] its development! + +## Contributing + +Thank you for considering contributing to Symfony AI! You can find the [contribution guide here](CONTRIBUTING.md). + +[1]: https://symfony.com/backers +[2]: https://symfony.com/sponsor diff --git a/src/mcp-sdk/README.md b/src/mcp-sdk/README.md index 21905fd9..c7637bed 100644 --- a/src/mcp-sdk/README.md +++ b/src/mcp-sdk/README.md @@ -1,119 +1,26 @@ -# Model Context Protocol PHP SDK [WIP] +# Model Context Protocol PHP SDK Model Context Protocol SDK for Client and Server applications in PHP. -**Currently only support Tool Calls as Server via Server-Sent Events (SSE) and STDIO.** - -See [Demo App](https://github.com/php-llm/mcp-demo) for a working example and [MCP Bundle](https://github.com/php-llm/mcp-bundle) for Symfony integration. ## Installation ```bash -composer require php-llm/mcp-sdk +composer require symfony/mcp-sdk ``` -## Usage with Symfony +This is a low level SDK that implements the [Model Context Protocol](https://modelcontextprotocol.io/) +(MCP). The protocol is used by LLM model to build "plugins" and give them extra +context. Example the logged in users' latest order. -Server integration points for are tailored to Symfony Console and HttpFoundation (Laravel compatible). +**This repository is a READ-ONLY sub-tree split**. See +https://github.com/symfony/ai to create issues or submit pull requests. -### Console Command for STDIO Server +## Resources -```php -namespace App\Command; +- [Documentation](doc/index.rst) +- [Report issues](https://github.com/symfony/ai/issues) and + [send Pull Requests](https://github.com/symfony/ai/pulls) + in the [main Symfony AI repository](https://github.com/symfony/ai) -use PhpLlm\McpSdk\Server; -use PhpLlm\McpSdk\Server\Transport\Stdio\SymfonyConsoleTransport; -use Symfony\Component\Console\Attribute\AsCommand; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -#[AsCommand('mcp', 'Starts an MCP server')] -final class McpCommand extends Command -{ - public function __construct( - private readonly Server $server, - ) { - parent::__construct(); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->server->connect( - new SymfonyConsoleTransport($input, $output) - ); - - return Command::SUCCESS; - } -} -``` - -### Controller for Server-Sent Events Server - -```php -namespace App\Controller; - -use PhpLlm\McpSdk\Server; -use PhpLlm\McpSdk\Server\Transport\Sse\Store\CachePoolStore; -use PhpLlm\McpSdk\Server\Transport\Sse\StreamTransport; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpKernel\Attribute\AsController; -use Symfony\Component\Routing\Attribute\Route; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Uid\Uuid; - -#[AsController] -#[Route('/mcp', name: 'mcp_')] -final readonly class McpController -{ - public function __construct( - private Server $server, - private CachePoolStore $store, - private UrlGeneratorInterface $urlGenerator, - ) { - } - - #[Route('/sse', name: 'sse', methods: ['GET'])] - public function sse(): StreamedResponse - { - $id = Uuid::v4(); - $endpoint = $this->urlGenerator->generate('mcp_messages', ['id' => $id], UrlGeneratorInterface::ABSOLUTE_URL); - $transport = new StreamTransport($endpoint, $this->store, $id); - - return new StreamedResponse(fn() => $this->server->connect($transport), headers: [ - 'Content-Type' => 'text/event-stream', - 'Cache-Control' => 'no-cache', - 'X-Accel-Buffering' => 'no', - ]); - } - - #[Route('/messages/{id}', name: 'messages', methods: ['POST'])] - public function messages(Request $request, Uuid $id): Response - { - $this->store->push($id, $request->getContent()); - - return new Response(); - } -} -``` - -### Exposing Tools - -Under the hood the SDK uses [LLM Chain](https://github.com/php-llm/llm-chain)'s `ToolBox` to register, analyze and -execute tools. In combination with its [Symfony Bundle](https://github.com/php-llm/llm-chain-bundle) you can expose -tools with `#[AsTool]` attribute. - -```php -use PhpLlm\LlmChain\ToolBox\Attribute\AsTool; - -#[AsTool('company_name', 'Provides the name of your company')] -final class CompanyName -{ - public function __invoke(): string - { - return 'ACME Corp.' - } -} -``` -See [LLM Chain Documentation](https://github.com/php-llm/llm-chain?tab=readme-ov-file#tools) for more information. +[1]: https://symfony.com/backers +[3]: https://symfony.com/sponsor diff --git a/src/mcp-sdk/composer.json b/src/mcp-sdk/composer.json index 8bc29e69..f84ab438 100644 --- a/src/mcp-sdk/composer.json +++ b/src/mcp-sdk/composer.json @@ -1,5 +1,5 @@ { - "name": "php-llm/mcp-sdk", + "name": "symfony/mcp-sdk", "type": "library", "description": "Model Context Protocol SDK for Client and Server applications in PHP", "license": "MIT", diff --git a/src/mcp-sdk/doc/index.rst b/src/mcp-sdk/doc/index.rst new file mode 100644 index 00000000..532165e8 --- /dev/null +++ b/src/mcp-sdk/doc/index.rst @@ -0,0 +1,32 @@ +Model Context Protocol SDK +========================== + +Symfony AI MCP SDK is the low level library that enables communication between +a PHP application and an LLM model. + +Installation +------------ + +Install the bundle using Composer: + +.. code-block:: terminal + + $ composer require symfony/mcp-sdk + +Usage +----- + +The `Model Context Protocol`_ is built on top of JSON-RPC. There two types of +messages. A Notification and Request. The Notification is just a status update +that something has happened. There is never a response to a Notification. A Request +is a message that expects a response. There are 3 concepts that you may request. +These are:: + +1. **Resources**: File-like data that can be read by clients (like API responses or file contents) +1. **Tools**: Functions that can be called by the LLM (with user approval) +1. **Prompts**: Pre-written templates that help users accomplish specific tasks + +The SDK comes with NotificationHandlers and RequestHandlers which are expected +to be wired up in your application. + +.. _`Model Context Protocol`: https://modelcontextprotocol.io/ diff --git a/src/mcp-sdk/examples/cli/index.php b/src/mcp-sdk/examples/cli/index.php index bf7040da..d31a4845 100644 --- a/src/mcp-sdk/examples/cli/index.php +++ b/src/mcp-sdk/examples/cli/index.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + require __DIR__.'/vendor/autoload.php'; use Symfony\Component\Console as SymfonyConsole; diff --git a/src/mcp-sdk/examples/cli/src/Builder.php b/src/mcp-sdk/examples/cli/src/Builder.php index 40e5a9c6..eb91d370 100644 --- a/src/mcp-sdk/examples/cli/src/Builder.php +++ b/src/mcp-sdk/examples/cli/src/Builder.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace App; use PhpLlm\McpSdk\Capability\PromptChain; diff --git a/src/mcp-sdk/examples/cli/src/ExamplePrompt.php b/src/mcp-sdk/examples/cli/src/ExamplePrompt.php index bbe86c90..068aa106 100644 --- a/src/mcp-sdk/examples/cli/src/ExamplePrompt.php +++ b/src/mcp-sdk/examples/cli/src/ExamplePrompt.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace App; use PhpLlm\McpSdk\Capability\Prompt\MetadataInterface; @@ -18,7 +29,7 @@ class ExamplePrompt implements MetadataInterface, PromptGetterInterface $this->getDescription(), [new PromptGetResultMessages( 'user', - sprintf('Hello %s', $firstName ?? 'World') + \sprintf('Hello %s', $firstName ?? 'World') )] ); } diff --git a/src/mcp-sdk/examples/cli/src/ExampleResource.php b/src/mcp-sdk/examples/cli/src/ExampleResource.php index 9e6cdba7..e14b1797 100644 --- a/src/mcp-sdk/examples/cli/src/ExampleResource.php +++ b/src/mcp-sdk/examples/cli/src/ExampleResource.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace App; use PhpLlm\McpSdk\Capability\Resource\MetadataInterface; diff --git a/src/mcp-sdk/examples/cli/src/ExampleTool.php b/src/mcp-sdk/examples/cli/src/ExampleTool.php index 618acb91..672d23dc 100644 --- a/src/mcp-sdk/examples/cli/src/ExampleTool.php +++ b/src/mcp-sdk/examples/cli/src/ExampleTool.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace App; use PhpLlm\McpSdk\Capability\Tool\MetadataInterface; diff --git a/src/mcp-sdk/src/Capability/Prompt/CollectionInterface.php b/src/mcp-sdk/src/Capability/Prompt/CollectionInterface.php index 377585c5..e466c055 100644 --- a/src/mcp-sdk/src/Capability/Prompt/CollectionInterface.php +++ b/src/mcp-sdk/src/Capability/Prompt/CollectionInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Prompt; interface CollectionInterface diff --git a/src/mcp-sdk/src/Capability/Prompt/IdentifierInterface.php b/src/mcp-sdk/src/Capability/Prompt/IdentifierInterface.php index 8096c178..58899912 100644 --- a/src/mcp-sdk/src/Capability/Prompt/IdentifierInterface.php +++ b/src/mcp-sdk/src/Capability/Prompt/IdentifierInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Prompt; interface IdentifierInterface diff --git a/src/mcp-sdk/src/Capability/Prompt/MetadataInterface.php b/src/mcp-sdk/src/Capability/Prompt/MetadataInterface.php index 6dc34040..4916554a 100644 --- a/src/mcp-sdk/src/Capability/Prompt/MetadataInterface.php +++ b/src/mcp-sdk/src/Capability/Prompt/MetadataInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Prompt; interface MetadataInterface extends IdentifierInterface diff --git a/src/mcp-sdk/src/Capability/Prompt/PromptGet.php b/src/mcp-sdk/src/Capability/Prompt/PromptGet.php index 22c64f42..f87909dd 100644 --- a/src/mcp-sdk/src/Capability/Prompt/PromptGet.php +++ b/src/mcp-sdk/src/Capability/Prompt/PromptGet.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Prompt; final readonly class PromptGet diff --git a/src/mcp-sdk/src/Capability/Prompt/PromptGetResult.php b/src/mcp-sdk/src/Capability/Prompt/PromptGetResult.php index 5362680d..f1403355 100644 --- a/src/mcp-sdk/src/Capability/Prompt/PromptGetResult.php +++ b/src/mcp-sdk/src/Capability/Prompt/PromptGetResult.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Prompt; final readonly class PromptGetResult diff --git a/src/mcp-sdk/src/Capability/Prompt/PromptGetResultMessages.php b/src/mcp-sdk/src/Capability/Prompt/PromptGetResultMessages.php index 48f85310..f81a38eb 100644 --- a/src/mcp-sdk/src/Capability/Prompt/PromptGetResultMessages.php +++ b/src/mcp-sdk/src/Capability/Prompt/PromptGetResultMessages.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Prompt; final readonly class PromptGetResultMessages diff --git a/src/mcp-sdk/src/Capability/Prompt/PromptGetterInterface.php b/src/mcp-sdk/src/Capability/Prompt/PromptGetterInterface.php index 75f2b86e..21abb797 100644 --- a/src/mcp-sdk/src/Capability/Prompt/PromptGetterInterface.php +++ b/src/mcp-sdk/src/Capability/Prompt/PromptGetterInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Prompt; use PhpLlm\McpSdk\Exception\PromptGetException; diff --git a/src/mcp-sdk/src/Capability/PromptChain.php b/src/mcp-sdk/src/Capability/PromptChain.php index 49f8e1d5..48513289 100644 --- a/src/mcp-sdk/src/Capability/PromptChain.php +++ b/src/mcp-sdk/src/Capability/PromptChain.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability; use PhpLlm\McpSdk\Capability\Prompt\CollectionInterface; diff --git a/src/mcp-sdk/src/Capability/Resource/CollectionInterface.php b/src/mcp-sdk/src/Capability/Resource/CollectionInterface.php index d4a4fbed..c36d5fab 100644 --- a/src/mcp-sdk/src/Capability/Resource/CollectionInterface.php +++ b/src/mcp-sdk/src/Capability/Resource/CollectionInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Resource; interface CollectionInterface diff --git a/src/mcp-sdk/src/Capability/Resource/IdentifierInterface.php b/src/mcp-sdk/src/Capability/Resource/IdentifierInterface.php index e3ee06e1..d6ccbaea 100644 --- a/src/mcp-sdk/src/Capability/Resource/IdentifierInterface.php +++ b/src/mcp-sdk/src/Capability/Resource/IdentifierInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Resource; interface IdentifierInterface diff --git a/src/mcp-sdk/src/Capability/Resource/MetadataInterface.php b/src/mcp-sdk/src/Capability/Resource/MetadataInterface.php index 253ce8c9..e491d8e8 100644 --- a/src/mcp-sdk/src/Capability/Resource/MetadataInterface.php +++ b/src/mcp-sdk/src/Capability/Resource/MetadataInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Resource; interface MetadataInterface extends IdentifierInterface diff --git a/src/mcp-sdk/src/Capability/Resource/ResourceRead.php b/src/mcp-sdk/src/Capability/Resource/ResourceRead.php index 6e2ed67e..e7a6d9ca 100644 --- a/src/mcp-sdk/src/Capability/Resource/ResourceRead.php +++ b/src/mcp-sdk/src/Capability/Resource/ResourceRead.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Resource; final readonly class ResourceRead diff --git a/src/mcp-sdk/src/Capability/Resource/ResourceReadResult.php b/src/mcp-sdk/src/Capability/Resource/ResourceReadResult.php index 4887ed0a..411f155e 100644 --- a/src/mcp-sdk/src/Capability/Resource/ResourceReadResult.php +++ b/src/mcp-sdk/src/Capability/Resource/ResourceReadResult.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Resource; final readonly class ResourceReadResult diff --git a/src/mcp-sdk/src/Capability/Resource/ResourceReaderInterface.php b/src/mcp-sdk/src/Capability/Resource/ResourceReaderInterface.php index 3102ac88..9c74cd6f 100644 --- a/src/mcp-sdk/src/Capability/Resource/ResourceReaderInterface.php +++ b/src/mcp-sdk/src/Capability/Resource/ResourceReaderInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Resource; use PhpLlm\McpSdk\Exception\ResourceNotFoundException; diff --git a/src/mcp-sdk/src/Capability/ResourceChain.php b/src/mcp-sdk/src/Capability/ResourceChain.php index e16d74cb..77855fa1 100644 --- a/src/mcp-sdk/src/Capability/ResourceChain.php +++ b/src/mcp-sdk/src/Capability/ResourceChain.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability; use PhpLlm\McpSdk\Capability\Resource\CollectionInterface; diff --git a/src/mcp-sdk/src/Capability/Tool/CollectionInterface.php b/src/mcp-sdk/src/Capability/Tool/CollectionInterface.php index 2140fbf2..19dcef9c 100644 --- a/src/mcp-sdk/src/Capability/Tool/CollectionInterface.php +++ b/src/mcp-sdk/src/Capability/Tool/CollectionInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Tool; interface CollectionInterface diff --git a/src/mcp-sdk/src/Capability/Tool/IdentifierInterface.php b/src/mcp-sdk/src/Capability/Tool/IdentifierInterface.php index 7dd5bb2b..987ca1f8 100644 --- a/src/mcp-sdk/src/Capability/Tool/IdentifierInterface.php +++ b/src/mcp-sdk/src/Capability/Tool/IdentifierInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Tool; interface IdentifierInterface diff --git a/src/mcp-sdk/src/Capability/Tool/MetadataInterface.php b/src/mcp-sdk/src/Capability/Tool/MetadataInterface.php index 24d870d1..e6fb92dd 100644 --- a/src/mcp-sdk/src/Capability/Tool/MetadataInterface.php +++ b/src/mcp-sdk/src/Capability/Tool/MetadataInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Tool; interface MetadataInterface extends IdentifierInterface diff --git a/src/mcp-sdk/src/Capability/Tool/ToolCall.php b/src/mcp-sdk/src/Capability/Tool/ToolCall.php index d438dfc7..3b211078 100644 --- a/src/mcp-sdk/src/Capability/Tool/ToolCall.php +++ b/src/mcp-sdk/src/Capability/Tool/ToolCall.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Tool; final readonly class ToolCall diff --git a/src/mcp-sdk/src/Capability/Tool/ToolCallResult.php b/src/mcp-sdk/src/Capability/Tool/ToolCallResult.php index b4b49513..2184ed81 100644 --- a/src/mcp-sdk/src/Capability/Tool/ToolCallResult.php +++ b/src/mcp-sdk/src/Capability/Tool/ToolCallResult.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Tool; final readonly class ToolCallResult diff --git a/src/mcp-sdk/src/Capability/Tool/ToolCollectionInterface.php b/src/mcp-sdk/src/Capability/Tool/ToolCollectionInterface.php index ffb378b4..19a8a591 100644 --- a/src/mcp-sdk/src/Capability/Tool/ToolCollectionInterface.php +++ b/src/mcp-sdk/src/Capability/Tool/ToolCollectionInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Tool; interface ToolCollectionInterface diff --git a/src/mcp-sdk/src/Capability/Tool/ToolExecutorInterface.php b/src/mcp-sdk/src/Capability/Tool/ToolExecutorInterface.php index a80c2015..ba3c3af3 100644 --- a/src/mcp-sdk/src/Capability/Tool/ToolExecutorInterface.php +++ b/src/mcp-sdk/src/Capability/Tool/ToolExecutorInterface.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability\Tool; use PhpLlm\McpSdk\Exception\ToolExecutionException; diff --git a/src/mcp-sdk/src/Capability/ToolChain.php b/src/mcp-sdk/src/Capability/ToolChain.php index 6d3eb9ee..2bd1310f 100644 --- a/src/mcp-sdk/src/Capability/ToolChain.php +++ b/src/mcp-sdk/src/Capability/ToolChain.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Capability; use PhpLlm\McpSdk\Capability\Tool\CollectionInterface; diff --git a/src/mcp-sdk/src/Exception/ExceptionInterface.php b/src/mcp-sdk/src/Exception/ExceptionInterface.php index 14b84f4a..52117971 100644 --- a/src/mcp-sdk/src/Exception/ExceptionInterface.php +++ b/src/mcp-sdk/src/Exception/ExceptionInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; interface ExceptionInterface diff --git a/src/mcp-sdk/src/Exception/NotFoundExceptionInterface.php b/src/mcp-sdk/src/Exception/NotFoundExceptionInterface.php index dd0294ea..c3f9b69e 100644 --- a/src/mcp-sdk/src/Exception/NotFoundExceptionInterface.php +++ b/src/mcp-sdk/src/Exception/NotFoundExceptionInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; interface NotFoundExceptionInterface extends ExceptionInterface diff --git a/src/mcp-sdk/src/Exception/PromptGetException.php b/src/mcp-sdk/src/Exception/PromptGetException.php index 0e3f6091..b3242f86 100644 --- a/src/mcp-sdk/src/Exception/PromptGetException.php +++ b/src/mcp-sdk/src/Exception/PromptGetException.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; use PhpLlm\McpSdk\Capability\Prompt\PromptGet; @@ -12,6 +21,6 @@ final class PromptGetException extends \RuntimeException implements ExceptionInt public readonly PromptGet $promptGet, ?\Throwable $previous = null, ) { - parent::__construct(sprintf('Handling prompt "%s" failed with error: %s', $promptGet->name, $previous->getMessage()), previous: $previous); + parent::__construct(\sprintf('Handling prompt "%s" failed with error: %s', $promptGet->name, $previous->getMessage()), previous: $previous); } } diff --git a/src/mcp-sdk/src/Exception/PromptNotFoundException.php b/src/mcp-sdk/src/Exception/PromptNotFoundException.php index fb163b3c..b601029e 100644 --- a/src/mcp-sdk/src/Exception/PromptNotFoundException.php +++ b/src/mcp-sdk/src/Exception/PromptNotFoundException.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; use PhpLlm\McpSdk\Capability\Prompt\PromptGet; @@ -11,6 +20,6 @@ final class PromptNotFoundException extends \RuntimeException implements NotFoun public function __construct( public readonly PromptGet $promptGet, ) { - parent::__construct(sprintf('Resource not found for uri: "%s"', $promptGet->name)); + parent::__construct(\sprintf('Resource not found for uri: "%s"', $promptGet->name)); } } diff --git a/src/mcp-sdk/src/Exception/ResourceNotFoundException.php b/src/mcp-sdk/src/Exception/ResourceNotFoundException.php index 6cc1cd7b..ad042921 100644 --- a/src/mcp-sdk/src/Exception/ResourceNotFoundException.php +++ b/src/mcp-sdk/src/Exception/ResourceNotFoundException.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; use PhpLlm\McpSdk\Capability\Resource\ResourceRead; @@ -11,6 +20,6 @@ final class ResourceNotFoundException extends \RuntimeException implements NotFo public function __construct( public readonly ResourceRead $readRequest, ) { - parent::__construct(sprintf('Resource not found for uri: "%s"', $readRequest->uri)); + parent::__construct(\sprintf('Resource not found for uri: "%s"', $readRequest->uri)); } } diff --git a/src/mcp-sdk/src/Exception/ResourceReadException.php b/src/mcp-sdk/src/Exception/ResourceReadException.php index 669d60a8..d986b223 100644 --- a/src/mcp-sdk/src/Exception/ResourceReadException.php +++ b/src/mcp-sdk/src/Exception/ResourceReadException.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; use PhpLlm\McpSdk\Capability\Resource\ResourceRead; @@ -12,6 +21,6 @@ final class ResourceReadException extends \RuntimeException implements Exception public readonly ResourceRead $readRequest, ?\Throwable $previous = null, ) { - parent::__construct(sprintf('Reading resource "%s" failed with error: %s', $readRequest->uri, $previous?->getMessage() ?? ''), previous: $previous); + parent::__construct(\sprintf('Reading resource "%s" failed with error: %s', $readRequest->uri, $previous?->getMessage() ?? ''), previous: $previous); } } diff --git a/src/mcp-sdk/src/Exception/ToolExecutionException.php b/src/mcp-sdk/src/Exception/ToolExecutionException.php index 04c7efac..70d65d19 100644 --- a/src/mcp-sdk/src/Exception/ToolExecutionException.php +++ b/src/mcp-sdk/src/Exception/ToolExecutionException.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; use PhpLlm\McpSdk\Capability\Tool\ToolCall; @@ -12,6 +21,6 @@ final class ToolExecutionException extends \RuntimeException implements Exceptio public readonly ToolCall $toolCall, ?\Throwable $previous = null, ) { - parent::__construct(sprintf('Execution of tool "%s" failed with error: %s', $toolCall->name, $previous?->getMessage() ?? ''), previous: $previous); + parent::__construct(\sprintf('Execution of tool "%s" failed with error: %s', $toolCall->name, $previous?->getMessage() ?? ''), previous: $previous); } } diff --git a/src/mcp-sdk/src/Exception/ToolNotFoundException.php b/src/mcp-sdk/src/Exception/ToolNotFoundException.php index e8118cf5..0066cffc 100644 --- a/src/mcp-sdk/src/Exception/ToolNotFoundException.php +++ b/src/mcp-sdk/src/Exception/ToolNotFoundException.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Exception; use PhpLlm\McpSdk\Capability\Tool\ToolCall; @@ -11,6 +20,6 @@ final class ToolNotFoundException extends \RuntimeException implements NotFoundE public function __construct( public readonly ToolCall $toolCall, ) { - parent::__construct(sprintf('Tool not found for call: "%s"', $toolCall->name)); + parent::__construct(\sprintf('Tool not found for call: "%s"', $toolCall->name)); } } diff --git a/src/mcp-sdk/src/Message/Error.php b/src/mcp-sdk/src/Message/Error.php index 294ecd5c..e07ab20c 100644 --- a/src/mcp-sdk/src/Message/Error.php +++ b/src/mcp-sdk/src/Message/Error.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Message; final readonly class Error implements \JsonSerializable diff --git a/src/mcp-sdk/src/Message/Factory.php b/src/mcp-sdk/src/Message/Factory.php index baf683e4..d2f73892 100644 --- a/src/mcp-sdk/src/Message/Factory.php +++ b/src/mcp-sdk/src/Message/Factory.php @@ -2,13 +2,22 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Message; final class Factory { public function create(string $json): Request|Notification { - $data = json_decode($json, true, flags: JSON_THROW_ON_ERROR); + $data = json_decode($json, true, flags: \JSON_THROW_ON_ERROR); if (!isset($data['method'])) { throw new \InvalidArgumentException('Invalid JSON-RPC request, missing method'); diff --git a/src/mcp-sdk/src/Message/Notification.php b/src/mcp-sdk/src/Message/Notification.php index 74f9c3d5..a32f497c 100644 --- a/src/mcp-sdk/src/Message/Notification.php +++ b/src/mcp-sdk/src/Message/Notification.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Message; final readonly class Notification implements \JsonSerializable, \Stringable @@ -40,6 +49,6 @@ final readonly class Notification implements \JsonSerializable, \Stringable public function __toString(): string { - return sprintf('%s', $this->method); + return \sprintf('%s', $this->method); } } diff --git a/src/mcp-sdk/src/Message/Request.php b/src/mcp-sdk/src/Message/Request.php index 97bd1399..95ced59d 100644 --- a/src/mcp-sdk/src/Message/Request.php +++ b/src/mcp-sdk/src/Message/Request.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Message; final class Request implements \JsonSerializable, \Stringable @@ -43,6 +52,6 @@ final class Request implements \JsonSerializable, \Stringable public function __toString(): string { - return sprintf('%s: %s', $this->id, $this->method); + return \sprintf('%s: %s', $this->id, $this->method); } } diff --git a/src/mcp-sdk/src/Message/Response.php b/src/mcp-sdk/src/Message/Response.php index caccb487..c0361d25 100644 --- a/src/mcp-sdk/src/Message/Response.php +++ b/src/mcp-sdk/src/Message/Response.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Message; final readonly class Response implements \JsonSerializable diff --git a/src/mcp-sdk/src/Server.php b/src/mcp-sdk/src/Server.php index d6eb39f2..56653408 100644 --- a/src/mcp-sdk/src/Server.php +++ b/src/mcp-sdk/src/Server.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk; use PhpLlm\McpSdk\Server\JsonRpcHandler; diff --git a/src/mcp-sdk/src/Server/JsonRpcHandler.php b/src/mcp-sdk/src/Server/JsonRpcHandler.php index 82568876..c0205ed5 100644 --- a/src/mcp-sdk/src/Server/JsonRpcHandler.php +++ b/src/mcp-sdk/src/Server/JsonRpcHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server; use PhpLlm\McpSdk\Message\Error; @@ -68,7 +77,7 @@ readonly class JsonRpcHandler } catch (\DomainException) { return null; } catch (\InvalidArgumentException $e) { - $this->logger->warning(sprintf('Failed to create response: %s', $e->getMessage()), ['exception' => $e]); + $this->logger->warning(\sprintf('Failed to create response: %s', $e->getMessage()), ['exception' => $e]); return $this->encodeResponse(Error::methodNotFound($message->id ?? 0, $e->getMessage())); } @@ -85,10 +94,10 @@ readonly class JsonRpcHandler $this->logger->info('Encoding response', ['response' => $response]); if ($response instanceof Response && [] === $response->result) { - return json_encode($response, JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT); + return json_encode($response, \JSON_THROW_ON_ERROR | \JSON_FORCE_OBJECT); } - return json_encode($response, JSON_THROW_ON_ERROR); + return json_encode($response, \JSON_THROW_ON_ERROR); } private function handleNotification(Notification $notification): null @@ -99,7 +108,7 @@ readonly class JsonRpcHandler } } - $this->logger->warning(sprintf('No handler found for "%s".', $notification->method), ['notification' => $notification]); + $this->logger->warning(\sprintf('No handler found for "%s".', $notification->method), ['notification' => $notification]); return null; } @@ -112,6 +121,6 @@ readonly class JsonRpcHandler } } - throw new \InvalidArgumentException(sprintf('No handler found for method "%s".', $request->method)); + throw new \InvalidArgumentException(\sprintf('No handler found for method "%s".', $request->method)); } } diff --git a/src/mcp-sdk/src/Server/NotificationHandler/BaseNotificationHandler.php b/src/mcp-sdk/src/Server/NotificationHandler/BaseNotificationHandler.php index 96d09cc0..c1bd4b03 100644 --- a/src/mcp-sdk/src/Server/NotificationHandler/BaseNotificationHandler.php +++ b/src/mcp-sdk/src/Server/NotificationHandler/BaseNotificationHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\NotificationHandler; use PhpLlm\McpSdk\Message\Notification; @@ -11,7 +20,7 @@ abstract class BaseNotificationHandler implements NotificationHandlerInterface { public function supports(Notification $message): bool { - return $message->method === sprintf('notifications/%s', $this->supportedNotification()); + return $message->method === \sprintf('notifications/%s', $this->supportedNotification()); } abstract protected function supportedNotification(): string; diff --git a/src/mcp-sdk/src/Server/NotificationHandler/InitializedHandler.php b/src/mcp-sdk/src/Server/NotificationHandler/InitializedHandler.php index afa5da18..ec214da1 100644 --- a/src/mcp-sdk/src/Server/NotificationHandler/InitializedHandler.php +++ b/src/mcp-sdk/src/Server/NotificationHandler/InitializedHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\NotificationHandler; use PhpLlm\McpSdk\Message\Notification; diff --git a/src/mcp-sdk/src/Server/NotificationHandlerInterface.php b/src/mcp-sdk/src/Server/NotificationHandlerInterface.php index d2d71d3e..110c3c9c 100644 --- a/src/mcp-sdk/src/Server/NotificationHandlerInterface.php +++ b/src/mcp-sdk/src/Server/NotificationHandlerInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server; use PhpLlm\McpSdk\Message\Notification; diff --git a/src/mcp-sdk/src/Server/RequestHandler/BaseRequestHandler.php b/src/mcp-sdk/src/Server/RequestHandler/BaseRequestHandler.php index d7aad40f..6c2ef33a 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/BaseRequestHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/BaseRequestHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Message\Request; diff --git a/src/mcp-sdk/src/Server/RequestHandler/InitializeHandler.php b/src/mcp-sdk/src/Server/RequestHandler/InitializeHandler.php index 4740d6dc..a90ab0e7 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/InitializeHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/InitializeHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Message\Request; diff --git a/src/mcp-sdk/src/Server/RequestHandler/PingHandler.php b/src/mcp-sdk/src/Server/RequestHandler/PingHandler.php index e2987403..ccad4b7d 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/PingHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/PingHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Message\Request; diff --git a/src/mcp-sdk/src/Server/RequestHandler/PromptGetHandler.php b/src/mcp-sdk/src/Server/RequestHandler/PromptGetHandler.php index a956e25b..e3f86b54 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/PromptGetHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/PromptGetHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Capability\Prompt\PromptGet; diff --git a/src/mcp-sdk/src/Server/RequestHandler/PromptListHandler.php b/src/mcp-sdk/src/Server/RequestHandler/PromptListHandler.php index 86799a53..a43bca10 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/PromptListHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/PromptListHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Capability\Prompt\CollectionInterface; diff --git a/src/mcp-sdk/src/Server/RequestHandler/ResourceListHandler.php b/src/mcp-sdk/src/Server/RequestHandler/ResourceListHandler.php index dd8aed06..3f8a303f 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/ResourceListHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/ResourceListHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Capability\Resource\CollectionInterface; diff --git a/src/mcp-sdk/src/Server/RequestHandler/ResourceReadHandler.php b/src/mcp-sdk/src/Server/RequestHandler/ResourceReadHandler.php index b02740dd..d66d8712 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/ResourceReadHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/ResourceReadHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Capability\Resource\ResourceRead; diff --git a/src/mcp-sdk/src/Server/RequestHandler/ToolCallHandler.php b/src/mcp-sdk/src/Server/RequestHandler/ToolCallHandler.php index 4cab6e10..58e3655a 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/ToolCallHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/ToolCallHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Capability\Tool\ToolCall; diff --git a/src/mcp-sdk/src/Server/RequestHandler/ToolListHandler.php b/src/mcp-sdk/src/Server/RequestHandler/ToolListHandler.php index fd4f717e..7ce8d2e9 100644 --- a/src/mcp-sdk/src/Server/RequestHandler/ToolListHandler.php +++ b/src/mcp-sdk/src/Server/RequestHandler/ToolListHandler.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\RequestHandler; use PhpLlm\McpSdk\Capability\Tool\CollectionInterface; diff --git a/src/mcp-sdk/src/Server/RequestHandlerInterface.php b/src/mcp-sdk/src/Server/RequestHandlerInterface.php index 80fe7833..4cb3c51c 100644 --- a/src/mcp-sdk/src/Server/RequestHandlerInterface.php +++ b/src/mcp-sdk/src/Server/RequestHandlerInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server; use PhpLlm\McpSdk\Message\Error; diff --git a/src/mcp-sdk/src/Server/Transport/Sse/Store/CachePoolStore.php b/src/mcp-sdk/src/Server/Transport/Sse/Store/CachePoolStore.php index d7683050..c9000e6c 100644 --- a/src/mcp-sdk/src/Server/Transport/Sse/Store/CachePoolStore.php +++ b/src/mcp-sdk/src/Server/Transport/Sse/Store/CachePoolStore.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\Transport\Sse\Store; use PhpLlm\McpSdk\Server\Transport\Sse\StoreInterface; diff --git a/src/mcp-sdk/src/Server/Transport/Sse/StoreInterface.php b/src/mcp-sdk/src/Server/Transport/Sse/StoreInterface.php index f6517e06..98d30f7c 100644 --- a/src/mcp-sdk/src/Server/Transport/Sse/StoreInterface.php +++ b/src/mcp-sdk/src/Server/Transport/Sse/StoreInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\Transport\Sse; use Symfony\Component\Uid\Uuid; diff --git a/src/mcp-sdk/src/Server/Transport/Sse/StreamTransport.php b/src/mcp-sdk/src/Server/Transport/Sse/StreamTransport.php index 7b6d7999..8259f788 100644 --- a/src/mcp-sdk/src/Server/Transport/Sse/StreamTransport.php +++ b/src/mcp-sdk/src/Server/Transport/Sse/StreamTransport.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\Transport\Sse; use PhpLlm\McpSdk\Server\TransportInterface; @@ -44,9 +53,9 @@ final readonly class StreamTransport implements TransportInterface private function flushEvent(string $event, string $data): void { - echo sprintf('event: %s', $event).PHP_EOL; - echo sprintf('data: %s', $data).PHP_EOL; - echo PHP_EOL; + echo \sprintf('event: %s', $event).\PHP_EOL; + echo \sprintf('data: %s', $data).\PHP_EOL; + echo \PHP_EOL; if (false !== ob_get_length()) { ob_flush(); } diff --git a/src/mcp-sdk/src/Server/Transport/Stdio/SymfonyConsoleTransport.php b/src/mcp-sdk/src/Server/Transport/Stdio/SymfonyConsoleTransport.php index 778b2a84..00419bdc 100644 --- a/src/mcp-sdk/src/Server/Transport/Stdio/SymfonyConsoleTransport.php +++ b/src/mcp-sdk/src/Server/Transport/Stdio/SymfonyConsoleTransport.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server\Transport\Stdio; use PhpLlm\McpSdk\Server\TransportInterface; @@ -33,14 +42,14 @@ final class SymfonyConsoleTransport implements TransportInterface public function receive(): \Generator { - $stream = $this->input instanceof StreamableInputInterface ? $this->input->getStream() ?? STDIN : STDIN; + $stream = $this->input instanceof StreamableInputInterface ? $this->input->getStream() ?? \STDIN : \STDIN; $line = fgets($stream); if (false === $line) { return; } - $this->buffer .= STDIN === $stream ? rtrim($line).PHP_EOL : $line; - if (str_contains($this->buffer, PHP_EOL)) { - $lines = explode(PHP_EOL, $this->buffer); + $this->buffer .= \STDIN === $stream ? rtrim($line).\PHP_EOL : $line; + if (str_contains($this->buffer, \PHP_EOL)) { + $lines = explode(\PHP_EOL, $this->buffer); $this->buffer = array_pop($lines); yield from $lines; diff --git a/src/mcp-sdk/src/Server/TransportInterface.php b/src/mcp-sdk/src/Server/TransportInterface.php index 6dd8b867..c416a924 100644 --- a/src/mcp-sdk/src/Server/TransportInterface.php +++ b/src/mcp-sdk/src/Server/TransportInterface.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Server; interface TransportInterface diff --git a/src/mcp-sdk/tests/Message/ErrorTest.php b/src/mcp-sdk/tests/Message/ErrorTest.php index 23745b53..c142f1e0 100644 --- a/src/mcp-sdk/tests/Message/ErrorTest.php +++ b/src/mcp-sdk/tests/Message/ErrorTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Tests\Message; use PhpLlm\McpSdk\Message\Error; diff --git a/src/mcp-sdk/tests/Message/FactoryTest.php b/src/mcp-sdk/tests/Message/FactoryTest.php index 8a7c632e..d5137058 100644 --- a/src/mcp-sdk/tests/Message/FactoryTest.php +++ b/src/mcp-sdk/tests/Message/FactoryTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Tests\Message; use PhpLlm\McpSdk\Message\Factory; diff --git a/src/mcp-sdk/tests/Message/ResponseTest.php b/src/mcp-sdk/tests/Message/ResponseTest.php index b35e2b17..326411e2 100644 --- a/src/mcp-sdk/tests/Message/ResponseTest.php +++ b/src/mcp-sdk/tests/Message/ResponseTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Tests\Message; use PhpLlm\McpSdk\Message\Response; diff --git a/src/mcp-sdk/tests/ServerTest.php b/src/mcp-sdk/tests/ServerTest.php index d211410e..a35fd1ca 100644 --- a/src/mcp-sdk/tests/ServerTest.php +++ b/src/mcp-sdk/tests/ServerTest.php @@ -1,5 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace PhpLlm\McpSdk\Tests; use PhpLlm\McpSdk\Server;