php-sdk/examples/client
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Christopher Hertel 43815e38a8
[Schema][Server] Harden sampling tools against the spec (#420)
* harden sampling tools against the spec

Report tool-flow violations as -32602 instead of dropping the request,
accept resource_link in tool results, gate tools on sampling.tools, and
reject empty content.

* normalize keyed content arrays to lists

array_filter() and friends preserve keys, and a keyed array serializes as a
JSON object instead of the content-block array the schema requires.
2026-08-15 04:13:53 +02:00
..
http_client_communication.php [Schema][Server] Harden sampling tools against the spec (#420) 2026-08-15 04:13:53 +02:00
http_discovery_calculator.php CS update after release of v3.95 (#282) 2026-04-26 12:39:27 +02:00
README.md [Client] Feat: Implement MCP client component (#192) 2026-03-10 17:22:40 +01:00
stdio_client_communication.php [Schema][Server] Harden sampling tools against the spec (#420) 2026-08-15 04:13:53 +02:00
stdio_discovery_calculator.php CS update after release of v3.95 (#282) 2026-04-26 12:39:27 +02:00
stdio_elicitation.php [Client] Add client-side elicitation support (#371) 2026-07-14 23:55:06 +02:00
stdio_roots.php [Client][Server] Add Roots support (#395) 2026-08-14 23:04:25 +02:00

Client Examples

These examples demonstrate how to use the MCP PHP Client SDK.

STDIO Client

Connects to an MCP server running as a child process:

php examples/client/stdio_discovery_calculator.php

HTTP Client

Connects to an MCP server over HTTP:

# First, start an HTTP server
php -S localhost:8000 examples/server/discovery-calculator/server.php

# Then run the client
php examples/client/http_discovery_calculator.php

Requirements

All examples require the server examples to be available. The STDIO examples spawn the server process, while the HTTP examples connect to a running HTTP server.