Skip to content
Merged
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
36 changes: 21 additions & 15 deletions src/Capability/Registry/Loader/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ public function load(ReferenceRegistryInterface $registry): void
}

$resource = new Resource(
$data['uri'],
$name,
$description,
$data['mimeType'],
$data['annotations'],
$data['size'],
$data['icons'],
$data['meta'],
uri: $data['uri'],
name: $name,
description: $description,
mimeType: $data['mimeType'] ?? null,
annotations: $data['annotations'] ?? null,
size: $data['size'] ?? null,
icons: $data['icons'] ?? null,
meta: $data['meta'] ?? null,
);
$registry->registerResource($resource, $data['handler'], true);

Expand Down Expand Up @@ -189,12 +189,12 @@ public function load(ReferenceRegistryInterface $registry): void
}

$template = new ResourceTemplate(
$data['uriTemplate'],
$name,
$description,
$data['mimeType'],
$data['annotations'],
$data['meta'],
uriTemplate: $data['uriTemplate'],
name: $name,
description: $description,
mimeType: $data['mimeType'] ?? null,
annotations: $data['annotations'] ?? null,
meta: $data['meta'] ?? null,
);
$completionProviders = $this->getCompletionProviders($reflection);
$registry->registerResourceTemplate($template, $data['handler'], $completionProviders, true);
Expand Down Expand Up @@ -246,7 +246,13 @@ public function load(ReferenceRegistryInterface $registry): void
!$param->isOptional() && !$param->isDefaultValueAvailable(),
);
}
$prompt = new Prompt($name, $description, $arguments, $data['icons'], $data['meta']);
$prompt = new Prompt(
name: $name,
description: $description,
arguments: $arguments,
icons: $data['icons'] ?? null,
meta: $data['meta'] ?? null
);
$completionProviders = $this->getCompletionProviders($reflection);
$registry->registerPrompt($prompt, $data['handler'], $completionProviders, true);

Expand Down
13 changes: 9 additions & 4 deletions src/Server/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ public function addResource(
/**
* Manually registers a resource template handler.
*
* @param Handler $handler
* @param Handler $handler
* @param array<string, mixed>|null $meta
*/
public function addResourceTemplate(
\Closure|array|string $handler,
Expand All @@ -388,6 +389,7 @@ public function addResourceTemplate(
?string $description = null,
?string $mimeType = null,
?Annotations $annotations = null,
?array $meta = null,
): self {
$this->resourceTemplates[] = compact(
'handler',
Expand All @@ -396,6 +398,7 @@ public function addResourceTemplate(
'description',
'mimeType',
'annotations',
'meta',
);

return $this;
Expand All @@ -404,16 +407,18 @@ public function addResourceTemplate(
/**
* Manually registers a prompt handler.
*
* @param Handler $handler
* @param ?Icon[] $icons
* @param Handler $handler
* @param ?Icon[] $icons
* @param array<string, mixed>|null $meta
*/
public function addPrompt(
\Closure|array|string $handler,
?string $name = null,
?string $description = null,
?array $icons = null,
?array $meta = null,
): self {
$this->prompts[] = compact('handler', 'name', 'description', 'icons');
$this->prompts[] = compact('handler', 'name', 'description', 'icons', 'meta');

return $this;
}
Expand Down