Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public function __construct(
$tools = [];

foreach ($this->endpoint->getFeatures() as $feature) {
if (!$feature->isActive()) {
continue;
}

$tool = $this->getForFeature($feature);

if (!$tool) {
Expand Down Expand Up @@ -117,7 +121,19 @@ public function getAll(): array
*/
private function getEnvelopeAll(): array
{
return $this->dataCacheAccess->get();
$activeFeatureIds = [];

foreach ($this->endpoint->getFeatures() as $feature) {
if ($feature->isActive()) {
$activeFeatureIds[$feature->getId()] = true;
}
}

// Cached definitions must not restore a feature that was revoked or unlinked.
return array_values(array_filter(
$this->dataCacheAccess->get(),
fn (ToolEnvelope $item) => isset($activeFeatureIds[$item->featureId]),
));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public function process(CallToolRequestParams $params): CallToolResult
{
$toolEnvelope = $this->toolProvider->get($params->name);

$this->jsonSchemaValidator->assert($toolEnvelope->tool->inputSchema, $params->arguments);

$feature = $this->getFeature($toolEnvelope->featureId, $params->name);

$this->jsonSchemaValidator->assert($toolEnvelope->tool->inputSchema, $params->arguments);

$processor = $this->processorFactory->create($params->name);

try {
Expand All @@ -76,6 +76,7 @@ public function process(CallToolRequestParams $params): CallToolResult

/**
* @throws InternalError
* @throws InvalidParamsError
*/
private function getFeature(string $id, string $name): Feature
{
Expand All @@ -85,6 +86,10 @@ private function getFeature(string $id, string $name): Feature
throw new InternalError("Feature `$id` for tool `$name` not found.");
}

if (!$feature->isActive()) {
throw new InvalidParamsError("Tool `$name` not found.");
}

return $feature;
}
}