WebClient
class WebClient extends Client
Properties
| protected Protocol | $protocol | from Client | |
| protected string|null | $name | from Client | |
| protected null|array<int, string> | $onlyTools | from Client | |
| protected array<int, string> | $exceptTools | from Client |
Methods
Create an HTTP client with optional OAuth configuration.
Create a local subprocess client.
Cache eligible responses in the given store and scope.
Pin the client to a supported protocol version.
List the available tools allowed on this client.
List the server's prompts.
List the server's resources.
Restore the HTTP transport and registered OAuth configuration.
Restore OAuth settings from the same factory instance as the transport.
Add custom HTTP headers.
Configure OAuth authorization for this client.
Create the OAuth client for this resource and challenge.
Get the canonical URL for a registered OAuth route.
Details
at line 22
__construct(HttpTransport $httpTransport, Implementation|null $clientInfo = null, OAuthConfig|null $oAuthConfig = null)
Create an HTTP client with optional OAuth configuration.
in
Client at line 68
protected Implementation
defaultClientInfo()
Get the application's default client information.
in
Client at line 92
static Client
local(string $command, array $args = [], array $env = [])
Create a local subprocess client.
in
Client at line 108
Client
withCache(string|null $store = null, string|null $for = null)
Cache eligible responses in the given store and scope.
in
Client at line 162
bool
allowsTool(string $name)
Determine whether the tool is allowed on this client.
in
Client at line 181
void
disconnect()
Disconnect the client and release its transport.
in
Client at line 189
bool
connected()
Determine whether the client is connected.
in
Client at line 197
InitializeResult|null
initializeResult()
Get the legacy initialization result.
in
Client at line 205
DiscoverResult|null
discoverResult()
Get the discovery result.
in
Client at line 215
array
capabilities()
Get the server's negotiated capabilities.
in
Client at line 225
Implementation|null
serverInfo()
Get the server's implementation information.
in
Client at line 235
string|null
instructions()
Get the server's instructions.
in
Client at line 245
Client
withProtocolVersion(ProtocolVersion|null $version)
Pin the client to a supported protocol version.
in
Client at line 263
ProtocolVersion
protocolVersion()
Get the negotiated protocol version.
in
Client at line 273
void
ping()
Ping the server.
in
Client at line 284
Collection
tools(int|null $limit = null, iterable|null $default = null)
List the available tools allowed on this client.
in
Client at line 303
ToolResult
callTool(Tool|string $tool, array $arguments = [])
Call a tool with the given arguments.
in
Client at line 337
Collection
prompts(int|null $limit = null, iterable|null $default = null)
List the server's prompts.
in
Client at line 355
PromptResult
getPrompt(string $name, array $arguments = [])
Get a prompt with the given arguments.
in
Client at line 366
Collection
resources(int|null $limit = null, iterable|null $default = null)
List the server's resources.
in
Client at line 382
ResourceReadResult
readResource(string $uri)
Read the resource at the given URI.
in
Client at line 392
array
__serialize()
Serialize the client's name or connection recipe.
at line 120
void
__unserialize(array $data)
Restore the HTTP transport and registered OAuth configuration.
at line 134
protected void
restoreNamedClient(Client $client)
Restore OAuth settings from the same factory instance as the transport.
in
Client at line 453
__destruct()
Disconnect a remaining live connection.
at line 47
WebClient
withHeaders(array $headers)
Add custom HTTP headers.
at line 57
WebClient
withOAuth(string|null $clientId = null, string|null $clientSecret = null, string|null $scope = null, string|null $redirectUri = null)
Configure OAuth authorization for this client.
at line 77
OAuthClient
oAuthClient(string|null $resourceMetadataUrl = null, string|null $challengeScope = null)
Create the OAuth client for this resource and challenge.
at line 106
protected string|null
canonicalRouteUrl(string $name)
Get the canonical URL for a registered OAuth route.