Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/advanced/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The SDK dispatches 4 broad event types at the protocol level, allowing you to ob
**Dispatched**: When any request is received from the client, before it's processed by handlers.

**Properties**:

- `getRequest(): Request` - The incoming request
- `setRequest(Request $request): void` - Modify the request before processing
- `getSession(): SessionInterface` - The current session
Expand All @@ -45,6 +46,7 @@ The SDK dispatches 4 broad event types at the protocol level, allowing you to ob
**Dispatched**: When a successful response is ready to be sent to the client, after handler execution.

**Properties**:

- `getResponse(): Response` - The response being sent
- `setResponse(Response $response): void` - Modify the response before sending
- `getRequest(): Request` - The original request
Expand All @@ -56,6 +58,7 @@ The SDK dispatches 4 broad event types at the protocol level, allowing you to ob
**Dispatched**: When an error occurs during request processing.

**Properties**:

- `getError(): Error` - The error being sent
- `setError(Error $error): void` - Modify the error before sending
- `getRequest(): Request` - The original request. Messages that fail to parse are rejected before this event, so a listener never sees them.
Expand All @@ -67,6 +70,7 @@ The SDK dispatches 4 broad event types at the protocol level, allowing you to ob
**Dispatched**: When a notification is received from the client, before it's processed by handlers.

**Properties**:

- `getNotification(): Notification` - The incoming notification
- `setNotification(Notification $notification): void` - Modify the notification before processing
- `getSession(): SessionInterface` - The current session
Expand Down
1 change: 1 addition & 0 deletions docs/client/connecting.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ $client->connect($transport);
```

The `connect()` method performs the MCP initialization handshake:

1. Opens the transport connection
2. Sends InitializeRequest with client capabilities
3. Waits for InitializeResult from server
Expand Down
3 changes: 3 additions & 0 deletions docs/client/transports.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $transport = new StdioTransport(
```

**Parameters:**

- `command` (string): The command to execute
- `args` (array): Command arguments
- `cwd` (string|null): Working directory for the process
Expand All @@ -39,6 +40,7 @@ $transport = new HttpTransport(
```

**Parameters:**

- `endpoint` (string): The MCP server URL
- `headers` (array): Additional HTTP headers
- `httpClient` (ClientInterface|null): PSR-18 HTTP client (auto-discovered)
Expand All @@ -50,6 +52,7 @@ $transport = new HttpTransport(
**PSR-18 Auto-Discovery:**

The transport automatically discovers PSR-18 HTTP clients from:

- `php-http/guzzle7-adapter`
- `php-http/curl-client`
- `symfony/http-client`
Expand Down
4 changes: 4 additions & 0 deletions docs/run/server-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ $server = Server::builder()
```

**Parameters:**

- `$name` (string): The server name
- `$version` (string): Version string (semantic versioning recommended)
- `$description` (string|null): Optional description
Expand Down Expand Up @@ -152,6 +153,7 @@ $server = Server::builder()
```

**Parameters:**

- `$basePath` (string): Base directory for discovery (typically `__DIR__`)
- `$scanDirs` (array): Directories to recursively scan for `#[McpTool]`, `#[McpResource]`, etc. All subdirectories are included. (default: `['.', 'src']`)
- `$excludeDirs` (array): Directory names to exclude **within** the scanned directories during recursive scanning
Expand Down Expand Up @@ -189,6 +191,7 @@ $server = Server::builder()
```

**How `excludeDirs` works:**

- If scanning `src/` and there's `src/vendor/`, it will be excluded
- If scanning `lib/` and there's `lib/tests/`, it will be excluded
- But if `vendor/` and `tests/` are at the same level as `src/`, they're not scanned anyway (not in `scanDirs`)
Expand Down Expand Up @@ -217,6 +220,7 @@ $server = Server::builder()
```

**Basic Container Features:**

- Supports constructor auto-wiring for classes with parameterless constructors
- Resolves dependencies where all parameters are type-hinted classes/interfaces known to the container
- Supports parameters with default values
Expand Down
2 changes: 2 additions & 0 deletions docs/run/sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ $server = Server::builder()
```

**Parameters:**

- `$gcProbability` (int): The numerator of the GC probability fraction (default: `1`). Set to `0` to disable GC.
- `$gcDivisor` (int): The denominator of the GC probability fraction (default: `100`). Must be >= 1.

> **Note**: When providing a custom `SessionManagerInterface` via the `$sessionManager` parameter,
> the `gcProbability` and `gcDivisor` settings are ignored — you control GC behavior in your own implementation.

**Available Session Stores:**

- `InMemorySessionStore`: Fast in-memory storage (default)
- `FileSessionStore`: Persistent file-based storage
- `Psr16SessionStore`: PSR-16 compliant cache-based storage
Expand Down
1 change: 1 addition & 0 deletions docs/servers/completions.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function getUserProfile(
```

**Provider Resolution:**

- **Class strings** (`Provider::class`) → Resolved from PSR-11 container
- **Instances** (`new Provider()`) → Used directly
- **Values** (`['a', 'b']`) → Wrapped in `ListCompletionProvider`
Expand Down
1 change: 1 addition & 0 deletions docs/servers/prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ makes the prompt handler throw.
### Error Handling

Prompt handlers can throw any exception, but the type determines how it's handled:

- **`PromptGetException`**: Converted to JSON-RPC error response with the actual exception message
- **Any other exception**: Converted to JSON-RPC error response, but with a generic error message

Expand Down
2 changes: 2 additions & 0 deletions docs/servers/registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ registry somehow. There are three ways to get it there, and they mix freely.
## Attribute-Based Discovery

**Advantages:**

- Declarative and readable
- Automatic parameter inference
- DocBlock integration
Expand All @@ -25,6 +26,7 @@ Register MCP elements programmatically without using attributes. The handler is
any PHP callable.

**Advantages:**

- Fine-grained control
- Runtime configuration
- Conditional registration
Expand Down