Server
abstract class Server mixin PendingTestResponse
Traits
Constants
| CAPABILITY_TOOLS |
|
| CAPABILITY_RESOURCES |
|
| CAPABILITY_PROMPTS |
|
| CAPABILITY_COMPLETIONS |
|
| CACHEABLE_METHODS |
|
Properties
| static protected array<string, null|list<object>|object> | $attributeCache | from ReadsAttributes | |
| protected string | $name | ||
| protected string | $version | ||
| protected string | $instructions | ||
| protected array<int, string> | $supportedProtocolVersion | ||
| protected Extension> | $extensions | ||
| protected array<string, array<string, bool>|stdClass|string> | $capabilities | ||
| protected array<int|Tool>|Tool>|Tool>|Tool> | $tools | ||
| protected Resource>|Resource> | $resources | ||
| protected Prompt>|Prompt> | $prompts | ||
| int | $maxPaginationLength | ||
| int | $defaultPaginationLength | ||
| protected Method>> | $methods |
Methods
Resolve the nearest matching attribute in the class hierarchy.
Resolve all matching attributes in the class hierarchy.
Resolve a resource by URI or URI template.
Add or modify a server capability.
Register a custom JSON-RPC method handler.
Boot the server and register its incoming message handler.
Bootstrap the server.
Handle an incoming JSON-RPC message.
Send a terminal failure from eager or streamed request handling.
Create the context for one incoming message.
Return the server's icons.
Validate the protocol metadata on a modern request.
Invoke the method and deliver its eager or streamed response.
Produce responses through the existing send extension point.
Add result metadata and send the response through the transport.
Return method-specific cache hints.
Resolve the cache hints for a successful result.
Resolve cache hints from the resource selected for this message.
Invoke a method under its request context.
Resolve the advertised server capabilities and extensions.
Enable the UI extension when an App resource is registered.
Start a server test invocation.
Details
in
ReadsAttributes at line 24
protected mixed
resolveAttribute(string $attributeClass)
Resolve the nearest matching attribute in the class hierarchy.
in
ReadsAttributes at line 56
protected array
resolveAttributes(string $attributeClass)
Resolve all matching attributes in the class hierarchy.
in
ReadsAttributes at line 82
static void
flushState()
Flush all static state.
in
HasIcons at line 19
array
resolvedIcons()
Resolve icons from attributes and the primitive's icons method.
in
ResolvesResources at line 17
protected Resource
resolveResource(string|null $uri, ServerContext $context)
Resolve a resource by URI or URI template.
at line 155
__construct(Transport $transport)
Create a server for the given transport.
at line 166
void
addCapability(string $key, bool $value = true)
Add or modify a server capability.
Using dot notation like "feature.enabled" will create a nested capability array. Passing a single key like "anotherFeature" will register an empty object capability.
at line 191
void
addMethod(string $method, string $handler)
Register a custom JSON-RPC method handler.
at line 199
void
start()
Boot the server and register its incoming message handler.
at line 210
protected void
boot()
Bootstrap the server.
at line 217
void
handle(string $rawMessage)
Handle an incoming JSON-RPC message.
at line 268
protected void
sendException(Throwable $exception, ServerContext $context, int|string|null $requestId)
Send a terminal failure from eager or streamed request handling.
at line 307
ServerContext
createContext()
Create the context for one incoming message.
at line 335
protected array
icons()
Return the server's icons.
at line 345
protected void
validateProtocolMeta(JsonRpcRequest $request, ServerContext $context)
Validate the protocol metadata on a modern request.
at line 384
protected void
handleMessage(JsonRpcRequest $request, ServerContext $context)
Invoke the method and deliver its eager or streamed response.
at line 415
protected Generator
streamResponses(iterable $response, JsonRpcRequest $request, ServerContext $context)
Produce responses through the existing send extension point.
at line 431
protected void
send(JsonRpcResponse $response, ServerContext $context, JsonRpcRequest|null $request = null)
Add result metadata and send the response through the transport.
at line 452
protected array
cacheHints()
Return method-specific cache hints.
at line 462
protected array
resolveCacheHints(JsonRpcRequest $request, ServerContext $context)
Resolve the cache hints for a successful result.
at line 483
protected Cacheable|null
resourceCacheable(JsonRpcRequest $request, ServerContext $context)
Resolve cache hints from the resource selected for this message.
at line 507
protected iterable|JsonRpcResponse
runMethodHandle(JsonRpcRequest $request, ServerContext $context)
Invoke a method under its request context.
at line 524
protected array
resolvedCapabilities()
Resolve the advertised server capabilities and extensions.
at line 539
protected void
detectUiCapability()
Enable the UI extension when an App resource is registered.
at line 551
static PendingTestResponse|TestResponse|TestListResponse
__callStatic(string $name, array $arguments)
Start a server test invocation.