Skip to content

Commit 11cfb16

Browse files
committed
Simplified docs
1 parent b701bb1 commit 11cfb16

File tree

2 files changed

+25
-418
lines changed

2 files changed

+25
-418
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,31 @@ $server = Server::builder()
229229
->build();
230230
```
231231

232+
### Logging
233+
234+
Automatically inject PSR-3 compatible logger into your registered handlers:
235+
236+
```php
237+
// Enable logging in server
238+
$server = Server::builder()
239+
->enableMcpLogging()
240+
->build();
241+
242+
// Use in any handler - logger is auto-injected
243+
#[McpTool]
244+
public function processData(string $input, McpLogger $logger): array {
245+
$logger->info('Processing data', ['input' => $input]);
246+
return ['result' => 'processed'];
247+
}
248+
249+
// Also works with PSR-3 LoggerInterface
250+
#[McpResource(uri: 'data://config')]
251+
public function getConfig(LoggerInterface $logger): array {
252+
$logger->info('Config accessed');
253+
return ['setting' => 'value'];
254+
}
255+
```
256+
232257
## Documentation
233258

234259
**Core Concepts:**
@@ -239,33 +264,8 @@ $server = Server::builder()
239264
**Learning:**
240265
- [Examples](docs/examples.md) - Comprehensive example walkthroughs
241266

242-
### MCP Logging
243-
244-
The SDK provides comprehensive logging capabilities following the [MCP logging specification](https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging):
245-
246-
- **Auto-injection**: `McpLogger` automatically injected into capability handlers
247-
- **Client-controlled filtering**: Clients can set log levels to control verbosity
248-
- **Centralized logging**: All server logs flow to client for unified debugging
249-
- **Fallback support**: Compatible with existing PSR-3 loggers
250-
251-
**Quick example:**
252-
```php
253-
#[McpTool(name: 'my_tool')]
254-
public function myTool(string $input, McpLogger $logger): array {
255-
$logger->info('Tool called', ['input' => $input]);
256-
return ['result' => 'processed'];
257-
}
258-
259-
// Enable in server
260-
$server = Server::builder()
261-
->enableMcpLogging() // Enable centralized logging
262-
->build();
263-
```
264-
265-
📖 **[Complete MCP Logging Guide](docs/mcp-logging.md)**
266267

267268
**External Resources:**
268-
- [SDK documentation](doc/index.rst)
269269
- [Model Context Protocol documentation](https://modelcontextprotocol.io)
270270
- [Model Context Protocol specification](https://spec.modelcontextprotocol.io)
271271
- [Officially supported servers](https://github.com/modelcontextprotocol/servers)

0 commit comments

Comments
 (0)