Client
class Client
Properties
| protected Protocol | $protocol | ||
| protected string|null | $name | ||
| protected null|array<int, string> | $onlyTools | ||
| protected array<int, string> | $exceptTools |
Methods
Create a client for the supplied transport.
Get the application's default client information.
Create a local subprocess client.
Cache eligible responses in the given store and scope.
Disable response caching.
Set the transport timeout.
Exclude the given tool patterns.
Determine whether the tool is allowed on this client.
Disconnect the client and release its transport.
Determine whether the client is connected.
Get the legacy initialization result.
Get the discovery result.
Get the server's negotiated capabilities.
Get the server's implementation information.
Get the server's instructions.
Pin the client to a supported protocol version.
Get the negotiated protocol version.
Ping the server.
List the available tools allowed on this client.
List the server's prompts.
Get a prompt with the given arguments.
List the server's resources.
Read the resource at the given URI.
Serialize the client's name or connection recipe.
Restore the client without restoring a live connection.
Restore configuration from the registered factory without reusing its connection.
Disconnect a remaining live connection.
Details
at line 56
__construct(Transport $transport, Implementation|null $clientInfo = null)
Create a client for the supplied transport.
at line 68
protected Implementation
defaultClientInfo()
Get the application's default client information.
at line 79
Client
setName(string|null $name)
Set the client's registered name.
at line 92
static Client
local(string $command, array $args = [], array $env = [])
Create a local subprocess client.
at line 100
static WebClient
web(string $url)
Create an HTTP client.
at line 108
Client
withCache(string|null $store = null, string|null $for = null)
Cache eligible responses in the given store and scope.
at line 118
Client
withoutCache()
Disable response caching.
at line 128
Client
withTimeout(float $seconds)
Set the transport timeout.
at line 140
Client
onlyTools(array $tools)
Limit calls to the given tool patterns.
at line 152
Client
exceptTools(array $tools)
Exclude the given tool patterns.
at line 162
bool
allowsTool(string $name)
Determine whether the tool is allowed on this client.
at line 171
Client
connect()
Connect and negotiate the server protocol.
at line 181
void
disconnect()
Disconnect the client and release its transport.
at line 189
bool
connected()
Determine whether the client is connected.
at line 197
InitializeResult|null
initializeResult()
Get the legacy initialization result.
at line 205
DiscoverResult|null
discoverResult()
Get the discovery result.
at line 215
array
capabilities()
Get the server's negotiated capabilities.
at line 225
Implementation|null
serverInfo()
Get the server's implementation information.
at line 235
string|null
instructions()
Get the server's instructions.
at line 245
Client
withProtocolVersion(ProtocolVersion|null $version)
Pin the client to a supported protocol version.
at line 263
ProtocolVersion
protocolVersion()
Get the negotiated protocol version.
at line 273
void
ping()
Ping the server.
at line 284
Collection
tools(int|null $limit = null, iterable|null $default = null)
List the available tools allowed on this client.
at line 303
ToolResult
callTool(Tool|string $tool, array $arguments = [])
Call a tool with the given arguments.
at line 337
Collection
prompts(int|null $limit = null, iterable|null $default = null)
List the server's prompts.
at line 355
PromptResult
getPrompt(string $name, array $arguments = [])
Get a prompt with the given arguments.
at line 366
Collection
resources(int|null $limit = null, iterable|null $default = null)
List the server's resources.
at line 382
ResourceReadResult
readResource(string $uri)
Read the resource at the given URI.
at line 392
array
__serialize()
Serialize the client's name or connection recipe.
at line 414
void
__unserialize(array $data)
Restore the client without restoring a live connection.
at line 442
protected void
restoreNamedClient(Client $client)
Restore configuration from the registered factory without reusing its connection.
at line 453
__destruct()
Disconnect a remaining live connection.