log-demo
Purpose
Demonstrate MCP logging protocol
Description
The log-demo tool demonstrates how MCP servers can send structured logs to clients at different severity levels. This is primarily an educational tool that shows the MCP logging protocol in action.
MCP supports five standard log levels:
- debug: Detailed information for debugging
- info: General informational messages
- warning: Warning messages for potential issues
- error: Error messages for failures
- critical: Critical issues requiring immediate attention
This tool helps you understand how MCP logging works and can be used to test that your MCP client properly displays logs at different severity levels.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| level | enum | No | Log level: debug, info, warning, error, critical (default: info) |
| message | string | No | Custom message to log (default: auto-generated) |
Example Usage
Ask Claude:
"Show me an example of MCP logging at the warning level"
"Demonstrate debug logging with message 'Testing debug output'"
"Use the log-demo tool to show all log levels"
"Send a critical level log message"Response
# MCP Logging Protocol Demo
## Requested Log Level: WARNING
**Message:** This is a warning level log message
**Timestamp:** 2025-01-05T10:30:00.000Z
## All Log Levels Example
The MCP protocol supports structured logging at multiple levels.
Here are examples of each log level:
[DEBUG] Debug log: Detailed variable state
Data: {"variable":"example","value":42}
[INFO] Info log: Operation completed successfully
Data: {"operation":"demo","duration":"123ms"}
[WARNING] Warning log: Resource usage is high
Data: {"memory":"85%","cpu":"70%"}
[ERROR] Error log: Failed to process request
Data: {"errorCode":"DEMO_ERROR","retryable":true}
[CRITICAL] Critical log: System component failure
Data: {"component":"example","action":"restart_required"}Log Levels Explained
DEBUG
Used for detailed diagnostic information useful during development. Typically disabled in production.
Example use cases:
- Variable state dumps
- Function entry/exit traces
- Detailed request/response data
INFO
General informational messages about normal operations.
Example use cases:
- Operation completion
- Configuration changes
- User actions
WARNING
Potentially problematic situations that don't prevent operation.
Example use cases:
- High resource usage
- Deprecated feature usage
- Retryable failures
ERROR
Error events that might still allow the application to continue.
Example use cases:
- Failed requests
- Invalid input
- External service failures
CRITICAL
Severe errors that may cause the application to abort.
Example use cases:
- System component failures
- Data corruption
- Security breaches
Authentication
Required: No
The log-demo tool is a demonstration tool and does not require authentication.
How MCP Logging Works
When an MCP server sends logs:
- Server generates log message with level and data
- Log is sent through the MCP transport
- Client receives log notification
- Client displays log in its UI (console, panel, etc.)
- Client may filter logs by level or store for later viewing
Clients can set minimum log level thresholds to control what they see.
Log Structure
Each MCP log message includes:
{
level: "debug" | "info" | "warning" | "error" | "critical",
message: string, // Human-readable message
data?: Record<string, any>, // Optional structured data
logger?: string, // Optional logger name/category
timestamp: string // ISO 8601 timestamp
}Common Use Cases
Testing Client Log Display
"Show me an error log to test my client's error display"Understanding Log Levels
"What's the difference between warning and error? Show examples"Learning MCP Protocol
"How does MCP logging work? Demonstrate with examples"Debugging Client Integration
"Send logs at all levels to verify my client handles them correctly"Client Filtering
MCP clients can filter logs by:
- Minimum level: Only show logs at or above a certain level
- Logger name: Filter by specific logger categories
- Search: Text search within log messages
Example filtering scenarios:
- Production: Show only warning and above
- Development: Show all levels including debug
- Troubleshooting: Focus on error and critical only
Related Tools
- trigger-notification - Demonstrate MCP notification protocol
- sampling-demo - Demonstrate MCP sampling protocol
- roots-demo - Demonstrate MCP roots protocol
Next Steps
- All Tools - Return to tools overview
- Development Guide - Learn to build MCP tools
- MCP Protocol Specification - Full MCP protocol documentation