Fix to make Symfony Finder component optional (#267)
This commit is contained in:
parent
85fddf5f0f
commit
ea38ef7b62
4 changed files with 17 additions and 3 deletions
|
|
@ -9,6 +9,7 @@ All notable changes to `mcp/sdk` will be documented in this file.
|
|||
* Add client component for building MCP clients
|
||||
* Add `Builder::setReferenceHandler()` to allow custom `ReferenceHandlerInterface` implementations (e.g. authorization decorators)
|
||||
* Add elicitation enum schema types per SEP-1330: `TitledEnumSchemaDefinition`, `MultiSelectEnumSchemaDefinition`, `TitledMultiSelectEnumSchemaDefinition`
|
||||
* [BC break] Make Symfony Finder component optional. Users would need to install `symfony/finder` now themselves
|
||||
|
||||
0.4.0
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -32,9 +32,11 @@
|
|||
"psr/http-server-handler": "^1.0",
|
||||
"psr/http-server-middleware": "^1.0",
|
||||
"psr/log": "^1.0 || ^2.0 || ^3.0",
|
||||
"symfony/finder": "^5.4 || ^6.4 || ^7.3 || ^8.0",
|
||||
"symfony/uid": "^5.4 || ^6.4 || ^7.3 || ^8.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/finder": "Required for file-based discovery."
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-openssl": "*",
|
||||
"composer/semver": "^3.0",
|
||||
|
|
@ -50,6 +52,7 @@
|
|||
"psr/simple-cache": "^2.0 || ^3.0",
|
||||
"symfony/cache": "^5.4 || ^6.4 || ^7.3 || ^8.0",
|
||||
"symfony/console": "^5.4 || ^6.4 || ^7.3 || ^8.0",
|
||||
"symfony/finder": "^5.4 || ^6.4 || ^7.3 || ^8.0",
|
||||
"symfony/http-client": "^5.4 || ^6.4 || ^7.3 || ^8.0",
|
||||
"symfony/process": "^5.4 || ^6.4 || ^7.3 || ^8.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use Mcp\Capability\Registry\ResourceReference;
|
|||
use Mcp\Capability\Registry\ResourceTemplateReference;
|
||||
use Mcp\Capability\Registry\ToolReference;
|
||||
use Mcp\Exception\ExceptionInterface;
|
||||
use Mcp\Exception\RuntimeException;
|
||||
use Mcp\Schema\Prompt;
|
||||
use Mcp\Schema\PromptArgument;
|
||||
use Mcp\Schema\Resource;
|
||||
|
|
@ -53,6 +54,10 @@ final class Discoverer implements DiscovererInterface
|
|||
private ?DocBlockParser $docBlockParser = null,
|
||||
private ?SchemaGeneratorInterface $schemaGenerator = null,
|
||||
) {
|
||||
if (!class_exists(Finder::class)) {
|
||||
throw new RuntimeException('File-based discovery requires symfony/finder. Run: composer require symfony/finder');
|
||||
}
|
||||
|
||||
$this->docBlockParser = $docBlockParser ?? new DocBlockParser(logger: $this->logger);
|
||||
$this->schemaGenerator = $schemaGenerator ?? new SchemaGenerator($this->docBlockParser);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ use Psr\EventDispatcher\EventDispatcherInterface;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
/**
|
||||
* @phpstan-import-type Handler from ElementReference
|
||||
|
|
@ -523,8 +524,12 @@ final class Builder
|
|||
);
|
||||
|
||||
if (null !== $this->discoveryBasePath) {
|
||||
$discoverer = $this->discoverer ?? $this->createDiscoverer($logger);
|
||||
$loaders[] = new DiscoveryLoader($this->discoveryBasePath, $this->discoveryScanDirs, $this->discoveryExcludeDirs, $discoverer);
|
||||
if (null !== $this->discoverer || class_exists(Finder::class)) {
|
||||
$discoverer = $this->discoverer ?? $this->createDiscoverer($logger);
|
||||
$loaders[] = new DiscoveryLoader($this->discoveryBasePath, $this->discoveryScanDirs, $this->discoveryExcludeDirs, $discoverer);
|
||||
} else {
|
||||
$logger->warning('File-based discovery requires symfony/finder. Skipping automatic discovery. Run: composer require symfony/finder');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($loaders as $loader) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue