Skip to content

Commit 6e8e705

Browse files
committed
Fix to make Symfony Finder component optional
1 parent 7a5d5f5 commit 6e8e705

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
"psr/http-server-handler": "^1.0",
3333
"psr/http-server-middleware": "^1.0",
3434
"psr/log": "^1.0 || ^2.0 || ^3.0",
35-
"symfony/finder": "^5.4 || ^6.4 || ^7.3 || ^8.0",
3635
"symfony/uid": "^5.4 || ^6.4 || ^7.3 || ^8.0"
3736
},
37+
"suggest": {
38+
"symfony/finder": "Required for file-based discovery."
39+
},
3840
"require-dev": {
3941
"ext-openssl": "*",
4042
"composer/semver": "^3.0",
@@ -50,6 +52,7 @@
5052
"psr/simple-cache": "^2.0 || ^3.0",
5153
"symfony/cache": "^5.4 || ^6.4 || ^7.3 || ^8.0",
5254
"symfony/console": "^5.4 || ^6.4 || ^7.3 || ^8.0",
55+
"symfony/finder": "^5.4 || ^6.4 || ^7.3 || ^8.0",
5356
"symfony/http-client": "^5.4 || ^6.4 || ^7.3 || ^8.0",
5457
"symfony/process": "^5.4 || ^6.4 || ^7.3 || ^8.0"
5558
},

src/Capability/Discovery/Discoverer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Mcp\Capability\Registry\ResourceTemplateReference;
2525
use Mcp\Capability\Registry\ToolReference;
2626
use Mcp\Exception\ExceptionInterface;
27+
use Mcp\Exception\RuntimeException;
2728
use Mcp\Schema\Prompt;
2829
use Mcp\Schema\PromptArgument;
2930
use Mcp\Schema\Resource;
@@ -53,6 +54,10 @@ public function __construct(
5354
private ?DocBlockParser $docBlockParser = null,
5455
private ?SchemaGeneratorInterface $schemaGenerator = null,
5556
) {
57+
if (!class_exists(Finder::class)) {
58+
throw new RuntimeException('File-based discovery requires symfony/finder. Run: composer require symfony/finder');
59+
}
60+
5661
$this->docBlockParser = $docBlockParser ?? new DocBlockParser(logger: $this->logger);
5762
$this->schemaGenerator = $schemaGenerator ?? new SchemaGenerator($this->docBlockParser);
5863
}

0 commit comments

Comments
 (0)