Skip to content

Commit 34ae3c3

Browse files
committed
Added doc
1 parent 14c5091 commit 34ae3c3

File tree

2 files changed

+421
-0
lines changed

2 files changed

+421
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Features
2727
- [x] Revive transports
2828
- [x] Streamable Transport https://github.com/modelcontextprotocol/php-sdk/issues/7
2929
- [ ] ~~Http/SSE-based Transport https://github.com/modelcontextprotocol/php-sdk/issues/8~~
30+
- [x] MCP Logging with auto-injection https://github.com/modelcontextprotocol/php-sdk/issues/70
3031
- [ ] Support pagination
3132
- [ ] Support Schema validation
3233
- [ ] Support multiple versions of the MCP specification https://github.com/modelcontextprotocol/php-sdk/issues/14
@@ -113,6 +114,33 @@ Your AI assistant can now call:
113114

114115
## Documentation
115116

117+
### MCP Logging
118+
119+
The SDK provides comprehensive logging capabilities following the [MCP logging specification](https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging):
120+
121+
- **Auto-injection**: `McpLogger` automatically injected into capability handlers
122+
- **Client-controlled filtering**: Clients can set log levels to control verbosity
123+
- **Centralized logging**: All server logs flow to client for unified debugging
124+
- **Fallback support**: Compatible with existing PSR-3 loggers
125+
126+
**Quick example:**
127+
```php
128+
#[McpTool(name: 'my_tool')]
129+
public function myTool(string $input, McpLogger $logger): array {
130+
$logger->info('Tool called', ['input' => $input]);
131+
return ['result' => 'processed'];
132+
}
133+
134+
// Enable in server
135+
$server = Server::builder()
136+
->enableMcpLogging() // Enable centralized logging
137+
->build();
138+
```
139+
140+
📖 **[Complete MCP Logging Guide](docs/mcp-logging.md)**
141+
142+
### Additional Resources
143+
116144
- [SDK documentation](doc/index.rst)
117145
- [Model Context Protocol documentation](https://modelcontextprotocol.io)
118146
- [Model Context Protocol specification](https://spec.modelcontextprotocol.io)

0 commit comments

Comments
 (0)