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: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ You can install the package via Composer:
42
42
composer require php-mcp/server
43
43
```
44
44
45
-
> **Note:** For Laravel applications, consider using the dedicated [`php-mcp/laravel-server`](https://github.com/php-mcp/laravel) package. It builds upon this core library, providing helpful integrations, configuration options, and Artisan commands specifically tailored for the Laravel framework.
45
+
> **Note:** For Laravel applications, consider using the dedicated [`php-mcp/laravel`](https://github.com/php-mcp/laravel) package. It builds upon this core library, providing helpful integrations, configuration options, and Artisan commands specifically tailored for the Laravel framework.
46
46
47
47
## Getting Started: A Simple `stdio` Server
48
48
@@ -384,9 +384,9 @@ class SummarizePrompt {
384
384
The `PhpMcp\Server\Server` class is the main entry point for configuring and running your MCP server. It provides a fluent interface (method chaining) to set up dependencies, parameters, and manually register elements.
385
385
386
386
***`Server::make(): self`**: Static factory method to create a new server instance. It initializes the server with default implementations for core services (Logger, Cache, Config, Container).
387
-
***`->withLogger(LoggerInterface $logger): self`**: Provide a PSR-3 compliant logger implementation.
388
-
***If using the default `BasicContainer`:** This method replaces the default `StreamLogger` instance and updates the registration within the `BasicContainer`.
389
-
***If using a custom container:** This method *only* sets an internal property on the `Server` instance. It **does not** affect the custom container. You should register your desired `LoggerInterface` directly within your container setup.
387
+
***`->withLogger(LoggerInterface $logger): self`**: Provide a PSR-3 compliant logger implementation. By default, logging is disabled unless a logger is explicitly provided here (when using the default container) or registered in a custom container.
388
+
***If using the default `BasicContainer`:** This method replaces the default no-op logger and updates the registration within the `BasicContainer`, enabling logging.
389
+
***If using a custom container:** This method *only* sets an internal property on the `Server` instance. It **does not** affect the custom container. You should register your desired `LoggerInterface` directly within your container setup to enable logging.
390
390
***`->withCache(CacheInterface $cache): self`**: Provide a PSR-16 compliant cache implementation.
391
391
***If using the default `BasicContainer`:** This method replaces the default `FileCache` instance and updates the registration within the `BasicContainer`.
392
392
***If using a custom container:** This method *only* sets an internal property on the `Server` instance. It **does not** affect the custom container. You should register your desired `CacheInterface` directly within your container setup.
@@ -420,17 +420,17 @@ The `Server` relies on a PSR-11 `ContainerInterface` for two main purposes:
420
420
**Default Behavior (No `withContainer` Call):**
421
421
422
422
If you *do not* call `->withContainer()`, the server uses its internal `PhpMcp\Server\Defaults\BasicContainer`. This basic container comes pre-configured with default implementations:
423
-
*`LoggerInterface` -> `PhpMcp\Server\Defaults\StreamLogger` (writes to `STDERR`)
423
+
*`LoggerInterface` -> `Psr\Log\NullLogger` (Logging is effectively disabled)
424
424
*`CacheInterface` -> `PhpMcp\Server\Defaults\FileCache` (writes to `../cache/mcp_cache` relative to the package directory)
In this default mode, you *can* use the `->withLogger()`, `->withCache()`, and `->withConfig()` methods to replace these defaults. These methods will update the instance used by the server and also update the registration within the internal `BasicContainer`.
427
+
In this default mode, you *can* use the `->withLogger()`, `->withCache()`, and `->withConfig()` methods to replace these defaults. These methods update the instance used by the server and also update the registration within the internal `BasicContainer`.
428
428
429
429
**Using a Custom Container (`->withContainer(MyContainer $c)`):**
430
430
431
431
If you provide your own PSR-11 container instance using `->withContainer()`, the responsibility shifts entirely to you:
432
432
433
-
***You MUST ensure your container is configured to provide implementations for `LoggerInterface`, `CacheInterface`, and `ConfigurationRepositoryInterface`.** The server will attempt to fetch these using `$container->get(...)` and will fail if they are not available.
433
+
***You MUST ensure your container is configured to provide implementations for `LoggerInterface`, `CacheInterface`, and `ConfigurationRepositoryInterface`.** The server will attempt to fetch these using `$container->get(...)` and will fail if they are not available. Providing a `NullLogger` for `LoggerInterface` will keep logging disabled.
434
434
* Your container will also be used to instantiate your handler classes, so ensure all their dependencies are also properly configured within your container.
435
435
* When using a custom container, the `->withLogger()`, `->withCache()`, and `->withConfig()` methods on the `Server` instance become largely ineffective for modifying the dependencies the server *actually uses* during request processing, as the server will always defer to retrieving these services from *your provided container*. Configure these services directly in your container's setup.
0 commit comments