php-sdk/examples/client/README.md
Christopher Hertel 7fe88677ad
[Docs][Examples][CI] Document and gate the 2026-07-28 lifecycle (#457)
docs/stateless-lifecycle.md walks the revision end to end - per-request
_meta, server/discover, multi round-trip requests, caching and subscriptions
- and a runnable example on each side shows what that looks like in code.

CI matrixes both conformance roles over both revisions. --spec-version is
cumulative across the dated revisions, so 2025-11-25 covers the two before
it; 2026-07-28 is not cumulative with them and needs its own run against its
own baseline. The runner is pinned so a PR only goes red for reasons in the
PR, and conformance-weekly tracks the moving target instead - on both
revisions, since the draft scenarios ship only on the alpha dist-tag.

The Inspector cannot reach a modern-lifecycle server (it opens with
initialize), so the example is covered by integration tests instead: one
drives it with hand-built HTTP the way a conforming client would, one drives
it with this SDK's client, and one drives the single endpoint from both eras.
2026-08-19 03:24:17 +02:00

40 lines
1 KiB
Markdown

# 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:
```bash
php examples/client/stdio_discovery_calculator.php
```
## HTTP Client
Connects to an MCP server over HTTP:
```bash
# 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
```
## Modern-era client (2026-07-28)
Speaks the stateless lifecycle: no `initialize`, a `_meta` envelope and SEP-2243 headers on every
request, and multi round-trip calls answered by the client without the caller noticing.
```bash
# First, start the matching server
php -S 127.0.0.1:8000 examples/server/stateless-lifecycle/server.php
# Then run the client
php examples/client/stateless_lifecycle_client.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.