You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+47-15Lines changed: 47 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,36 @@
2
2
3
3
All notable changes to `php-mcp/server` will be documented in this file.
4
4
5
+
## PHP MCP Server v1.1.0 - 2025-05-01
6
+
7
+
### Added
8
+
9
+
***Manual Element Registration:** Added fluent methods `withTool()`, `withResource()`, `withPrompt()`, and `withResourceTemplate()` to the `Server` class. This allows programmatic registration of MCP elements as an alternative or supplement to attribute discovery. Both `[ClassName::class, 'methodName']` array handlers and invokable class string handlers are supported.
10
+
***Invokable Class Attribute Discovery:** The server's discovery mechanism now supports placing `#[Mcp*]` attributes directly on invokable PHP class definitions (classes with a public `__invoke` method). The `__invoke` method will be used as the handler.
11
+
***Discovery Path Configuration:** Added `withBasePath()`, `withScanDirectories()`, and `withExcludeDirectories()` methods to the `Server` class for finer control over which directories are scanned during attribute discovery.
12
+
13
+
### Changed
14
+
15
+
***Dependency Injection:** Refactored internal dependency management. Core server components (`Processor`, `Registry`, `TransportState`, etc.) now resolve `LoggerInterface`, `CacheInterface`, and `ConfigurationRepositoryInterface` Just-In-Time from the provided PSR-11 container. See **Breaking Changes** for implications.
16
+
***Default Logging Behavior:** Logging is now **disabled by default**. To enable logging, provide a `LoggerInterface` implementation via `withLogger()` (when using the default container) or by registering it within your custom PSR-11 container.
17
+
***Transport Handler Constructors:** Transport Handlers (e.g., `StdioTransportHandler`, `HttpTransportHandler`) now primarily accept the `Server` instance in their constructor, simplifying their instantiation.
18
+
19
+
### Fixed
20
+
21
+
* Prevented potential "Constant STDERR not defined" errors in non-CLI environments by changing the default logger behavior (see Changed section).
22
+
23
+
### Updated
24
+
25
+
* Extensively updated `README.md` to document manual registration, invokable class discovery, the dependency injection overhaul, discovery path configuration, transport handler changes, and the new default logging behavior.
26
+
27
+
### Breaking Changes
28
+
29
+
***Dependency Injection Responsibility:** Due to the DI refactoring, if you provide a custom PSR-11 container using `withContainer()`, you **MUST** ensure that your container is configured to provide implementations for `LoggerInterface`, `CacheInterface`, and `ConfigurationRepositoryInterface`. The server relies on being able to fetch these from the container.
30
+
***`withLogger/Cache/Config` Behavior with Custom Container:** When a custom container is provided via `withContainer()`, calls to `->withLogger()`, `->withCache()`, or `->withConfig()` on the `Server` instance will **not** override the services resolved from *your* container during runtime. Configuration for these core services must be done directly within your custom container setup.
31
+
***Transport Handler Constructor Signatures:** The constructor signatures for `StdioTransportHandler`, `HttpTransportHandler`, and `ReactPhpHttpTransportHandler` have changed. They now primarily require the `Server` instance. Update any direct instantiations of these handlers accordingly.
@@ -10,28 +40,30 @@ This release introduces the core implementation of the Model Context Protocol (M
10
40
11
41
### ✨ Key Features:
12
42
13
-
***Attribute-Based Definitions:** Easily define MCP Tools (`#[McpTool]`), Resources (`#[McpResource]`, `#[McpResourceTemplate]`), and Prompts (`#[McpPrompt]`) using PHP 8 attributes directly on your methods.
14
-
***Automatic Metadata Inference:** Leverages method signatures (parameters, type hints) and DocBlocks (`@param`, `@return`, summaries) to automatically generate MCP schemas and descriptions, minimizing boilerplate.
15
-
***PSR Compliance:** Integrates seamlessly with standard PHP interfaces:
16
-
*`PSR-3` (LoggerInterface) for flexible logging.
17
-
*`PSR-11` (ContainerInterface) for dependency injection and class resolution.
18
-
*`PSR-16` (SimpleCacheInterface) for caching discovered elements and transport state.
19
-
***Automatic Discovery:** Scans configured directories to find and register your annotated MCP elements.
20
-
***Flexible Configuration:** Uses a configuration repository (`ConfigurationRepositoryInterface`) for fine-grained control over server behaviour, capabilities, and caching.
21
-
***Multiple Transports:**
22
-
* Built-in support for the `stdio` transport, ideal for command-line driven clients.
23
-
* Includes `HttpTransportHandler` components for building standard `http` (HTTP+SSE) transports (requires integration into an HTTP server).
24
-
* Provides `ReactPhpHttpTransportHandler` for seamless integration with asynchronous ReactPHP applications.
25
-
***Protocol Support:** Implements the `2024-11-05` version of the Model Context Protocol.
26
-
***Framework Agnostic:** Designed to work in vanilla PHP projects or integrated into any framework.
43
+
***Attribute-Based Definitions:** Easily define MCP Tools (`#[McpTool]`), Resources (`#[McpResource]`, `#[McpResourceTemplate]`), and Prompts (`#[McpPrompt]`) using PHP 8 attributes directly on your methods.
44
+
***Automatic Metadata Inference:** Leverages method signatures (parameters, type hints) and DocBlocks (`@param`, `@return`, summaries) to automatically generate MCP schemas and descriptions, minimizing boilerplate.
45
+
***PSR Compliance:** Integrates seamlessly with standard PHP interfaces:
46
+
*`PSR-3` (LoggerInterface) for flexible logging.
47
+
*`PSR-11` (ContainerInterface) for dependency injection and class resolution.
48
+
*`PSR-16` (SimpleCacheInterface) for caching discovered elements and transport state.
49
+
50
+
***Automatic Discovery:** Scans configured directories to find and register your annotated MCP elements.
51
+
***Flexible Configuration:** Uses a configuration repository (`ConfigurationRepositoryInterface`) for fine-grained control over server behaviour, capabilities, and caching.
52
+
***Multiple Transports:**
53
+
* Built-in support for the `stdio` transport, ideal for command-line driven clients.
54
+
* Includes `HttpTransportHandler` components for building standard `http` (HTTP+SSE) transports (requires integration into an HTTP server).
55
+
* Provides `ReactPhpHttpTransportHandler` for seamless integration with asynchronous ReactPHP applications.
56
+
57
+
***Protocol Support:** Implements the `2024-11-05` version of the Model Context Protocol.
58
+
***Framework Agnostic:** Designed to work in vanilla PHP projects or integrated into any framework.
27
59
28
60
### 🚀 Getting Started
29
61
30
62
Please refer to the [README.md](README.md) for detailed installation instructions, usage examples, and core concepts. Sample implementations for `stdio` and `reactphp` are available in the `samples/` directory.
31
63
32
64
### ⚠️ Important Notes
33
65
34
-
*When implementing the `http` transport using `HttpTransportHandler`, be aware of the critical server environment requirements detailed in the README regarding concurrent request handling for SSE. Standard synchronous PHP servers (like `php artisan serve` or basic Apache/Nginx setups) are generally **not suitable** without proper configuration for concurrency (e.g., PHP-FPM with multiple workers, Octane, Swoole, ReactPHP, RoadRunner, FrankenPHP).
66
+
* When implementing the `http` transport using `HttpTransportHandler`, be aware of the critical server environment requirements detailed in the README regarding concurrent request handling for SSE. Standard synchronous PHP servers (like `php artisan serve` or basic Apache/Nginx setups) are generally **not suitable** without proper configuration for concurrency (e.g., PHP-FPM with multiple workers, Octane, Swoole, ReactPHP, RoadRunner, FrankenPHP).
0 commit comments